Package jline.solvers.jmt.io
Class JMTIO
java.lang.Object
jline.solvers.jmt.io.JMTIO
Unified I/O handler for JMT (Java Modelling Tools) files.
This class provides both read and write functionality for JMT XML format files (JSIM and JMVA) from LINE network models. It combines the functionality previously split between JMTXMLParser (write) and JMTResultParser (read).
Supported operations:
- Write: Generate JSIM/JMVA XML files from LINE models
- Read: Parse JSIM/JMVA result files and log files
Usage Example:
JMTIO jmtio = new JMTIO(model, options);
// Write
String outputFile = jmtio.writeJSIM(sn, "model.jsim");
// Read
JMTResult result = jmtio.parseJSIMResult("model.jsim-result.jsim");
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetModel()getSaveHandlers(SolverAvgHandles avgHandles) Gets or creates the SaveHandlers instance for XML generation.longgetSeed()doubledoubleparseCSVLog(String filePath) Parses a CSV log file from JMT.parseJMVAResult(String resultFilePath) Parses a JMVA result XML file.parseJSIMResult(String resultFilePath) Parses a JSIM result XML file.Matrix[][][]parseLogs(boolean[] isNodeLogged, MetricType metric) Parses JMT log files for the specified metric type.Matrix[][]parseTranRespT(List<String[]> arvData, List<String[]> depData) Parses transient response time data from arrival and departure logs.Object[]Parses transient state data from log files.saveArrivalStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveBufferCapacity(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveCacheStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveClasses(SolverAvgHandles avgHandles, ElementDocumentPair elementDocumentPair) Saves class definitions to the XML document.saveClassSwitchStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveDelayOffStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveDropStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveForkStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveGetStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveImpatience(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveJoinStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveLinks(SolverAvgHandles avgHandles, ElementDocumentPair elementDocumentPair) Saves network links to the XML document.saveLogTunnel(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveMetrics(SolverAvgHandles avgHandles, ElementDocumentPair elementDocumentPair) Saves metrics configuration to the XML document.saveNumberOfServers(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) savePreemptiveStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) savePreemptiveWeights(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) savePutStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveRegions(SolverAvgHandles avgHandles, ElementDocumentPair elementDocumentPair) Saves finite capacity regions to the XML document.saveRoutingStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveServerVisits(SolverAvgHandles avgHandles, DocumentSectionPair pair) saveServiceStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveSwitchoverStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) saveXMLHeader(SolverAvgHandles avgHandles, String logPath) Generates the XML header for JMT simulation files.voidUpdates the network structure in the SaveHandlers.
-
Constructor Details
-
JMTIO
Creates a new JMTIO instance with default settings.- Parameters:
model- The LINE network model
-
JMTIO
public JMTIO(Network model, double simConfInt, double simMaxRelErr, long maxSamples, long maxEvents, double maxSimulatedTime, long seed) Creates a new JMTIO instance with full parameter control.- Parameters:
model- The LINE network modelsimConfInt- Confidence interval for simulation (e.g., 0.99)simMaxRelErr- Maximum relative error (e.g., 0.03)maxSamples- Maximum number of samplesmaxEvents- Maximum number of events (-1 for unlimited)maxSimulatedTime- Maximum simulated timeseed- Random seed for reproducibility
-
-
Method Details
-
getSaveHandlers
Gets or creates the SaveHandlers instance for XML generation.- Parameters:
avgHandles- Performance metric handles- Returns:
- SaveHandlers instance
-
updateNetworkStruct
Updates the network structure in the SaveHandlers.- Parameters:
sn- The network structure
-
saveXMLHeader
public ElementDocumentPair saveXMLHeader(SolverAvgHandles avgHandles, String logPath) throws ParserConfigurationException Generates the XML header for JMT simulation files.- Parameters:
avgHandles- Performance metric handleslogPath- Path for simulation logs- Returns:
- ElementDocumentPair containing the XML structure
- Throws:
ParserConfigurationException- if XML parser configuration fails
-
saveClasses
public ElementDocumentPair saveClasses(SolverAvgHandles avgHandles, ElementDocumentPair elementDocumentPair) Saves class definitions to the XML document. -
saveMetrics
public ElementDocumentPair saveMetrics(SolverAvgHandles avgHandles, ElementDocumentPair elementDocumentPair) Saves metrics configuration to the XML document. -
saveLinks
public ElementDocumentPair saveLinks(SolverAvgHandles avgHandles, ElementDocumentPair elementDocumentPair) Saves network links to the XML document. -
saveRegions
public ElementDocumentPair saveRegions(SolverAvgHandles avgHandles, ElementDocumentPair elementDocumentPair) Saves finite capacity regions to the XML document. -
saveArrivalStrategy
public DocumentSectionPair saveArrivalStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveBufferCapacity
public DocumentSectionPair saveBufferCapacity(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveServiceStrategy
public DocumentSectionPair saveServiceStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveRoutingStrategy
public DocumentSectionPair saveRoutingStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveNumberOfServers
public DocumentSectionPair saveNumberOfServers(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveServerVisits
-
saveDropStrategy
public DocumentSectionPair saveDropStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveGetStrategy
public DocumentSectionPair saveGetStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
savePutStrategy
public DocumentSectionPair savePutStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveClassSwitchStrategy
public DocumentSectionPair saveClassSwitchStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveForkStrategy
public DocumentSectionPair saveForkStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveJoinStrategy
public DocumentSectionPair saveJoinStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveCacheStrategy
public DocumentSectionPair saveCacheStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveLogTunnel
public DocumentSectionPair saveLogTunnel(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveDelayOffStrategy
public DocumentSectionPair saveDelayOffStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveSwitchoverStrategy
public DocumentSectionPair saveSwitchoverStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
savePreemptiveStrategy
public DocumentSectionPair savePreemptiveStrategy(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
savePreemptiveWeights
public DocumentSectionPair savePreemptiveWeights(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
saveImpatience
public DocumentSectionPair saveImpatience(SolverAvgHandles avgHandles, DocumentSectionPair pair, int ind) -
parseLogs
Parses JMT log files for the specified metric type.- Parameters:
isNodeLogged- Array indicating which nodes have logging enabledmetric- The metric type to parse (e.g., RespT, QLen)- Returns:
- 3D array of matrices containing parsed data [nodes][classes][data]
-
parseCSVLog
Parses a CSV log file from JMT.- Parameters:
filePath- Path to the CSV log file- Returns:
- List of parsed rows, each as a String array
- Throws:
IOException- if file reading fails
-
parseTranRespT
Parses transient response time data from arrival and departure logs.- Parameters:
arvData- Arrival log datadepData- Departure log data- Returns:
- 2D array of matrices [classes][data matrices]
-
parseTranState
Parses transient state data from log files.- Parameters:
arvData- Arrival log datadepData- Departure log datanodePreload- Initial state at the node- Returns:
- Array containing [state matrix, event types, event classes, event jobs]
-
parseJSIMResult
Parses a JSIM result XML file.- Parameters:
resultFilePath- Path to the JSIM result file- Returns:
- Parsed JMTResult, or null if parsing fails
-
parseJMVAResult
Parses a JMVA result XML file.- Parameters:
resultFilePath- Path to the JMVA result file- Returns:
- Parsed JMTResult, or null if parsing fails
-
getModel
-
getSimConfInt
public double getSimConfInt() -
getSimMaxRelErr
public double getSimMaxRelErr() -
getSeed
public long getSeed()
-