Class SolverSSA

Direct Known Subclasses:
SSA

public class SolverSSA extends NetworkSolver
  • Field Details

    • threadPool

      public ExecutorService threadPool
    • numThreads

      public int numThreads
    • eventCache

      public EventCache eventCache
  • Constructor Details

    • SolverSSA

      public SolverSSA(Network model)
    • SolverSSA

      public SolverSSA(Network model, Object... args)
    • SolverSSA

      public SolverSSA(Network model, NetworkSolver initSolver, Object... args)
      Creates a new SolverSSA that warm-starts the simulated trajectory from the steady-state solution of an auxiliary solver (see NetworkSolver.initFromSolver(jline.solvers.NetworkSolver)).
      Parameters:
      model - The network model to analyze
      initSolver - auxiliary solver used to compute the steady-state distribution
      args - Variable arguments for solver options
    • SolverSSA

      public SolverSSA(Network model, String method)
    • SolverSSA

      public SolverSSA(Network model, SolverOptions options)
    • SolverSSA

      public SolverSSA(Composition model, Object... args)
      Simulates a LAL composition by serial SSA (serial, ssa, default) or the next-reaction method (nrm), with an optional ssa. prefix. The event budget is events when positive, else samples; seed and config.warmupfrac (key warmupfrac) control the run. Results are read with getLALAvgTable() and getActTable().
      Parameters:
      model - the composition
      args - solver options in key-value form
  • Method Details

    • isLALComposition

      public boolean isLALComposition()
      Description copied from class: NetworkSolver
      Whether this solver was built from a LAL composition rather than a Network. False here; SolverAG, SolverCTMC, SolverSSA and SolverMAM override it. A composition-built solver has no Network model, so every inherited entry point that needs stations and classes refuses through NetworkSolver.assertNetworkModel(String) instead of dereferencing a null model.
      Overrides:
      isLALComposition in class NetworkSolver
      Returns:
      true when the solver was built from a LAL composition
    • supports

      public boolean supports(Composition model)
      Every finite LAL composition is accepted; method support is checked by supportsModelMethod(java.lang.String).
    • lalNetworkRefusal

      protected String lalNetworkRefusal(String caller)
      Python SolverSSA's wording (_require_network_metrics).
      Overrides:
      lalNetworkRefusal in class NetworkSolver
      Parameters:
      caller - name of the refused entry point
      Returns:
      the refusal message
    • getLALAvgTable

      public LalTable getLALAvgTable()
      State table of a LAL composition (Python getAvgTable on a composition): estimated probability of each agent's local states. Its attributes record the method, seed, measured events, duration, absorption and warmup fraction.
    • getAvgAct

      public double getAvgAct(Object... action)
      Throughput estimate of one LAL action, named as in SolverCTMC.getAvgAct.
    • getAvgActMode

      public double getAvgActMode(Object node, EventType event, String mode)
      Throughput estimate of a Petri-net mode action (transition, ENABLE|FIRE, mode).
    • getActAvg

      public List<Double> getActAvg(List<?> actions)
      Throughput estimates of several actions, each a name or an Object[] of getAvgAct(java.lang.Object...) arguments.
    • getAvgReward

      public Map<String,Double> getAvgReward()
      Estimates of the rewards declared with Composition.setReward, by name.
    • getActTable

      public LalTable getActTable()
      Estimated labelled action throughputs of a LAL composition.
    • getActT

      public LalTable getActT()
      Alias of getActTable() (MATLAB and Python getActT).
    • actT

      public LalTable actT()
      Alias of getActTable() (MATLAB and Python actT).
    • getActionTable

      public LalTable getActionTable()
      Alias of getActTable() (MATLAB and Python getActionTable).
    • getTotalSimulatedTime

      public double getTotalSimulatedTime()
      Simulated time of the LAL SSA run over which its estimates were measured (the run's horizon after the warmup is discarded; infinite when the run absorbed). Python getTotalSimulatedTime on a composition.
      Returns:
      the measured simulated time
    • getSampleCount

      public int getSampleCount()
      Number of events of the LAL SSA run over which its estimates were measured (the event budget less the warmup, fewer when the run absorbed), the events attribute of its tables. Python getSampleCount on a composition.
      Returns:
      the measured event count
    • getTranAvg

      public void getTranAvg()
      Description copied from class: NetworkSolver
      Computes transient average station metrics over the specified time interval. The timespan is defined in the solver options.
      Overrides:
      getTranAvg in class NetworkSolver
    • getAvgChain

      public SolverResult getAvgChain()
      Description copied from class: NetworkSolver
      Returns average station metrics aggregated by job chains.
      Overrides:
      getAvgChain in class NetworkSolver
      Returns:
      solver result with metrics aggregated by chains
    • getAvgNode

      public SolverResult getAvgNode()
      Description copied from class: NetworkSolver
      Computes average performance metrics at steady-state for all nodes. Aggregates station-level metrics to node-level metrics.
      Overrides:
      getAvgNode in class NetworkSolver
      Returns:
      solver result containing node-level average metrics
    • getAvg

      public SolverResult getAvg()
      Description copied from class: NetworkSolver
      Computes and returns average station metrics at steady-state. This is the main method for obtaining steady-state performance metrics.
      Overrides:
      getAvg in class NetworkSolver
      Returns:
      solver result containing station-level average metrics
    • getAvgTable

      public NetworkAvgTable getAvgTable()
      Description copied from class: NetworkSolver
      Returns a table of average station metrics organized by job classes.
      Overrides:
      getAvgTable in class NetworkSolver
      Returns:
      table containing station-level metrics for each class
    • getFeatureSet

      public static FeatureSet getFeatureSet()
      Returns the feature set supported by the SSA solver
      Returns:
      - the feature set supported by the SSA solver
    • getEventCache

      public EventCache getEventCache()
    • setEventCache

      public void setEventCache(EventCache eventCache)
    • getNumThreads

      public int getNumThreads()
    • setNumThreads

      public void setNumThreads(int numThreads)
    • getStruct

      public NetworkStruct getStruct()
    • getThreadPool

      public ExecutorService getThreadPool()
    • setThreadPool

      public void setThreadPool(ExecutorService threadPool)
    • getMethodFeatureSet

      public FeatureSet getMethodFeatureSet(String method)
      Description copied from class: Solver
      Per-method feature set, or null to signal "this solver does not diverge per method" (the coarse supports(model) is then used, preserving any structural checks it carries). Divergent solvers (e.g. MVA, MAM, NC) override this to return the base envelope with per-method deltas applied.
      Overrides:
      getMethodFeatureSet in class Solver
      Parameters:
      method - the concrete method name
      Returns:
      the per-method FeatureSet, or null
    • getTranReward

      public List<MLMC.Result> getTranReward(String rewardName, double[] times, MLMC.Options control)
      One result per observation time; intervals are pointwise, not simultaneous.
    • listValidMethods

      public List<String> listValidMethods()
    • listValidMethods

      public List<String> listValidMethods(Network model)
    • runAnalyzer

      Description copied from class: Solver
      Executes the solver algorithm to analyze the model. This abstract method must be implemented by concrete solver classes.
      Specified by:
      runAnalyzer in class Solver
      Throws:
      IllegalAccessException - if access to required resources is denied
      ParserConfigurationException - if XML parsing configuration fails
      IOException - if I/O operations fail
    • getStartRate

      public Matrix getStartRate()
      (stations x classes) rate at which a class-r job BEGINS or RESUMES holding a server at station i, estimated over the simulated path exactly as the throughput is.

      At a lossless station with no in-service abandonment getStartRate == getAvgTput + getPreemptRate up to simulation error; the CTMC accessor of the same name reports the exact value.

    • getPreemptRate

      public Matrix getPreemptRate()
      (stations x classes) rate at which a class-r job HOLDING A SERVER at station i is pushed back into the buffer. Zero at a non-preemptive station.
    • setParallelism

      public void setParallelism(int numThreads)
    • supports

      public boolean supports(Network model)
      Description copied from class: Solver
      Checks if this solver supports the given network model. Default implementation returns true; subclasses should override to provide specific feature validation.
      Overrides:
      supports in class Solver
      Parameters:
      model - the network model to check
      Returns:
      true if the model is supported, false otherwise
    • isStochasticMethod

      public boolean isStochasticMethod(String method)
      All SSA methods are stochastic simulation.
      Overrides:
      isStochasticMethod in class Solver
      Parameters:
      method - the method name to classify
      Returns:
      true always
    • supportsModelMethod

      public String supportsModelMethod(String method)
      The fork-join model class, which EVERY SSA method has to clear.

      runAnalyzer tag-augments a fork-join model through ModelAdapter.fjtag, whose first act is fjValidate, so a model that validator refuses is refused whichever method was asked for. The feature set cannot state it -- Fork and Join are declared, and the rules are about how they are WIRED (the pairing, the join strategy, the tasks per link, whether an open class is routed through the fork) -- so it is structural, and it is the validator's own body of rules rather than a copy of them.

      Without it the report offered every ssa.* row on a fork-join model whose Join names no fork, and each one then threw; SolverCTMC gates on the same predicate for the same reason.

      Overrides:
      supportsModelMethod in class Solver
      Parameters:
      method - the concrete method name
      Returns:
      empty string if supported, else the offending reason
    • reset

      public void reset()
      Clears the stored results, the cached trajectory and reseeds the generator.
      Overrides:
      reset in class Solver
    • sample

      public Ret.SampleResult sample(Node node, Integer numEvents, boolean markActivePassive) throws Exception
      Sample path of one node: numEvents rows, row k holding the LINE State of the node OCCUPIED UNTIL t(k), and the node's OWN events in the six-column layout [t, node, code, class, jobId, phase] of Ret.SampleResult.getEvent(int), the type as a wire code. SSA tracks no job identity, so jobId is -1; phase is the phase a PHASE event enters (1-based), 0 elsewhere. See samplePath(jline.lang.nodes.Node, java.lang.Integer, boolean, boolean).
      Parameters:
      node - the node to sample
      numEvents - number of rows (steps); null takes options.samples
      markActivePassive - order each step's events active, passive, PREEMPT, START
      Returns:
      the node's state rows, times and events
      Throws:
      Exception - if sampling fails
    • sample

      public Ret.SampleResult sample(Node node, int numEvents) throws Exception
      Parameters:
      node - The node to sample from
      numEvents - Number of rows (steps)
      Returns:
      the node's state rows, times and events
      Throws:
      Exception - if sampling fails
    • sample

      public Ret.SampleResult sample(Node node) throws Exception
      Sample path of one node with options.samples rows.
      Parameters:
      node - The node to sample from
      Returns:
      the node's state rows, times and events
      Throws:
      Exception - if sampling fails
    • sampleAggr

      public Ret.SampleResult sampleAggr(Node node, Integer numEvents, boolean markActivePassive) throws Exception
      Sample path of one node as per-class job counts, with the node's own events, see sample(jline.lang.nodes.Node, Integer, boolean).
      Parameters:
      node - The node to sample from
      numEvents - number of rows (steps); null takes options.samples
      markActivePassive - order each step's events active, passive, PREEMPT, START
      Returns:
      the node's per-class counts, times and events
      Throws:
      Exception - if sampling fails
    • sampleAggr

      public Ret.SampleResult sampleAggr(Node node, int numEvents) throws Exception
      Aggregated sample path of one node.
      Parameters:
      node - The node to sample from
      numEvents - Number of rows (steps)
      Returns:
      the node's per-class counts, times and events
      Throws:
      Exception - if sampling fails
    • sampleAggr

      public Ret.SampleResult sampleAggr(Node node) throws Exception
      Aggregated sample path of one node with options.samples rows.
      Parameters:
      node - The node to sample from
      Returns:
      the node's per-class counts, times and events
      Throws:
      Exception - if sampling fails
    • stream

      public Ret.SampleResult stream(Node node, StreamingOptions streamingOptions) throws Exception
      Sample node state with real-time streaming to OTLP receiver. Streams phase-detailed state information during simulation.
      Parameters:
      node - The node to sample from
      streamingOptions - Configuration for streaming (endpoint, mode, frequency)
      Returns:
      the sample path, as sample(jline.lang.nodes.Node, Integer, boolean)
      Throws:
      Exception - if sampling fails
    • stream

      public Ret.SampleResult stream(Node node, Integer numEvents, StreamingOptions streamingOptions) throws Exception
      Sample node state with real-time streaming to OTLP receiver. Streams phase-detailed state information during simulation.
      Parameters:
      node - The node to sample from
      numEvents - Number of rows (steps)
      streamingOptions - Configuration for streaming (endpoint, mode, frequency)
      Returns:
      the sample path, as sample(jline.lang.nodes.Node, Integer, boolean)
      Throws:
      Exception - if sampling fails
    • streamAggr

      public Ret.SampleResult streamAggr(Node node, StreamingOptions streamingOptions) throws Exception
      Sample aggregated node state with real-time streaming to OTLP receiver. Streams state information aggregated by job class during simulation.
      Parameters:
      node - The node to sample from
      streamingOptions - Configuration for streaming (endpoint, mode, frequency)
      Returns:
      the aggregated sample path, as sampleAggr(jline.lang.nodes.Node, Integer, boolean)
      Throws:
      Exception - if sampling fails
    • streamAggr

      public Ret.SampleResult streamAggr(Node node, Integer numEvents, StreamingOptions streamingOptions) throws Exception
      Sample aggregated node state with real-time streaming to OTLP receiver. Streams state information aggregated by job class during simulation.
      Parameters:
      node - The node to sample from
      numEvents - Number of rows (steps)
      streamingOptions - Configuration for streaming (endpoint, mode, frequency)
      Returns:
      the aggregated sample path, as sampleAggr(jline.lang.nodes.Node, Integer, boolean)
      Throws:
      Exception - if sampling fails
    • getStreamingCollector

      public Collector getStreamingCollector()
      Get the active streaming collector (for use by Solver_ssa.kt). Returns null if streaming is not active.
      Returns:
      The active Collector, or null
    • sampleSys

      public Ret.SampleResult sampleSys(int numEvents)
      Sample system-wide state evolution using SSA simulation
      Overrides:
      sampleSys in class NetworkSolver
      Parameters:
      numEvents - Number of samples to generate
      Returns:
      SampleSysState containing the system-wide sampling results
      Throws:
      Exception - if sampling fails
    • sampleSys

      public Ret.SampleResult sampleSys() throws Exception
      Sample system-wide state evolution using SSA simulation using default sample count
      Returns:
      SampleSysState containing the system-wide sampling results
      Throws:
      Exception - if sampling fails
    • sampleSysAggr

      public Ret.SampleResult sampleSysAggr(int numEvents)
      Sample aggregated system-wide state evolution using SSA simulation
      Overrides:
      sampleSysAggr in class NetworkSolver
      Parameters:
      numEvents - Number of samples to generate
      Returns:
      SampleSysState containing the aggregated system-wide sampling results
      Throws:
      Exception - if sampling fails
    • sampleSysAggr

      public Ret.SampleResult sampleSysAggr() throws Exception
      Sample aggregated system-wide state evolution using SSA simulation using default sample count
      Returns:
      SampleSysState containing the aggregated system-wide sampling results
      Throws:
      Exception - if sampling fails
    • getProb

      public double getProb(Node node, Matrix state) throws Exception
      Get probability for a specific node state
      Parameters:
      node - The node to get probability for
      state - The state vector (optional - uses node's default state if null)
      Returns:
      Probability of being in the specified state
      Throws:
      Exception - if probability calculation fails
    • getProb

      public double getProb(Node node) throws Exception
      Get probability for a specific node state using the node's default state
      Parameters:
      node - The node to get probability for
      Returns:
      Probability of being in the node's default state
      Throws:
      Exception - if probability calculation fails
    • getProb

      public Ret.ProbabilityResult getProb(int node, Matrix state)
      Get marginal probability for a specific node state (by node index). This overrides the base NetworkSolver method to use SSA sampling.
      Overrides:
      getProb in class NetworkSolver
      Parameters:
      node - The node index to get probability for
      state - The state vector (optional - uses node's default state if null)
      Returns:
      Probability result for being in the specified state
    • getProbAggr

      public double getProbAggr(Node node, Matrix state) throws Exception
      Get aggregated probability for a specific node state
      Parameters:
      node - The node to get probability for
      state - The state vector (optional - uses node's default state if null)
      Returns:
      Aggregated probability of being in the specified state
      Throws:
      Exception - if probability calculation fails
    • getProbAggr

      public double getProbAggr(Node node) throws Exception
      Get aggregated probability for a specific node state using the node's default state
      Parameters:
      node - The node to get probability for
      Returns:
      Aggregated probability of being in the node's default state
      Throws:
      Exception - if probability calculation fails
    • getProbAggr

      public Ret.ProbabilityResult getProbAggr(int node, Matrix state)
      Aggregated probability for a node state, addressed by NODE INDEX.

      The Node-typed pair above is the implementation; this overload is what NetworkSolver.getProbAggr(int, Matrix) declares and what every index-addressed caller reaches, LineCLI's -a prob-aggr included. Without it the base class answered "getProbAggr is not supported by SolverSSA" for a solver that implements it, and a delegating client read that refusal as a missing feature.

      Overrides:
      getProbAggr in class NetworkSolver
      Parameters:
      node - the node index
      state - per-class job counts, or null for the node's own state
      Returns:
      scalar probability in [0,1]
    • getProbSys

      public Ret.ProbabilityResult getProbSys()
      Get system-wide probability for the current system state
      Overrides:
      getProbSys in class NetworkSolver
      Returns:
      Probability of being in the system state
      Throws:
      Exception - if probability calculation fails
    • getProbSysAggr

      public Ret.ProbabilityResult getProbSysAggr()
      Get aggregated system-wide probability for the current system state
      Overrides:
      getProbSysAggr in class NetworkSolver
      Returns:
      Aggregated probability of being in the system state
      Throws:
      Exception - if probability calculation fails
    • defaultOptions

      public static SolverOptions defaultOptions()
      Returns the default solver options for the SSA solver.
      Returns:
      Default solver options with SolverType.SSA
    • planRunLength

      public static Map<String,Object> planRunLength(SolverOptions options, Matrix means, Matrix ciHalfWidth, double samplesUsed)
      The run length the caller would need for the precision they asked for.

      Null unless options.config.runLengthPlan is set; it is either a Double target RELATIVE precision or a map with keys relprecision and confidence.

      Parameters:
      options - the solver options
      means - the measured means
      ciHalfWidth - their confidence-interval half-widths
      samplesUsed - the run length those half-widths came from
      Returns:
      the plan, or null
      See Also:
    • getCdfRespT

      public Ret.DistributionResult getCdfRespT()
      Not available: SolverSSA does not record per-job response times.

      A simulator must report what it measured. The inherited NetworkSolver implementation fabricates an exponential law with the right mean, which carries no information about the tail and would be indistinguishable, to the caller, from a measured distribution. SSA samples state trajectories, not per-job sojourn times, so there is nothing to build an empirical CDF from -- the reference @SolverSSA/getCdfRespT.m refuses by name and so does this port.

      Overrides:
      getCdfRespT in class NetworkSolver
      Returns:
      result containing CDFs for response times [stations x classes]
    • getCdfRespT

      public Ret.DistributionResult getCdfRespT(AvgHandle R)
      Description copied from class: NetworkSolver
      Returns cumulative distribution functions of response times at steady-state. Uses an exponential approximation based on average response times.
      Overrides:
      getCdfRespT in class NetworkSolver
      Parameters:
      R - response time handles (optional)
      Returns:
      result containing CDFs for response times [stations x classes]