Class MemoryGuard

java.lang.Object
jline.solvers.ctmc.MemoryGuard

public final class MemoryGuard extends Object
Hardware-aware, profiling-calibrated memory guard for SolverCTMC. Replaces the historical hard-coded state-space size threshold with a model that (a) probes the memory actually available to this process and (b) calibrates the per-state cost of a sparse steady-state solve by profiling EJML's sparse LU once, caching the fitted power law per machine in the temp directory. Mirrors the MATLAB (ctmc_memory_gate.m / lineGetAvailableMemory.m) and Python-native (memory_guard.py) implementations, sharing the same model. Java 8 compatible: no var, no List.of, no switch expressions.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Result of a gate decision.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Default fraction of available memory the solver may target.
  • Method Summary

    Modifier and Type
    Method
    Description
    gate(double logNstates, boolean force, boolean verbose, double safetyFraction)
    Hardware-aware, calibrated pre-gate.
    static double
    Portable memory budget probe (bytes).
    static double
    Worst-case log-size of the CTMC state space induced by sn: stars-and-bars job placements per class over the stations that keep no ordered buffer (open classes truncated at the cutoff), times the class-sequence multiplicity of every order-preserving buffer, times the service-phase multiplicity at each station, times one routing pointer per (node,class) doing RROBIN or WRROBIN.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_SAFETY_FRACTION

      public static final double DEFAULT_SAFETY_FRACTION
      Default fraction of available memory the solver may target.
      See Also:
  • Method Details

    • getAvailableMemoryBytes

      public static double getAvailableMemoryBytes()
      Portable memory budget probe (bytes). Because CTMC data is allocated on the JVM heap, the binding constraint is the heap headroom, further capped by free physical memory (queried via the OperatingSystemMXBean, which is implemented on all platforms). Never throws; returns a conservative constant if nothing can be determined.
    • stateSpaceLogSize

      public static double stateSpaceLogSize(NetworkStruct sn, SolverOptions options)
      Worst-case log-size of the CTMC state space induced by sn: stars-and-bars job placements per class over the stations that keep no ordered buffer (open classes truncated at the cutoff), times the class-sequence multiplicity of every order-preserving buffer, times the service-phase multiplicity at each station, times one routing pointer per (node,class) doing RROBIN or WRROBIN. Mirrors MATLAB ctmc_state_space_logsize.m and Python state_space_log_size.
      Parameters:
      sn - the network structure, after PH conversion
      options - solver options carrying the cutoff
      Returns:
      the natural log of the worst-case number of states
    • gate

      public static MemoryGuard.GateResult gate(double logNstates, boolean force, boolean verbose, double safetyFraction)
      Hardware-aware, calibrated pre-gate.
      Parameters:
      logNstates - natural log of the worst-case state-space size
      force - bypass the hard stop (still warns)
      verbose - print the estimate
      safetyFraction - fraction of available memory allowed as budget
      Returns:
      a MemoryGuard.GateResult; ok is false only when the predicted footprint exceeds the budget and force is not set.