Class SaveHandlers

java.lang.Object
jline.solvers.wrappers.jmt.handlers.SaveHandlers

public class SaveHandlers extends Object
Handles the generation and serialization of JMT (Java Modelling Tools) simulation models.

This class is responsible for converting LINE network models into JMT XML format for discrete-event simulation. It provides comprehensive support for translating various network components including nodes, routing strategies, service disciplines, and performance metrics.

The class supports both JSIMg (JMT Simulation Graph) and JSIM (JMT Simulation) XML formats, with JSIMg being the default format that includes additional simulation parameters such as confidence intervals, maximum relative error, and stopping criteria.

Key Features:

  • Conversion of LINE Network models to JMT XML format
  • Support for complex routing strategies and class switching
  • Handling of various node types (Sources, Queues, Delays, Sinks, etc.)
  • Translation of service disciplines and scheduling strategies
  • Cache modeling with different replacement strategies
  • Fork-join synchronization patterns
  • Performance metric collection and measurement configuration

Supported Node Types:

  • Sources with various arrival processes
  • Queues with different scheduling disciplines
  • Delay stations for pure delays
  • Sinks for job termination
  • Routers for probabilistic routing
  • Forks and Joins for synchronization
  • Caches with replacement strategies
  • Transitions for Petri net models
See Also:
  • Constructor Details

    • SaveHandlers

      public SaveHandlers(Network simModel, double simMaxRelErr, double simConfInt, SolverAvgHandles avgHandles, long seed, String simFileName, long maxEvents, long maxSamples, double maxSimulatedTime)
      Constructs a SaveHandlers instance with full simulation parameter control.

      This constructor allows complete customization of all simulation parameters for JMT model generation. It is typically used when specific simulation configuration is required beyond the default settings.

      Parameters:
      simModel - The LINE network model to be converted to JMT format
      simMaxRelErr - Maximum relative error for simulation stopping criterion (e.g., 0.03 for 3%)
      simConfInt - Confidence interval for simulation results (e.g., 0.99 for 99%)
      avgHandles - Collection of performance metric handlers to be included in the simulation
      seed - Random number generator seed for reproducible simulation results
      simFileName - Output filename for the simulation model (empty string for default naming)
      maxEvents - Maximum number of events to simulate (0 for unlimited)
      maxSamples - Maximum number of samples to collect for each metric
      maxSimulatedTime - Maximum simulation time (use GlobalConstants.Inf for unlimited)
    • SaveHandlers

      public SaveHandlers(Network simModel)
      Constructs a SaveHandlers instance with default simulation parameters.

      This convenience constructor uses SolverJMT default values for all simulation parameters, making it suitable for most standard simulation scenarios. The default configuration provides reasonable accuracy and performance for typical queueing network analysis.

      Default Parameters:

      • Maximum relative error: 3%
      • Confidence interval: 99%
      • Random seed: 23000
      • Maximum samples: 10,000
      • Maximum events: unlimited
      • Maximum simulation time: unlimited
      Parameters:
      simModel - The LINE network model to be converted to JMT format
  • Method Details

    • updateNetworkStruct

      public void updateNetworkStruct(NetworkStruct sn)
      Updates the internal network structure used for model conversion.

      This method allows updating the network structure after the SaveHandlers instance has been created. This is useful when the network model has been modified or when working with multiple network configurations.

      Parameters:
      sn - The new network structure to use for subsequent conversions
    • getExportableClasses

      public boolean[] getExportableClasses()
      Returns a boolean array indicating which classes should be exported to JMT. Classes with 0 customers are normally skipped unless they are used as cache hit/miss classes (since jobs will switch into them) or can receive jobs via class-switching from another class in the same chain.
      Returns:
      boolean array of length nclasses, true for classes to export
    • saveArrivalStrategy

      public DocumentSectionPair saveArrivalStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveBufferCapacity

      public DocumentSectionPair saveBufferCapacity(DocumentSectionPair documentSectionPair, int ind)
      Saves buffer capacity for JMT XML. LINE uses Kendall notation where cap = K = total system capacity (queue + in-service). JMT's "size" parameter also represents total capacity K.
    • jmtReachablePopulation

      public static double jmtReachablePopulation(NetworkStruct sn, int ist)
      jmtReachablePopulation(int) against an explicit struct, so that SolverJMT.jmtMethodRefusal can apply the writer's own BINDING test without building a writer. sn.cap is DERIVED for a station the user never capped, so "the cap is finite" is not the question -- "the cap is below what can reach the station" is.
      Parameters:
      sn - the model struct
      ist - station index
      Returns:
      the reachable population, possibly infinite
    • jmtCapIsUnbounded

      public static boolean jmtCapIsUnbounded(NetworkStruct sn, int ist)
      Is the buffer at station ist UNBOUNDED, as the JSIM writer reads it?

      THIS PORT DOES NOT CARRY Inf ON sn.cap FOR AN UNBOUNDED STATION, and that is what makes the question worth a named predicate. Station.cap is an int, so it cannot hold Inf: its "no bound" value is Integer.MAX_VALUE (Station.hasFiniteCap() is the predicate for the declared one). refreshCapacity then derives a station's capacity as min(sum(chaincap row), sum(classcap row)), and it SUMS that sentinel across the classes served there -- so an unbounded MIXED station comes out as 2147483647 + 2 = 2147483649 for one open and one closed class, and a Source serving two open classes as 2 x 2147483647 = 4294967294. Utils.isInf(double) recognises the sentinel EXACTLY and so does not see a sum of them.

      >= Integer.MAX_VALUE is refreshCapacity's own idiom for the same question (chainCap >= Integer.MAX_VALUE, station.getCap() >= Integer.MAX_VALUE), and it is safe because setCapacity takes an int: no capacity a caller can declare is larger. MATLAB, native python and C++ all carry a genuine Inf here, so this narrowing is the JAR's alone.

      saveBufferCapacity used to ask the question by NARROWING to int first, which saturates the sum back onto Integer.MAX_VALUE and made Utils.isInf answer correctly by accident. Naming it here is what lets the gate ask the same question as the writer instead of reading the raw double and concluding that every mixed model has a binding buffer.

      Parameters:
      sn - the model struct
      ist - station index
      Returns:
      true when the station has no bound a job can reach
    • jmtStationCapRefusal

      public static String jmtStationCapRefusal(NetworkStruct sn, int ist)
      jmtStationCapAssert(int) as a SENTENCE rather than an exception, against an explicit struct; empty when the buffer at ist is exportable.

      ONE PREDICATE, TWO CALLERS. saveBufferCapacity raises it while writing the JSIM document, and SolverJMT.jmtMethodRefusal returns it so that findSolver and SolverAUTO never offer jmt.jsim on a model the writer will refuse. It used to be reachable only from inside the writer, which is why the gate could not see it.

      Parameters:
      sn - the model struct
      ist - station index
      Returns:
      empty string when exportable, otherwise the refusal
    • saveCache

      public ElementDocumentPair saveCache(ElementDocumentPair elementDocumentPair)
    • saveCacheStrategy

      public DocumentSectionPair saveCacheStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveClassSwitchStrategy

      public DocumentSectionPair saveClassSwitchStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveClasses

      public ElementDocumentPair saveClasses(ElementDocumentPair elementDocumentPair)
    • saveDropRule

      public DocumentSectionPair saveDropRule(DocumentSectionPair documentSectionPair, int ind)
    • saveDropStrategy

      public DocumentSectionPair saveDropStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveEnablingConditions

      public DocumentSectionPair saveEnablingConditions(DocumentSectionPair documentSectionPair, int ind)
    • saveFiringOutcomes

      public DocumentSectionPair saveFiringOutcomes(DocumentSectionPair documentSectionPair, int ind)
    • saveFiringPriorities

      public DocumentSectionPair saveFiringPriorities(DocumentSectionPair documentSectionPair, int ind)
    • saveFiringWeights

      public DocumentSectionPair saveFiringWeights(DocumentSectionPair documentSectionPair, int ind)
    • saveForkStrategy

      public DocumentSectionPair saveForkStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveGetStrategy

      public DocumentSectionPair saveGetStrategy(DocumentSectionPair documentSectionPair)
    • saveGetStrategy

      public DocumentSectionPair saveGetStrategy(DocumentSectionPair documentSectionPair, int ind)
    • setPollingServerClassName

      public DocumentSectionPair setPollingServerClassName(DocumentSectionPair documentSectionPair, int ind)
    • saveSwitchoverStrategy

      public DocumentSectionPair saveSwitchoverStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveDelayOffStrategy

      public DocumentSectionPair saveDelayOffStrategy(DocumentSectionPair documentSectionPair, int ind)
      Saves delay-off and setup time strategies for Queue nodes. This exports the switchoverStrategies, delayOffTime and setUpTime parameters to JMT XML format when the queue has delay-off times enabled.

      JMT's Server constructor expects parameters in order: switchoverStrategies, delayOffStrategies, setUpStrategies

      Parameters:
      documentSectionPair - the document/section pair to append to
      ind - the node index
      Returns:
      updated document/section pair
    • saveInhibitingConditions

      public DocumentSectionPair saveInhibitingConditions(DocumentSectionPair documentSectionPair, int ind)
    • saveJoinStrategy

      public DocumentSectionPair saveJoinStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveLinks

      public ElementDocumentPair saveLinks(ElementDocumentPair elementDocumentPair)
    • saveLogTunnel

      public DocumentSectionPair saveLogTunnel(DocumentSectionPair documentSectionPair, int ind)
    • saveMetric

      public ElementDocumentPair saveMetric(ElementDocumentPair elementDocumentPair, AvgHandle handles)
    • saveMetrics

      public ElementDocumentPair saveMetrics(ElementDocumentPair elementDocumentPair)
    • saveFCRMetrics

      public ElementDocumentPair saveFCRMetrics(ElementDocumentPair elementDocumentPair)
      Saves performance metrics for Finite Capacity Regions (blocking regions). Requests QLen, RespT, ResidT, and Tput metrics for each FCR.
    • saveModeNames

      public DocumentSectionPair saveModeNames(DocumentSectionPair documentSectionPair, int ind)
    • saveNumberOfServers

      public DocumentSectionPair saveNumberOfServers(DocumentSectionPair documentSectionPair, int ind)
    • isHeterogeneousStation

      public boolean isHeterogeneousStation(int stationIdx)
      Checks if a station has heterogeneous server configuration.
      Parameters:
      stationIdx - the station index
      Returns:
      true if the station has heterogeneous servers
    • serverPools

      public SaveHandlers.ServerPools serverPools(int ind)
      Builds the server pools of node ind, or null when the station declares neither server types nor job parallelism.
      Parameters:
      ind - the node index
      Returns:
      the pools, or null when the Server section needs no pool block
    • saveClassParallelism

      public DocumentSectionPair saveClassParallelism(DocumentSectionPair documentSectionPair, int ind)
      Saves the per-class job parallelism to JMT XML. Generates the classParallelism parameter array (Server.serverNumRequired).
      Parameters:
      documentSectionPair - the document/section pair
      ind - the node index
      Returns:
      updated document/section pair
    • saveServerTypeNames

      public DocumentSectionPair saveServerTypeNames(DocumentSectionPair documentSectionPair, int ind)
      Saves heterogeneous server type names to JMT XML. Generates the serverNames parameter array.
      Parameters:
      documentSectionPair - the document/section pair
      ind - the node index
      Returns:
      updated document/section pair
    • saveServersPerType

      public DocumentSectionPair saveServersPerType(DocumentSectionPair documentSectionPair, int ind)
      Saves the number of servers per server type to JMT XML. Generates the serversPerServerType parameter array.
      Parameters:
      documentSectionPair - the document/section pair
      ind - the node index
      Returns:
      updated document/section pair
    • saveServerCompatibilities

      public DocumentSectionPair saveServerCompatibilities(DocumentSectionPair documentSectionPair, int ind)
      Saves server-class compatibility matrix to JMT XML. Generates the serverCompatibilities parameter array.
      Parameters:
      documentSectionPair - the document/section pair
      ind - the node index
      Returns:
      updated document/section pair
    • saveHeteroSchedPolicy

      public DocumentSectionPair saveHeteroSchedPolicy(DocumentSectionPair documentSectionPair, int ind)
      Saves heterogeneous scheduling policy to JMT XML. Generates the schedulingPolicy parameter.
      Parameters:
      documentSectionPair - the document/section pair
      ind - the node index
      Returns:
      updated document/section pair
    • warnHeteroRates

      public void warnHeteroRates(int ind)
      Warns that per-server-type service rates cannot reach the JMT engine.

      JMT keys the ServiceStrategy array of a station by refClass, so its loader (jmt.engine.simEngine.SimLoader) keeps one strategy per class however many (type, class) entries are written, and every pool of a station ends up serving at the class rate. Pool sizes, class compatibilities and the assignment policy do cross; setService(class, type, distribution) rates do not.

      Parameters:
      ind - the node index
    • saveHeterogeneousServerConfig

      public DocumentSectionPair saveHeterogeneousServerConfig(DocumentSectionPair documentSectionPair, int ind)
      Saves all heterogeneous server configuration to JMT XML. This is a convenience method that calls all hetero save methods.
      Parameters:
      documentSectionPair - the document/section pair
      ind - the node index
      Returns:
      updated document/section pair
    • saveNumbersOfServers

      public DocumentSectionPair saveNumbersOfServers(DocumentSectionPair documentSectionPair, int ind)
    • savePlaceCapacities

      public DocumentSectionPair savePlaceCapacities(DocumentSectionPair documentSectionPair, int ind)
    • savePreemptiveStrategy

      public DocumentSectionPair savePreemptiveStrategy(DocumentSectionPair documentSectionPair, int ind)
    • savePreemptiveWeights

      public DocumentSectionPair savePreemptiveWeights(DocumentSectionPair documentSectionPair, int ind)
    • savePutStrategies

      public DocumentSectionPair savePutStrategies(DocumentSectionPair documentSectionPair, int ind)
    • savePutStrategy

      public DocumentSectionPair savePutStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveImpatience

      public DocumentSectionPair saveImpatience(DocumentSectionPair documentSectionPair, int ind)
    • saveRetrialDistributions

      public DocumentSectionPair saveRetrialDistributions(DocumentSectionPair documentSectionPair, int ind)
    • saveRegions

      public ElementDocumentPair saveRegions(ElementDocumentPair elementDocumentPair)
    • saveRoutingStrategy

      public DocumentSectionPair saveRoutingStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveServerVisits

      public DocumentSectionPair saveServerVisits(DocumentSectionPair documentSectionPair)
    • saveServiceStrategy

      public DocumentSectionPair saveServiceStrategy(DocumentSectionPair documentSectionPair, int ind)
    • saveTimingStrategies

      public DocumentSectionPair saveTimingStrategies(DocumentSectionPair documentSectionPair, int ind)
    • saveTotalCapacity

      public DocumentSectionPair saveTotalCapacity(DocumentSectionPair documentSectionPair, int ind)
    • saveXMLHeader

      public ElementDocumentPair saveXMLHeader(String logPath) throws ParserConfigurationException
      Throws:
      ParserConfigurationException