Package jline.solvers.ctmc
Class MemoryGuard
java.lang.Object
jline.solvers.ctmc.MemoryGuard
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 ClassesModifier and TypeClassDescriptionstatic final classResult of a gate decision. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault fraction of available memory the solver may target. -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryGuard.GateResultgate(double logNstates, boolean force, boolean verbose, double safetyFraction) Hardware-aware, calibrated pre-gate.static doublePortable memory budget probe (bytes).
-
Field Details
-
DEFAULT_SAFETY_FRACTION
public static final double DEFAULT_SAFETY_FRACTIONDefault 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. -
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 sizeforce- bypass the hard stop (still warns)verbose- print the estimatesafetyFraction- 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.
-