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

  • Method Details

    • 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)
    • 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
    • sample

      public SampleNodeState sample(Node node, Integer numEvents, boolean markActivePassive) throws Exception
      Sample node state evolution using SSA simulation
      Parameters:
      node - The node to sample from
      numEvents - Number of samples to generate (overrides solver options if provided)
      markActivePassive - Whether to mark events as active/passive
      Returns:
      SampleNodeState containing the sampling results
      Throws:
      Exception - if sampling fails
    • sample

      public SampleNodeState sample(Node node, int numEvents) throws Exception
      Sample node state evolution using SSA simulation
      Parameters:
      node - The node to sample from
      numEvents - Number of samples to generate
      Returns:
      SampleNodeState containing the sampling results
      Throws:
      Exception - if sampling fails
    • sample

      public SampleNodeState sample(Node node) throws Exception
      Sample node state evolution using SSA simulation using default sample count
      Parameters:
      node - The node to sample from
      Returns:
      SampleNodeState containing the sampling results
      Throws:
      Exception - if sampling fails
    • sampleAggr

      public SampleNodeState sampleAggr(Node node, Integer numEvents, boolean markActivePassive) throws Exception
      Sample aggregated node state evolution using SSA simulation
      Parameters:
      node - The node to sample from
      numEvents - Number of samples to generate (overrides solver options if provided)
      markActivePassive - Whether to mark events as active/passive
      Returns:
      SampleNodeState containing the aggregated sampling results
      Throws:
      Exception - if sampling fails
    • sampleAggr

      public SampleNodeState sampleAggr(Node node, int numEvents) throws Exception
      Sample aggregated node state evolution using SSA simulation
      Parameters:
      node - The node to sample from
      numEvents - Number of samples to generate
      Returns:
      SampleNodeState containing the aggregated sampling results
      Throws:
      Exception - if sampling fails
    • sampleAggr

      public SampleNodeState sampleAggr(Node node) throws Exception
      Sample aggregated node state evolution using SSA simulation using default sample count
      Parameters:
      node - The node to sample from
      Returns:
      SampleNodeState containing the aggregated sampling results
      Throws:
      Exception - if sampling fails
    • stream

      public SampleNodeState 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:
      SampleNodeState containing the sampling results
      Throws:
      Exception - if sampling fails
    • stream

      public SampleNodeState 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 samples to generate
      streamingOptions - Configuration for streaming (endpoint, mode, frequency)
      Returns:
      SampleNodeState containing the sampling results
      Throws:
      Exception - if sampling fails
    • streamAggr

      public SampleNodeState 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:
      SampleNodeState containing the aggregated sampling results
      Throws:
      Exception - if sampling fails
    • streamAggr

      public SampleNodeState 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 samples to generate
      streamingOptions - Configuration for streaming (endpoint, mode, frequency)
      Returns:
      SampleNodeState containing the aggregated sampling results
      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 SampleSysState 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 SampleSysState 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]