Package jline.io

Class QN2JAVA

java.lang.Object
jline.io.QN2JAVA

public final class QN2JAVA extends Object
Generates the Java (JLINE) source of a method that rebuilds a Network.

Port of matlab/src/io/QN2JAVA.m. The output is the body of a static method public static Network ex() (or only its statements when headers is false) laid out in the same three blocks as the MATLAB generator: nodes, classes with their arrival and service processes, and the routing matrix read from sn.rtnodes. It compiles against jline.lang.*, jline.lang.nodes.*, jline.lang.processes.* and jline.lang.constant.*.

Processes are written as MATLAB writes them, from their first two moments: an SCV of 1 becomes Exp.fitMean, an SCV of at least 0.5 becomes APH.fitMeanAndSCV, a lower SCV becomes an Erlang with round(1/SCV) phases, and a mean below GlobalConstants.CoarseTol becomes Immediate. A trace-driven process keeps its file. So mean-value measures of the rebuilt model equal the original's, while a non-exponential process is represented by its two-moment fit. Class switching nodes become Routers whose switching is carried by the routing matrix, exactly as in MATLAB.

Differences from the MATLAB text, each made so the output compiles and rebuilds the same model: distributions are instantiated with new; a number MATLAB's %f would round is printed in full; an Erlang phase count is an integer literal; a Fork row is written with probability 1 and a tasks-per-link other than 1 is restored through setTasksPerLink. Node types MATLAB would silently omit (Cache, Logger, Place, Transition) are refused by name instead.

  • Method Details

    • generate

      public static String generate(Network model)
      Returns the generated method, with headers, for a model named after model.getName().
    • generate

      public static String generate(Network model, String modelName)
      Returns the generated method, with headers.
    • generate

      public static String generate(Network model, String modelName, boolean headers)
      Returns the generated code; headers adds the ex() method signature and return.
    • write

      public static void write(Network model, String modelName, PrintStream out)
      Writes the generated method, with headers, to a stream (e.g. System.out).
    • write

      public static void write(Network model, String modelName, PrintStream out, boolean headers)
      Writes the generated code to a stream, which is flushed but not closed.
    • write

      public static void write(Network model, String modelName, Writer out)
      Writes the generated method, with headers, to a writer.
    • write

      public static void write(Network model, String modelName, Writer out, boolean headers)
      Writes the generated code to a writer, which is flushed but not closed.
    • write

      public static void write(Network model, String modelName, String filename)
      Writes the generated method, with headers, to filename.
    • write

      public static void write(Network model, String modelName, String filename, boolean headers)
      Writes the generated code to filename, overwriting it.