Class SolverLQNS

java.lang.Object
jline.solvers.Solver
jline.solvers.NetworkSolver
jline.solvers.wrappers.lqns.SolverLQNS
Direct Known Subclasses:
LQNS

public class SolverLQNS extends NetworkSolver
Solver interface to the LQNS external tools: lqns and lqsim for a Layered Queueing Network, and qnsolver for a flat Network.

On a LayeredNetwork the methods are default, lqns, srvn, exactmva, srvn.exactmva, sim, lqsim and lqns.default. On a Network they are default and qns, which leave the multiserver approximation to the default, and qns.conway, qns.rolia, qns.zhou, qns.suri, qns.reiser and qns.schmidt, which name it. A product-form or open Network is written as a JMVA document for qnsolver; a closed non-product-form one is converted by QN2LQN and solved with lqns. This is the arrangement SolverJMT has for JMVA. The layered table is getLNAvgTable().

SolverLQNS provides integration with the external LQNS (Layered Queueing Network Solver) command-line tool developed at Carleton University. This solver enables high-performance analysis of complex layered queueing networks through native C++ implementations.

Key LQNS integration capabilities:

  • External tool integration via command-line interface
  • LQN model serialization to LQNS XML format
  • High-performance native solver algorithms
  • Result parsing and integration back to LINE
  • Support for complex software system models

Requirements: This solver requires the 'lqns' and 'lqsim' command-line tools to be installed and available in the system PATH. Tools can be obtained from: http://www.sce.carleton.ca/rads/lqns/

