Class SRVN2LQNX
.in / .lqn text grammar) for LayeredNetwork.
The reader translates an SRVN document into the LQN XML interchange and hands that to
LayeredNetwork.parseXML, so loading model.in builds exactly the model that loading the
.lqnx written by lqn2xml -Oxml model.in builds. The translation is deterministic and is
reproduced byte for byte by the MATLAB (srvn2lqnx.m), Python (line_solver.io.srvn_io) and
C++ (line::lqn::srvn2lqnx) twins, which is what their parity tests compare.
Grammar covered (LQNS 6): the G, P, U, T, E, A and R
sections; processor, task, group, entry and activity declarations with every option LQNS accepts;
fan-in/fan-out (I/O); semaphore and rwlock entries; activity precedence (sequence, AND/OR fork
and join, quorum join, loop, reply lists); #pragma lines; and SPEX scalar parameters
($x = expr), which are substituted. A SPEX sweep ($x = [ ... ]) used by the model is refused,
since one LayeredNetwork carries one value per parameter. SPEX observations (%u $U), histogram
requests (H) and the R result list are requests for output, not model content, and are
skipped.
Errors: a syntax or reference error raises LineInputException with id LINE:input:Format; a
used SPEX sweep raises LineUnsupportedException with id LINE:unsupported:Format.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatNumber(double x) Shortest C%gspelling that round-tripsx; the four codebases share this rule.static booleanisSrvnFile(String path) True when the file holds SRVN text rather than XML: its first non-blank character is not'<'.static StringThe model name of a file: its basename without the extension.static StringReads a file as text the way Python's text mode does: UTF-8 with malformed bytes replaced, and\r\n/\rline ends read as\n.static StringTranslates SRVN text into an LQN XML document.static StringtranslateFile(String path) Translates an SRVN file into an LQN XML document, naming the model after the file's basename without its extension.
-
Method Details
-
formatNumber
Shortest C%gspelling that round-tripsx; the four codebases share this rule. Integers below 1e15 in magnitude print as%d.- Parameters:
x- the value- Returns:
- its spelling
-
translate
Translates SRVN text into an LQN XML document.- Parameters:
src- the SRVN document textname- the model name written to<lqn-model name=...>- Returns:
- the LQN XML document, newline-terminated
- Throws:
LineInputException- (LINE:input:Format) on a syntax or reference errorLineUnsupportedException- (LINE:unsupported:Format) when the model uses a SPEX sweep
-
readText
Reads a file as text the way Python's text mode does: UTF-8 with malformed bytes replaced, and\r\n/\rline ends read as\n.- Parameters:
path- the file path- Returns:
- the file text
- Throws:
IOException- if the file cannot be read
-
modelName
The model name of a file: its basename without the extension.- Parameters:
path- the file path- Returns:
- the name
-
translateFile
Translates an SRVN file into an LQN XML document, naming the model after the file's basename without its extension.- Parameters:
path- the SRVN file- Returns:
- the LQN XML document
- Throws:
IOException- if the file cannot be read
-
isSrvnFile
True when the file holds SRVN text rather than XML: its first non-blank character is not'<'.- Parameters:
path- the file path- Returns:
- whether the file is SRVN text
-