Class SaveHandlers
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classServer pools and job parallelism of a node, as the JMT Server section needs them. -
Constructor Summary
ConstructorsConstructorDescriptionSaveHandlers(Network simModel) Constructs a SaveHandlers instance with default simulation parameters.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. -
Method Summary
Modifier and TypeMethodDescriptionboolean[]Returns a boolean array indicating which classes should be exported to JMT.booleanisHeterogeneousStation(int stationIdx) Checks if a station has heterogeneous server configuration.static StringjmtCachePromotion(NetworkStruct sn, int ind, Matrix[] out) Promotion matrix of the Cache at node ind and the reason JMT cannot express its list dynamics ("" when it can; out[0] then holds the matrix).static booleanjmtCapIsUnbounded(NetworkStruct sn, int ist) Is the buffer at stationistUNBOUNDED, as the JSIM writer reads it?static StringThe due date an EDD or EDF station needs and the model does not carry, as a sentence; empty when every such station can be exported (MATLAB jmtDeadlineRefusal).static doublejmtReachablePopulation(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.static StringjmtStationCapRefusal(NetworkStruct sn, int ist) jmtStationCapAssert(int)as a SENTENCE rather than an exception, against an explicit struct; empty when the buffer atistis exportable.static Stringnum2str(double v) MATLABnum2strof a real scalar, the spelling saveClasses.m gives the<userClass softDeadline>attribute: an integer-valued double has no decimal point ("5", not "5.0"), anything else is C%.Ngwith N = max(floor(log10|v|)+5, 5) significant digits, capped at 16 (0.123456 is "0.12346", 1234.5678 is "1234.5678").saveArrivalStrategy(DocumentSectionPair documentSectionPair, int ind) saveBufferCapacity(DocumentSectionPair documentSectionPair, int ind) Saves buffer capacity for JMT XML.saveCache(ElementDocumentPair elementDocumentPair) saveCacheStrategy(DocumentSectionPair documentSectionPair, int ind) saveClasses(ElementDocumentPair elementDocumentPair) saveClassParallelism(DocumentSectionPair documentSectionPair, int ind) Saves the per-class job parallelism to JMT XML.voidsaveClassSoftDeadlines(Document simDoc, Element node, int ind) Writes the<classSoftDeadlines>child of an EDD or EDF station's<node>, one<softDeadline>per exported class; a no-op at any other node.saveClassSwitchStrategy(DocumentSectionPair documentSectionPair, int ind) saveDelayOffStrategy(DocumentSectionPair documentSectionPair, int ind) Saves delay-off and setup time strategies for Queue nodes.saveDropRule(DocumentSectionPair documentSectionPair, int ind) saveDropStrategy(DocumentSectionPair documentSectionPair, int ind) saveEnablingConditions(DocumentSectionPair documentSectionPair, int ind) saveFCRMetrics(ElementDocumentPair elementDocumentPair) Saves performance metrics for Finite Capacity Regions (blocking regions).saveFiringOutcomes(DocumentSectionPair documentSectionPair, int ind) saveFiringPriorities(DocumentSectionPair documentSectionPair, int ind) saveFiringWeights(DocumentSectionPair documentSectionPair, int ind) saveFJMetrics(ElementDocumentPair elementDocumentPair) Requests JMT's 'Fork Join Response Time' and 'Fork Join Number of Customers' at the Fork of every Fork/Join pair, for each class that visits the Fork.saveForkStrategy(DocumentSectionPair documentSectionPair, int ind) saveGetStrategy(DocumentSectionPair documentSectionPair) saveGetStrategy(DocumentSectionPair documentSectionPair, int ind) saveHeterogeneousServerConfig(DocumentSectionPair documentSectionPair, int ind) Saves all heterogeneous server configuration to JMT XML.saveHeteroSchedPolicy(DocumentSectionPair documentSectionPair, int ind) Saves heterogeneous scheduling policy to JMT XML.saveImpatience(DocumentSectionPair documentSectionPair, int ind) saveInhibitingConditions(DocumentSectionPair documentSectionPair, int ind) saveJoinStrategy(DocumentSectionPair documentSectionPair, int ind) saveLinks(ElementDocumentPair elementDocumentPair) saveLogTunnel(DocumentSectionPair documentSectionPair, int ind) saveMetric(ElementDocumentPair elementDocumentPair, AvgHandle handles) saveMetrics(ElementDocumentPair elementDocumentPair) saveModeNames(DocumentSectionPair documentSectionPair, int ind) saveNumberOfServers(DocumentSectionPair documentSectionPair, int ind) saveNumbersOfServers(DocumentSectionPair documentSectionPair, int ind) savePlaceCapacities(DocumentSectionPair documentSectionPair, int ind) savePreemptiveStrategy(DocumentSectionPair documentSectionPair, int ind) savePreemptiveWeights(DocumentSectionPair documentSectionPair, int ind) savePutStrategies(DocumentSectionPair documentSectionPair, int ind) savePutStrategy(DocumentSectionPair documentSectionPair, int ind) saveRegions(ElementDocumentPair elementDocumentPair) saveRetrialDistributions(DocumentSectionPair documentSectionPair, int ind) saveRoutingStrategy(DocumentSectionPair documentSectionPair, int ind) saveServerCompatibilities(DocumentSectionPair documentSectionPair, int ind) Saves server-class compatibility matrix to JMT XML.saveServersPerType(DocumentSectionPair documentSectionPair, int ind) Saves the number of servers per server type to JMT XML.saveServerTypeNames(DocumentSectionPair documentSectionPair, int ind) Saves heterogeneous server type names to JMT XML.saveServerVisits(DocumentSectionPair documentSectionPair) saveServiceStrategy(DocumentSectionPair documentSectionPair, int ind) saveSwitchoverStrategy(DocumentSectionPair documentSectionPair, int ind) saveTimingStrategies(DocumentSectionPair documentSectionPair, int ind) saveTotalCapacity(DocumentSectionPair documentSectionPair, int ind) saveXMLHeader(String logPath) serverPools(int ind) Builds the server pools of nodeind, or null when the station declares neither server types nor job parallelism.setPollingServerClassName(DocumentSectionPair documentSectionPair, int ind) voidUpdates the internal network structure used for model conversion.voidwarnHeteroRates(int ind) Warns that per-server-type service rates cannot reach the JMT engine.
-
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 formatsimMaxRelErr- 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 simulationseed- Random number generator seed for reproducible simulation resultssimFileName- 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 metricmaxSimulatedTime- Maximum simulation time (use GlobalConstants.Inf for unlimited)
-
SaveHandlers
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
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
-
jmtCachePromotion
Promotion matrix of the Cache at node ind and the reason JMT cannot express its list dynamics ("" when it can; out[0] then holds the matrix). ONE PREDICATE, TWO CALLERS, as MATLAB jmtCachePromotion: saveCacheStrategy writes the matrix and refuses on the reason, and SolverJMT.jmtMethodRefusal asks for the reason alone, so supports(), supportsModelMethod and the run agree (supports() used to accept a FIFO cache of capacity 2 the writer refused). FIFO and SFIFO: JMT re-appends an item hit in the list it stays in (removeItemMode 0), which is LRU order, a no-op only in a unit list, so a FIFO cache whose items can stay in a list of capacity above 1 is refused.- Parameters:
sn- the model structind- the Cache's node indexout- a one-element holder for the matrix, or null- Returns:
- "" when JMT can express the cache, otherwise the refusal
-
saveArrivalStrategy
-
saveBufferCapacity
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
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 structist- station index- Returns:
- the reachable population, possibly infinite
-
jmtCapIsUnbounded
Is the buffer at stationistUNBOUNDED, 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.capis anint, so it cannot hold Inf: its "no bound" value isInteger.MAX_VALUE(Station.hasFiniteCap()is the predicate for the declared one). refreshCapacity then derives a station's capacity asmin(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_VALUEis refreshCapacity's own idiom for the same question (chainCap >= Integer.MAX_VALUE,station.getCap() >= Integer.MAX_VALUE), and it is safe because setCapacity takes anint: 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.Do not answer it by NARROWING to int first: that saturates the sum back onto Integer.MAX_VALUE and makes Utils.isInf right only 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 structist- station index- Returns:
- true when the station has no bound a job can reach
-
jmtDeadlineRefusal
The due date an EDD or EDF station needs and the model does not carry, as a sentence; empty when every such station can be exported (MATLAB jmtDeadlineRefusal).JMT 1.2.x serves EDD and EDF for real: Queue.process stamps each arriving job with softDeadlines(classId) + now, read from the node's
<classSoftDeadlines>element, and EDDStrategy/EDFStrategy order the buffer by it. A job that arrives with no due date keeps Job's -1.0 and EDDStrategy.put THROWS ("Attempting to schedule job with no soft deadline") instead of serving FCFS, so a served class without a finite deadline is an aborted run and is refused here. The<userClass softDeadline>attribute saveClasses writes does not satisfy this: it feeds only the system tardiness measures.ONE PREDICATE, TWO CALLERS: saveClassSoftDeadlines raises it while writing the JSIM document, and SolverJMT.jmtMethodRefusal returns it.
- Parameters:
sn- the model struct- Returns:
- empty string when exportable, otherwise the refusal
-
saveClassSoftDeadlines
Writes the<classSoftDeadlines>child of an EDD or EDF station's<node>, one<softDeadline>per exported class; a no-op at any other node. Must precede the sections, as SIMmodeldefinition.xsd sequences<node>(MATLAB saveClassSoftDeadlines).- Parameters:
simDoc- the JSIM documentnode- the<node>element being builtind- node index
-
jmtStationCapRefusal
jmtStationCapAssert(int)as a SENTENCE rather than an exception, against an explicit struct; empty when the buffer atistis 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.
- Parameters:
sn- the model structist- station index- Returns:
- empty string when exportable, otherwise the refusal
-
saveCache
-
saveCacheStrategy
-
saveClassSwitchStrategy
public DocumentSectionPair saveClassSwitchStrategy(DocumentSectionPair documentSectionPair, int ind) -
saveClasses
-
saveDropRule
-
saveDropStrategy
-
saveEnablingConditions
-
saveFiringOutcomes
-
saveFiringPriorities
-
saveFiringWeights
-
saveForkStrategy
-
saveGetStrategy
-
saveGetStrategy
-
setPollingServerClassName
public DocumentSectionPair setPollingServerClassName(DocumentSectionPair documentSectionPair, int ind) -
saveSwitchoverStrategy
-
saveDelayOffStrategy
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 toind- the node index- Returns:
- updated document/section pair
-
saveInhibitingConditions
public DocumentSectionPair saveInhibitingConditions(DocumentSectionPair documentSectionPair, int ind) -
saveJoinStrategy
-
saveLinks
-
saveLogTunnel
-
num2str
MATLABnum2strof a real scalar, the spelling saveClasses.m gives the<userClass softDeadline>attribute: an integer-valued double has no decimal point ("5", not "5.0"), anything else is C%.Ngwith N = max(floor(log10|v|)+5, 5) significant digits, capped at 16 (0.123456 is "0.12346", 1234.5678 is "1234.5678").- Parameters:
v- the value- Returns:
- its num2str text
-
saveMetric
-
saveMetrics
-
saveFCRMetrics
Saves performance metrics for Finite Capacity Regions (blocking regions). Requests QLen, RespT, ResidT, and Tput metrics for each FCR. -
saveFJMetrics
Requests JMT's 'Fork Join Response Time' and 'Fork Join Number of Customers' at the Fork of every Fork/Join pair, for each class that visits the Fork. JMT keeps the section list in the Fork's input section and closes a job's entry when its Join fires, so both measure the whole fork-join section. Port of MATLAB saveFJMetrics in JMTIO/saveMetrics.m. -
saveModeNames
-
saveNumberOfServers
-
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
Builds the server pools of nodeind, 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
Saves the per-class job parallelism to JMT XML. Generates the classParallelism parameter array (Server.serverNumRequired).- Parameters:
ind- the node index- Returns:
- updated document/section pair
-
saveServerTypeNames
Saves heterogeneous server type names to JMT XML. Generates the serverNames parameter array.- Parameters:
ind- the node index- Returns:
- updated document/section pair
-
saveServersPerType
Saves the number of servers per server type to JMT XML. Generates the serversPerServerType parameter array.- Parameters:
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:
ind- the node index- Returns:
- updated document/section pair
-
saveHeteroSchedPolicy
Saves heterogeneous scheduling policy to JMT XML. Generates the schedulingPolicy parameter.- Parameters:
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:
ind- the node index- Returns:
- updated document/section pair
-
saveNumbersOfServers
-
savePlaceCapacities
-
savePreemptiveStrategy
-
savePreemptiveWeights
-
savePutStrategies
-
savePutStrategy
-
saveImpatience
-
saveRetrialDistributions
public DocumentSectionPair saveRetrialDistributions(DocumentSectionPair documentSectionPair, int ind) -
saveRegions
-
saveRoutingStrategy
-
saveServerVisits
-
saveServiceStrategy
-
saveTimingStrategies
-
saveTotalCapacity
-
saveXMLHeader
- Throws:
ParserConfigurationException
-