Package jline.io

Class LQN2JAVA

java.lang.Object
jline.io.LQN2JAVA

public final class LQN2JAVA extends Object
Generates a Java (JLINE) program that rebuilds a LayeredNetwork and solves it with SolverLN.

Port of matlab/src/io/LQN2JAVA.m. The output is a class TestSolver<NAME> in package jline.examples whose main declares the processors, tasks, entries and activities (with bindings, synchronous and asynchronous calls and replies), then the activity precedences grouped as MATLAB groups them (serial, loop, or-fork, and-fork, or-join, and-join), and finally runs SolverLN.getEnsembleAvg().

Think times and host demands are written as MATLAB's javaDist writes them: each law by its own constructor and parameters (Weibull as (shape, scale), Erlang as (rate, phases), HyperExp in its scalar or vector form, PH/APH/MAP/ME/RAP as matrices), numbers through jnum (4.0, shortest round-trip spelling otherwise), and only an unrecognised class as APH.fitMeanAndSCV with a warning.

Differences from the MATLAB text, each made so the output compiles and rebuilds the same model: the import block lists the same packages in another order; a call mean, loop count or or-fork probability that MATLAB's %g would round is printed in full; the class name drops every character a Java identifier cannot hold, not only spaces. Precedences are read from each task's declared ActivityPrecedence list rather than reconstructed from sn.graph: the reconstruction loses a loop whose count is at most 1 and, after the first and-fork, carries the previous fork's branches into the next one. Output order within each group is the MATLAB order (by activity index; joins by descending index of the joined activity).

  • Method Details

    • generate

      public static String generate(LayeredNetwork model)
      Returns the generated program for a model named after model.getName().
    • generate

      public static String generate(LayeredNetwork model, String modelName)
      Returns the generated program.
    • write

      public static void write(LayeredNetwork model, String modelName, PrintStream out)
      Writes the generated program to a stream (e.g. System.out), which is flushed but not closed.
    • write

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

      public static void write(LayeredNetwork model, String modelName, String filename)
      Writes the generated program to filename, overwriting it.
    • className

      public static String className(String modelName)
      The class name MATLAB derives from the model name, reduced to a valid Java identifier.