Class SolverUQ

Direct Known Subclasses:
UQ

public class SolverUQ extends EnsembleSolver
UQ solver for Bayesian-style parameter uncertainty analysis.

This solver wraps another solver and handles Prior distributions by expanding the model into a family of networks, one for each alternative in the Prior. Results are aggregated using prior-weighted expectations.

Usage:

 Prior prior = new Prior(Arrays.asList(new Exp(1.0), new Exp(2.0)), new double[]{0.6, 0.4});
 queue.setService(jobClass, prior);
 SolverUQ solver = new SolverUQ(model, m -> new SolverMVA(m));
 AvgTable avgTable = solver.getAvgTable();
 
  • Field Details

    • originalModel

      protected Network originalModel
    • solverFactory

      protected SolverUQ.SolverFactory solverFactory
    • priorInfo

      protected SolverUQ.PriorInfo priorInfo
    • design

      protected Prior.Design design
      The DESIGN: which alternatives are solved and with what weight. The reference reduces the detected Priors to weighted design points before anything is solved (UQ.buildDesign), and options.method chooses HOW: 'default'/'discrete'/'quadrature' expand a discrete Prior exactly, while 'montecarlo' draws options.samples of them against the prior probabilities and weights each 1/n. This class used to read prior.getAlternative(i) and prior.getProbabilities() directly, so it had one design and options.method selected nothing.
    • aggregatedResult

      protected SolverResult aggregatedResult
  • Constructor Details

    • SolverUQ

      public SolverUQ(Network model, SolverUQ.SolverFactory solverFactory)
      Creates a SolverUQ with the given model and solver factory.
      Parameters:
      model - the network model containing Prior distributions
      solverFactory - function to create solvers for each alternative
    • SolverUQ

      public SolverUQ(Network model, SolverUQ.SolverFactory solverFactory, SolverOptions options)
      Creates a SolverUQ with solver options.
      Parameters:
      model - the network model
      solverFactory - function to create solvers
      options - solver options
  • Method Details

    • defaultOptions

      public static SolverOptions defaultOptions()
      Returns default solver options.
    • detectPrior

      protected SolverUQ.PriorInfo detectPrior()
      Detects Prior distributions in the model. Currently supports only a single Prior per model.
      Returns:
      PriorInfo for the detected Prior, or null if none found
    • hasPriorDistribution

      public boolean hasPriorDistribution()
      Checks if the model has a Prior distribution.
    • getNumAlternatives

      public int getNumAlternatives()
      Returns the number of alternatives in the Prior.
    • listValidMethods

      public String[] listValidMethods()
      Valid methods for this solver, UQ.listValidMethods in MATLAB verbatim. They name the DESIGN, i.e. how the Prior is reduced to weighted design points, and not the inner solver, which is chosen by the SolverFactory this class is constructed with.
      Returns:
      the design methods SolverUQ accepts
    • getUQMethod

      public String getUQMethod()
      Resolve the discretization method from the solver options. 'default' keeps the historical behaviour: a discrete Prior is expanded as given. Mirrors UQ.getUQMethod.
      Returns:
      "quadrature" or "montecarlo"
    • getUQNodes

      public int getUQNodes()
      Number of nodes per Prior, from options.samples (UQ.getUQNodes).
      Returns:
      the design size for the Monte Carlo method
    • buildDesign

      protected void buildDesign()
      Reduce the detected Prior to weighted design points. Each design point assigns one concrete Distribution to the Prior and carries the weight of that assignment. Mirrors UQ.buildDesign; this solver detects a single Prior, so there is no tensor product to take.
    • getNumberOfModels

      public int getNumberOfModels()
      Overrides:
      getNumberOfModels in class EnsembleSolver
    • deepCopyNetwork

      protected Network deepCopyNetwork(Network original)
      Deep copies a Network using serialization.
    • init

      protected void init()
      Specified by:
      init in class EnsembleSolver
    • pre

      protected void pre(int it)
      Specified by:
      pre in class EnsembleSolver
    • analyze

      protected SolverResult analyze(int it, int e)
      Specified by:
      analyze in class EnsembleSolver
    • post

      protected void post(int it)
      Specified by:
      post in class EnsembleSolver
    • finish

      protected void finish()
      Specified by:
      finish in class EnsembleSolver
    • converged

      protected boolean converged(int it)
      Specified by:
      converged in class EnsembleSolver
    • aggregateResults

      protected void aggregateResults()
      Aggregates results from all alternatives using prior weights.
    • getEnsembleAvg

      protected AvgTable getEnsembleAvg()
      Specified by:
      getEnsembleAvg in class EnsembleSolver
    • getAvgTable

      public AvgTable getAvgTable()
      Returns the prior-weighted average results.
      Specified by:
      getAvgTable in class EnsembleSolver
    • getAvgTableImpl

      protected AvgTable getAvgTableImpl()
      Body of getAvgTable(), 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.
    • getInterval

      public SolverUQ.Interval getInterval()
      Range of every metric over the support of the Prior, weights discarded.

      This is the epistemic case in which the modeller can bound a parameter but not distribute it. Two regimes, distinguished by SolverUQ.Interval.exact:

      • exact: the model is a single-class closed product-form network with load-independent single-server queues and delays, so Pfqn_mva_interval returns the exact hull of MVA over the whole demand box by the monotonicity of Luthi and Haring (1998). No ensemble run is needed and the interval is attained, not sampled.
      • not exact: fallback to the range across the alternatives that were solved. The JAR Prior is discrete, so that range is again the whole support; it is reported as inexact only because the monotonicity theorems do not apply to the model.
      The interval is conditional on the true parameters lying inside the Prior support. It is not a bound on the exact solution of the network and must not be composed with SolverBA brackets.
      Returns:
      the interval-valued metrics
    • qualifiesForIntervalMVA

      public String qualifiesForIntervalMVA()
      Whether the monotonicity theorems behind Pfqn_mva_interval hold for this model.
      Returns:
      null when they do, otherwise the first violated condition
    • intervalByMVA

      public SolverUQ.Interval intervalByMVA()
      Exact hull through Pfqn_mva_interval. The demand box is the nominal demand vector with the prior-carrying station widened to the range of mean service times over the Prior support.
    • intervalBySampling

      public SolverUQ.Interval intervalBySampling(String why)
      Range of each metric across the alternatives that were solved.
      Parameters:
      why - the condition that ruled out the exact path, kept on the result
    • getPosteriorTable

      public SolverUQ.PosteriorTable getPosteriorTable()
      Returns a table with per-alternative results and probabilities.
      Returns:
      PosteriorTable with all alternatives
    • getPosteriorDist

      public SolverUQ.EmpiricalCDF getPosteriorDist(String metric, Station station, JobClass jobClass)
      Returns the posterior distribution for a specific metric at a station/class.
      Parameters:
      metric - the metric name ("Q", "U", "R", "T", "A")
      station - the station
      jobClass - the job class
      Returns:
      EmpiricalCDF representing the posterior distribution
    • supports

      public boolean supports(Network model)
      Description copied from class: Solver
      Checks if this solver supports the given network model. Default implementation returns true; subclasses should override to provide specific feature validation.
      Overrides:
      supports in class Solver
      Parameters:
      model - the network model to check
      Returns:
      true if the model is supported, false otherwise
    • runAnalyzer

      public void runAnalyzer()
      Runs the posterior analysis.
      Specified by:
      runAnalyzer in class Solver