Since:
1.0
See Also:
  • Constructor Details

    • SolverLQNS

      public SolverLQNS(LayeredNetwork lqnmodel)
    • SolverLQNS

      public SolverLQNS(LayeredNetwork lqnmodel, SolverOptions options)
    • SolverLQNS

      public SolverLQNS(Network model)
      A solver for a flat Network, whose method names are the qns ones. Unlike the layered constructors it does not require lqns, which only a closed non-product-form model reaches; the run checks for the binary it needs.
    • SolverLQNS

      public SolverLQNS(Network model, String method)
    • SolverLQNS

      public SolverLQNS(Network model, SolverOptions options)
    • SolverLQNS

      public SolverLQNS(Network model, Object... varargin)
  • Method Details

    • getLayeredModel

      public LayeredNetwork getLayeredModel()
      The layered model this solver holds, or null for a flat Network.
    • parseNetworkOptions

      public static SolverOptions parseNetworkOptions(Object... varargin)
      Options for a flat Network from name-value pairs: method, multiserver, timespan.
    • networkDefaultOptions

      public static SolverOptions networkDefaultOptions()
      The default options on a flat Network (the former SolverQNS defaults).
    • qnsMethods

      public static List<String> qnsMethods()
      The method names on a flat Network: "default" and "qns" leave the multiserver approximation to the default, "qns.NAME" selects NAME.
    • isQnsMethod

      public static boolean isQnsMethod(String method)
      True for "qns" and every "qns.NAME".
    • qnsMultiserver

      public static String qnsMultiserver(String method)
      The multiserver approximation a Network method selects: the part after "qns.", or "default" for "default" and "qns".
    • getLayeredFeatureSet

      public static FeatureSet getLayeredFeatureSet()
      The layered feature set: what a layer of a LayeredNetwork may use.
      Returns:
      the feature set supported on the layered path
    • getFeatureSet

      public static FeatureSet getFeatureSet()
      The feature set on a flat Network (the qns methods). The layered path is getLayeredFeatureSet().
    • isAvailable

      public static boolean isAvailable()
      True if LQNS can run: a native lqns binary is on the PATH. LINE never runs LQNS from a container image, because its licence is an evaluation agreement that forbids redistribution, so the binary must be one the user installed. To exercise a containerised build in the test suite, put a shim on the PATH with run-tests.sh --lqns-docker.
    • hasNativeLqns

      public static boolean hasNativeLqns()
      True if a native lqns binary is available on the PATH.
    • hasQnsolver

      public static boolean hasQnsolver()
      True if a native qnsolver binary is on the PATH (the qns methods on a Network).
    • getAvg

      public SolverResult getAvg()
      Overrides:
      getAvg in class NetworkSolver
    • getAvgTable

      public NetworkAvgTable getAvgTable()
      The station table of a flat Network. A LayeredNetwork is not indexed by station, so its table is getLNAvgTable().
      Overrides:
      getAvgTable in class NetworkSolver
      Returns:
      table containing station-level metrics for each class
    • getLNAvgTable

      public final LayeredNetworkAvgTable getLNAvgTable()
      The per-element table of a LayeredNetwork.
    • getLNAvgTableImpl

      protected final LayeredNetworkAvgTable getLNAvgTableImpl()
      Body of getLNAvgTable(), split out so LineResultRecorder sees what the getter RETURNED. The JAVA cross-codebase parity row is measured from that rather than from what an example printed.
    • getEnsembleAvg

      protected SolverResult getEnsembleAvg()
    • getStruct

      public LayeredNetworkStruct getStruct()
    • listValidMethods

      public List<String> listValidMethods()
    • listValidMethods

      public List<String> listValidMethods(Network model)
      The method names for the model this solver holds: the layered ones on a LayeredNetwork, qnsMethods() on a flat Network. A non-null argument asks about that Network instead.
    • parseXMLResults

      public SolverResult parseXMLResults(String filename) throws IOException
      Throws:
      IOException
    • runAnalyzer

      public void runAnalyzer() throws IllegalAccessException, ParserConfigurationException
      Description copied from class: Solver
      Executes the solver algorithm to analyze the model. This abstract method must be implemented by concrete solver classes.
      Specified by:
      runAnalyzer in class Solver
      Throws:
      IllegalAccessException - if access to required resources is denied
      ParserConfigurationException - if XML parsing configuration fails
    • runAnalyzer

      public void runAnalyzer(SolverOptions options) throws IllegalAccessException, ParserConfigurationException
      Throws:
      IllegalAccessException
      ParserConfigurationException
    • isStochasticMethod

      public boolean isStochasticMethod(String method)
      The lqsim simulator is stochastic; the analytical lqns/srvn methods are deterministic.
      Overrides:
      isStochasticMethod in class Solver
      Parameters:
      method - the method name to classify
      Returns:
      true if the method returns stochastic estimates
    • supports

      public boolean supports(Network model)
      Coarse gate. On a flat Network it tests the model against getFeatureSet(); on a LayeredNetwork each layer against getLayeredFeatureSet().
      Overrides:
      supports in class Solver
      Parameters:
      model - the network model to check
      Returns:
      true if the model is supported, false otherwise
    • getMethodFeatureSet

      public FeatureSet getMethodFeatureSet(String method)
      The per-method envelope: the Network feature set for the qns methods, and none on a LayeredNetwork, whose gate is the coarse layered test.
      Overrides:
      getMethodFeatureSet in class Solver
      Parameters:
      method - the concrete method name
      Returns:
      the per-method FeatureSet, or null
    • supportsModelMethod

      public String supportsModelMethod(String method)
      Structural finite-capacity gate.

      On a LayeredNetwork the gate refuses the qns names, which need a flat Network, and otherwise applies the coarse layered test.

      On a Network: NOTHING on the qnsolver path reads sn.cap or sn.classcap -- the model is written out for qnsolver, whose MVA-family algorithms have no representation of a finite buffer -- so a capped station was solved as an unbounded one and the table reported the unconstrained answer under this solver's name. There is no registry feature name for plain capacity, hence the structural test; SolverMVA, SolverNC, SolverAG and SolverFluid gate the same way through the same helper.

      Without it SolverAUTO.listValidMethods offered all eight qns method names on the BAS-blocking model of cqn_bas_blocking.

      Overrides:
      supportsModelMethod in class Solver
      Parameters:
      method - the concrete method name
      Returns:
      empty string if supported, else the offending reason
    • qnsImmfeedRefusal

      public static String qnsImmfeedRefusal(NetworkStruct sn)
      Why the qns methods of SolverLQNS cannot serve a model with immediate feedback, or "" when the model has none.

      Immediate feedback (sn.immfeed) keeps a self-looping job on its server instead of re-queueing it, and neither qns path can state that: the JMVA document qnsolver reads carries a mean demand and a visit count per chain, and the LQN QN2LQN writes turns the routing into OR-fork precedences of pseudo-activities on the reference task, where a repeated visit is a new call. Either would answer for re-queueing under this solver's name.

      ONE PREDICATE, TWO CALLERS: supportsModelMethod(java.lang.String) (the gate, hence model.help and SolverAUTO) and runAnalyzer() (the run, for a caller with enableChecks off). SolverJMT keeps its own wording in jmtMethodRefusal. Mirrors matlab/src/solvers/wrappers/LQNS/qns_immfeed_refusal.m.

      Parameters:
      sn - the network struct
      Returns:
      the refusal, or "" when the model carries no immediate feedback
    • qnsMultiserverRefusal

      public static String qnsMultiserverRefusal(NetworkStruct sn, String method)
      Whether qnsolver's own -m switch offers this multiserver approximation.

      THE RULE IS INSIDE THE MULTISERVER BRANCH, and that is not a detail. Without a multiserver station the reference emits no -m at all and answers under the caller's method name, so refusing "suri" there would refuse a model this solver does solve.

      "qnsolver -m" accepts conway, reiser, rolia and zhou. "suri" and "schmidt" are LQNS approximations, reachable only on the non-product-form closed lqns branch, and qnsolver has no flag for either. Mirrors matlab/src/solvers/wrappers/LQNS/qns_multiserver_refusal.m and the C++ is_qnsolver_multiserver.

      Parameters:
      sn - the network struct
      method - the multiserver approximation, i.e. qnsMultiserver(java.lang.String) of the method
      Returns:
      the refusal, or "" when the pair is served
    • getRawAvgTables

      public LayeredNetworkAvgTable[] getRawAvgTables()
      Get raw average tables with detailed metrics for nodes and calls. This method provides more detailed metrics than getAvgTable(), including phase-specific utilization and service times, processor metrics, and call waiting times. Returns two tables aligned with MATLAB's getRawAvgTables: - NodeAvgTable: Node, NodeType, Utilization, Phase1Utilization, Phase2Utilization, Phase1ServiceTime, Phase2ServiceTime, Throughput, ProcWaiting, ProcUtilization - CallAvgTable: SourceNode, TargetNode, Type, Waiting
      Returns:
      Array containing [NodeAvgTable, CallAvgTable] with detailed metrics
    • defaultOptions

      public static SolverOptions defaultOptions()
      Returns the default solver options for the LQNS solver.
      Returns:
      Default solver options with SolverType.LQNS
    • getProbNormConstAggr

      public Ret.ProbabilityResult getProbNormConstAggr()
      Description copied from class: NetworkSolver
      Returns the logarithm of the normalizing constant of state probabilities. This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      getProbNormConstAggr in class NetworkSolver
      Returns:
      result containing the log normalizing constant
    • getProb

      public Ret.ProbabilityResult getProb(int node, Matrix state)
      Description copied from class: NetworkSolver
      Returns marginal state probabilities for a specific node and state. This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      getProb in class NetworkSolver
      Parameters:
      node - the node index for which to compute probabilities
      state - the state vector to query (optional, null for all states)
      Returns:
      result containing marginal state probabilities
    • getProb

      public Ret.ProbabilityResult getProb(int node)
      Description copied from class: NetworkSolver
      Returns marginal state probabilities for a specific node (all states). This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      getProb in class NetworkSolver
      Parameters:
      node - the node index for which to compute probabilities
      Returns:
      result containing marginal state probabilities
    • getProbSys

      public Ret.ProbabilityResult getProbSys()
      Description copied from class: NetworkSolver
      Returns joint state probabilities for the entire system. This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      getProbSys in class NetworkSolver
      Returns:
      result containing joint state probabilities
    • getProbAggr

      public Ret.ProbabilityResult getProbAggr(int node, Matrix state_a)
      Description copied from class: NetworkSolver
      Probability of a SPECIFIC per-class job distribution at a station. Returns P(n1 jobs of class 1, n2 jobs of class 2, ...) for given state.

      Compare with NetworkSolver.getProbMarg(int, int, jline.util.matrix.Matrix): returns queue-length distribution for a single class, i.e., P(n jobs of class r) for n=0,1,...,N(r).

      Overrides:
      getProbAggr in class NetworkSolver
      Parameters:
      node - the node index for which to compute probabilities
      state_a - per-class job counts, e.g., [2,1] = 2 class-1, 1 class-2
      Returns:
      scalar probability in [0,1]
    • getProbAggr

      public Ret.ProbabilityResult getProbAggr(int node)
      Description copied from class: NetworkSolver
      Probability of a SPECIFIC per-class job distribution at a station (current state). Returns P(n1 jobs of class 1, n2 jobs of class 2, ...).

      Compare with NetworkSolver.getProbMarg(int, int, jline.util.matrix.Matrix): returns queue-length distribution for a single class, i.e., P(n jobs of class r) for n=0,1,...,N(r).

      Overrides:
      getProbAggr in class NetworkSolver
      Parameters:
      node - the node index for which to compute probabilities
      Returns:
      scalar probability in [0,1]
    • getProbSysAggr

      public Ret.ProbabilityResult getProbSysAggr()
      Description copied from class: NetworkSolver
      Returns aggregated joint state probabilities for the entire system. This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      getProbSysAggr in class NetworkSolver
      Returns:
      result containing aggregated joint state probabilities
    • sample

      public Ret.SampleResult sample(int node, int numEvents)
      Description copied from class: NetworkSolver
      Samples state trajectories for a specific node. This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      sample in class NetworkSolver
      Parameters:
      node - the node index to sample from
      numEvents - the number of events to sample
      Returns:
      result containing sampled state trajectories
    • sampleAggr

      public Ret.SampleResult sampleAggr(int node, int numEvents)
      Description copied from class: NetworkSolver
      Samples aggregated state trajectories for a specific node. This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      sampleAggr in class NetworkSolver
      Parameters:
      node - the node index to sample from
      numEvents - the number of events to sample
      Returns:
      result containing sampled aggregated state trajectories
    • sampleSys

      public Ret.SampleResult sampleSys(int numEvents)
      Description copied from class: NetworkSolver
      Samples joint system state trajectories. This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      sampleSys in class NetworkSolver
      Parameters:
      numEvents - the number of events to sample
      Returns:
      result containing sampled joint system state trajectories
    • sampleSysAggr

      public Ret.SampleResult sampleSysAggr(int numEvents)
      Description copied from class: NetworkSolver
      Samples aggregated joint system state trajectories. This is an abstract method that must be implemented by concrete solver subclasses.
      Overrides:
      sampleSysAggr in class NetworkSolver
      Parameters:
      numEvents - the number of events to sample
      Returns:
      result containing sampled aggregated joint system state trajectories