Package jline.io

Class LQN2PN

java.lang.Object
jline.io.LQN2PN

public class LQN2PN extends Object
LayeredNetwork to Petri net (GSPN) translator.

JAR port of python/line_solver/io/lqn2pn.py and matlab/src/io/LQN2PN.m; the three must stay in step and build the same net: the same nodes, classes, populations and transition modes, in the same order. See _kb/06-solver-catalog.md (LQN2PN) for the construction and its caveats.

The result is a Network of Place and Transition nodes that keeps every layer of the model at once, so it can be solved without SolverLN's layer decomposition.

Construction:

  • Every request travels as a token. A reference task replica is a closed class whose population is the task multiplicity, waiting in the place <T>_think and leaving it through a timed, infinite-server transition with the think-time law. An entry with an open arrival process is an open class fed by a Source and absorbed by a Sink at the reply.
  • A finite thread pool (a non-reference task of finite multiplicity) is a closed class of thread tokens held in <T>_free. An immediate mode <E>_acq takes one together with the request and parks it in <T>_busy; the reply returns it.
  • An FCFS or SIRO processor is a closed class of processor tokens in <P>_free. An immediate <A>_get mode takes one and the timed, infinite-server <A>_run mode, with the host-demand law, returns it. A PS processor has no tokens: its run modes are infinite-server with the marking-dependent rate g = min(1, c/n), n the jobs at the processor. A phase-type demand (alpha, S) on a PS processor is expanded into one place <A>_ph<k> per phase, entered by alpha through <A>_start and left through exponential modes <A>_run<k> with rates S(k,j) and the exit rates, all scaled by g, which is exact PS with phase-type service. Under FCFS, SIRO and INF the run mode carries the demand law itself, of any family. An infinite-server processor is the timed run mode alone.
  • An activity is its host demand, then its think time (thread kept, processor released), then its call stages. Sequence and OR precedences are place merges and weighted immediate modes, an AND-fork is one immediate mode putting a token on every branch, an AND-join one immediate mode taking one token from every branch.
  • A synchronous call moves the caller's token into the callee, whose subgraph is copied per call site as in LQN2QN, so that the reply returns the token to the right continuation. Its mean is unrolled into floor(m) stages plus one Bernoulli stage.
  • An asynchronous call mints a token of a class of its own (population 0) that walks the callee copy and is destroyed at its reply, while the caller goes on.
  • Forwarding hands the request, with its continuation, to the target entry and releases the forwarder's thread.
  • Phase 2: at the reply the request returns to the caller and the task's thread token itself walks the phase-2 activities back to <T>_free; a task without a thread pool mints a token for it instead.
  • Replication is materialised (one set of places and classes per replica, with the fan-out block rule of LQN2QN) or pooled (r times the tokens).

Documented semantics: a contended thread pool or FCFS processor serves the waiting requests in random order, which is exact where one call path queues there; tokens are uncoloured within a class, so an AND-join in a task with several threads may pair branches of different requests.

Refused by name (LineUnsupportedException): cache tasks, setup and function tasks, an AND-join quorum below its branch count, scheduling other than FCFS, SIRO, PS and INF (reference tasks aside), admission constraints, load and class dependence, server pools, and a host demand on a PS processor that is not a renewal phase-type law (PSNonPhaseType: MAP, ME, RAP, Det, Uniform, Gamma, ...).

Usage: Network pn = LQN2PN.convert(lqn); or, to also read the result map,

   LQN2PN t = new LQN2PN(lqn, "auto");
   Network pn = t.build();
   LQN2PN.ResultMap map = t.getMap();
 
  • Constructor Details

    • LQN2PN

      public LQN2PN(LayeredNetwork lqn, String replication)
      Parameters:
      lqn - the layered network
      replication - "auto", "materialize" or "pool"
      Throws:
      LineInputException - (LINE:input:Argument) on any other replication value
  • Method Details

    • convert

      public static Network convert(LayeredNetwork lqn)
      Converts a LayeredNetwork into a Petri net with automatic replication handling (materialised up to 128 task instantiations, pooled beyond).
      Parameters:
      lqn - the layered network
      Returns:
      the Petri net
    • convert

      public static Network convert(LayeredNetwork lqn, String replication)
      Converts a LayeredNetwork into a Petri net.
      Parameters:
      lqn - the layered network
      replication - "auto", "materialize" or "pool", as in LQN2QN
      Returns:
      the Petri net
    • build

      public Network build()
      Builds the Petri net on the first call and returns the same Network on every later call.
      Returns:
      the Petri net, named <lqn name>-PN
    • getMap

      public LQN2PN.ResultMap getMap()
      Returns the result map, building the net first if needed. It has four maps keyed by LQN element name:
      • processors: name to LQN2PN.ProcessorMap (sched, mult, and the busy cell for FCFS/SIRO or the run cells for PS/INF);
      • tasks: name to LQN2PN.TaskMap (the thread-pool free and busy cells, or the reference task think cell);
      • entries: name to the (request place, class) cells of every copy of the entry;
      • activities: name to the (entry place, class) cells of every copy of the activity.
      Returns:
      the result map