Package jline.lang

Class ModelAdapter

java.lang.Object
jline.lang.ModelAdapter

public class ModelAdapter extends Object
Static class to transform and adapt models, providing functionality for: - Creating tagged job models for response time analysis - Fork-join network transformations (formerly from FJ.java) - Model preprocessing and adaptation operations
  • Constructor Details

    • ModelAdapter

      public ModelAdapter()
  • Method Details

    • tagChain

      public static ModelAdapter.TaggedChainResult tagChain(Network model, Chain chain, JobClass jobclass, String suffix)
      Build a tagged copy of model: one job of jobclass is moved out of its own class into a new class of population 1, so that a solver can follow that single job.

      Port of matlab/src/io/@ModelAdapter/tagChain.m, which is the reference.

      THIS REPLACED A STUB. The previous body created the tagged class and stopped: it gave the class NO SERVICE at any station and NO ROUTING, so the tagged model had a job that could neither be served nor move, and SolverCTMC produced an EMPTY (0x0) generator from it. It also called addJobClass on top of the ClosedClass constructor, which already registers the class, and its population decrement was guarded by > 1 so a two-job class kept both jobs and the tagged model carried one more job than the original. Everything downstream degraded silently because getCdfRespT wrapped the lot in a catch that returned zeros.

      The three things that make a tagged class real, and that the stub omitted: a service process at EVERY station cloned from the source class, the source class's routing replicated for the new class over the linked routing matrix, and one job actually MOVED rather than added.

    • tagChain

      public static ModelAdapter.TaggedChainResult tagChain(Network model, Chain chain, JobClass jobclass)
      Convenience method with default parameters
    • tagChain

      public static ModelAdapter.TaggedChainResult tagChain(Network model, Chain chain)
      Convenience method with default parameters
    • findPaths

      public static Matrix findPaths(NetworkStruct sn, Matrix P, int startNode, int endNode, int r, ArrayList<Integer> toMerge, Matrix QN, Matrix TN, double currentTime, Matrix fjclassmap, Matrix fjforkmap, Network nonfjmodel)
      Finds the response times along each path leading out of startNode up to (and not including) endNode
    • findPaths

      public static Matrix findPaths(NetworkStruct sn, Matrix P, int startNode, int endNode, int r, ArrayList<Integer> toMerge, Matrix QN, Matrix TN, double currentTime, Matrix fjclassmap, Matrix fjforkmap, Network nonfjmodel, Set<Integer> onPath)
      Simple paths only; see the ONPATH note on findPathsCS.
    • findPathsCS

      public static Matrix findPathsCS(NetworkStruct sn, Matrix P, int curNode, int endNode, int curClass, ArrayList<Integer> toMerge, Matrix QN, Matrix TN, double currentTime, Matrix fjclassmap, Matrix fjforkmap, Network nonfjmodel)
      Finds the response times along each path leading out of curNode up to (and not including) endNode Variant for models with class switching
    • findPathsCS

      public static Matrix findPathsCS(NetworkStruct sn, Matrix P, int curNode, int endNode, int curClass, ArrayList<Integer> toMerge, Matrix QN, Matrix TN, double currentTime, Matrix fjclassmap, Matrix fjforkmap, Network nonfjmodel, Set<Long> onPath)
      Enumerates the SIMPLE paths only: the call classes carry a geometric loop (server -> Aux -> server) whenever a call mean exceeds one, so the routing graph between a fork and its join is cyclic and the path set would be infinite without ONPATH. A repeated visit adds no new branch, its residence time is already carried by QN/TN at the station.
    • ht

      public static Ret.FJApprox ht(Network model)
      Heidelberger-Trivedi fork-join queueing network transformation. Transforms the queueing network containing a FJ subsystem into a queueing network without one. Fork nodes changed to Router nodes. Join nodes changed to Delay nodes. One artificial class is created for each parallel branch and for each class. Another delay is added to model the sojourn time of the original classes. -- This approach is derived by PHILIP HEIDELBERGER and KISHOR S. TRIVEDI in "Analytic Queueing Models for Programs with Internal Concurrency"
      Parameters:
      model - - the original network
      Returns:
      - queueing network with no FJ system, the class and the fork maps for the artificial classes, and the auxiliary delay map (each join node is mapped to a corresponding auxiliary delay).
    • mmt

      public static Ret.FJApprox mmt(Network model)
      Fork-Join Transform approach with default forkLambda parameter
    • mmt

      public static Ret.FJApprox mmt(Network model, Matrix forkLambda)
      Fork-Join Transform approach to evaluate queueing networks including fork-join systems. An equivalent network is created where the fork nodes are replaced by routers, the join nodes are replaced by delays, and the parallelism induced by a fork-join system is simulated through the addition of artificial open customer classes.
      Parameters:
      model - - the original queueing network
      forkLambda - - the arrival rates of the artificial classes
      Returns:
      - the equivalent queueing network with the fork-join systems replaced with other nodes, a mapping of the artificial classes and their corresponding original classes, a mapping of the artificial classes and their FJ systems, and the fanout of each artificial class
    • refreshServicesFromBase

      public static boolean refreshServicesFromBase(Ret.FJApprox mmtResult)
      Re-feed a transformed model produced by mmt(jline.lang.Network) from the current service parameters of the base model it was derived from, so that the transformation can be reused across the iterations of an outer fixed point instead of being rebuilt. SolverLN re-solves each layer once per iteration and only the rates change between iterations; the fork topology the transformation encodes does not. Rebuilding costs a full serialisation deep copy of the model each time.

      Three kinds of slot, each handled differently:

      • serviceSrc: base-derived, re-read from the base model.
      • immediateSlots: owned by the transformation, and RESET rather than skipped -- the fork loop overwrites every join with its current synchronisation delay on each pass, so a reused model still holds the previous outer iteration's converged value. Leaving them alone silently warm-starts the fork loop.
      • auxiliary arrivals: owned by the forkLambda fixed point, reset to what a cold call would have set.
      Reading a transformation-owned slot from the base model is the converse error and corrupts the transform outright. Both failure modes are silent.
      Returns:
      false when the provenance cannot be applied, in which case the caller must fall back to a cold mmt(jline.lang.Network).
    • sort_forks

      public static Ret.FJsortForks sort_forks(NetworkStruct sn, NetworkStruct nonfjstruct, Matrix fjforkmap, Matrix fjclassmap, Network nonfjmodel)
      Determines a directed acyclic graph of relationships among fork nodes.
    • removeClass

      public static Network removeClass(Network model, JobClass jobclass)
      Returns a copy of the model with the specified job class removed, updating all station configurations, routing matrices and class-dependent parameters accordingly. The original model is left unchanged.
      Parameters:
      model - the source network model
      jobclass - the job class to remove
      Returns:
      a new model without the specified class
    • aggregateChains

      public static ModelAdapter.AggregateChainResult aggregateChains(Network model)
    • aggregateChains

      public static ModelAdapter.AggregateChainResult aggregateChains(Network model, String suffix)
      Transform a multi-class model into an equivalent chain-aggregated model
      Parameters:
      model - Source Network model with potentially multiple classes per chain
      suffix - Optional suffix for chain class names
      Returns:
      AggregateChainResult containing the aggregated model, alpha, and deaggInfo
    • aggregateFES

      public static FESResult aggregateFES(Network model, List<Station> stationSubset)
      Replace a station subset with a Flow-Equivalent Server (FES) This function replaces a subset of stations in a closed product-form queueing network with a single Flow-Equivalent Server (FES). The FES has Limited Joint Dependence (LJD) service rates where the rate for class-c in state (n1,...,nK) equals the throughput of class-c in an isolated subnetwork consisting only of the subset stations.
      Parameters:
      model - Closed product-form Network model
      stationSubset - List of Station objects to aggregate
      Returns:
      FESResult containing the FES model, FES station, and deaggregation info
    • aggregateFES

      public static FESResult aggregateFES(Network model, List<Station> stationSubset, FESOptions options)
      Replace a station subset with a Flow-Equivalent Server (FES) with options
      Parameters:
      model - Closed product-form Network model
      stationSubset - List of Station objects to aggregate
      options - FES aggregation options
      Returns:
      FESResult containing the FES model, FES station, and deaggregation info
    • fjSupportsReason

      public static String fjSupportsReason(NetworkStruct sn)
      Can the exact fork-join construction be asked for this model?

      The fork-join model class fjValidate(jline.lang.NetworkStruct) admits, asked as a predicate rather than thrown. SolverCTMC.supportsModelMethod and SolverSSA.supportsModelMethod call it so that a caller (help, findSolver, SolverAUTO) sees the verdict before paying for a run, and BOTH analyzers reach the SAME rules through fjtag(jline.lang.Network). The sentence the validator throws names "the native CTMC/SSA fork-join implementation", which is why this predicate lives beside it rather than in either solver.

      IT WRAPS THE VALIDATOR RATHER THAN RESTATING IT, and that is the point: the rules are eight and they move (pairing, join strategy, tasks-per-link, branch probability, open classes through a fork), so a second copy would be a second thing to keep in step. There is exactly one body of rules and two ways in -- one that throws, for the run, and this one, which answers.

      WHAT IT REFUSES AND WHY THE ANALYZER IS RIGHT TO. The fork-join PAIRING is a declaration carried by the Join (new Join(model, name, fork) in all four codebases), not a derivation from the routing: a nested model such as fj_basic_nesting has two forks and two joins whose pairing the routing alone does not determine. So a Join built without naming its fork leaves sn.fj empty, and "Fork nodes without a matched Join" is the honest answer to a model that declares none.

      Parameters:
      sn - the network structure
      Returns:
      empty string when the fork-join construction may run, else the refusal
    • fjValidate

      public static void fjValidate(NetworkStruct sn)
    • fjFoldback

      public static void fjFoldback(Matrix QN, Matrix UN, Matrix RN, Matrix TN, Matrix fjclassmap, int Korig)
      Fold the auxiliary-class metric columns computed on an FJ tag-augmented struct back into the original classes: queue lengths, utilizations and throughputs of the sibling classes are exact aggregates of the class they were forked from; response times are recomputed by Little's law after folding. Mirrors matlab/src/api/fj/sn_fj_foldback.m. The input matrices are modified in place up to column Korig; callers should extract the first Korig columns afterwards.
    • fjtag

      public static ModelAdapter.FJTagResult fjtag(Network model)
      Build a tag-augmented copy of a closed fork-join model for exact native analysis by SolverCTMC/SolverSSA. For each (fork f, class r) pair with matched join j, branch b and tag t (one per chain population slot), an auxiliary transient closed class with population 0 is created. The tag identifies the origin job: the fork firing (AfterFJEvent) emits weight (tasksPerLink) siblings per branch in the tag's auxiliary classes using the lowest free tag, and the join fires only when all siblings OF THE SAME TAG are buffered, releasing one class-r job (AfterEventJoin). Mirrors matlab/src/io/@ModelAdapter/fjtag.m.