Class LQN2PN
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>_thinkand 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>_acqtakes 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>_getmode takes one and the timed, infinite-server<A>_runmode, with the host-demand law, returns it. A PS processor has no tokens: its run modes are infinite-server with the marking-dependent rateg = 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>_startand 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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA (place name, class name) pair naming where to read a measure.static final classWhere to read a processor (replica).static final classResult map, keyed by LQN element name (replica-suffixed_r<k>for k > 1).static final classWhere to read a task (replica). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the Petri net on the first call and returns the same Network on every later call.static Networkconvert(LayeredNetwork lqn) Converts a LayeredNetwork into a Petri net with automatic replication handling (materialised up to 128 task instantiations, pooled beyond).static Networkconvert(LayeredNetwork lqn, String replication) Converts a LayeredNetwork into a Petri net.getMap()Returns the result map, building the net first if needed.
-
Constructor Details
-
LQN2PN
- Parameters:
lqn- the layered networkreplication-"auto","materialize"or"pool"- Throws:
LineInputException- (LINE:input:Argument) on any other replication value
-
-
Method Details
-
convert
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
Converts a LayeredNetwork into a Petri net.- Parameters:
lqn- the layered networkreplication-"auto","materialize"or"pool", as in LQN2QN- Returns:
- the Petri net
-
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
Returns the result map, building the net first if needed. It has four maps keyed by LQN element name:processors: name toLQN2PN.ProcessorMap(sched, mult, and thebusycell for FCFS/SIRO or theruncells for PS/INF);tasks: name toLQN2PN.TaskMap(the thread-poolfreeandbusycells, or the reference taskthinkcell);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
-