Package jline.solvers.uq
Class SolverUQ
java.lang.Object
jline.solvers.Solver
jline.solvers.EnsembleSolver
jline.solvers.uq.SolverUQ
- Direct Known Subclasses:
UQ
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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEmpirical CDF representing a discrete posterior distribution.static classInterval-valued metrics returned bygetInterval().static classTable containing per-alternative posterior results.static classRow in the posterior table.static classInformation about a detected Prior distribution.static interfaceFunctional interface for creating solvers. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SolverResultprotected Prior.DesignThe DESIGN: which alternatives are solved and with what weight.protected Networkprotected SolverUQ.PriorInfoprotected SolverUQ.SolverFactoryFields inherited from class jline.solvers.EnsembleSolver
ensemble, numThreads, results, solvers, threadPool -
Constructor Summary
ConstructorsConstructorDescriptionSolverUQ(Network model, SolverUQ.SolverFactory solverFactory) Creates a SolverUQ with the given model and solver factory.SolverUQ(Network model, SolverUQ.SolverFactory solverFactory, SolverOptions options) Creates a SolverUQ with solver options. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAggregates results from all alternatives using prior weights.protected SolverResultanalyze(int it, int e) protected voidReduce the detected Prior to weighted design points.protected booleanconverged(int it) protected NetworkdeepCopyNetwork(Network original) Deep copies a Network using serialization.static SolverOptionsReturns default solver options.protected SolverUQ.PriorInfoDetects Prior distributions in the model.protected voidfinish()Returns the prior-weighted average results.protected AvgTableBody ofgetAvgTable(), split out soLineResultRecordersees what the getter RETURNED.protected AvgTableRange of every metric over the support of the Prior, weights discarded.intReturns the number of alternatives in the Prior.intgetPosteriorDist(String metric, Station station, JobClass jobClass) Returns the posterior distribution for a specific metric at a station/class.Returns a table with per-alternative results and probabilities.Resolve the discretization method from the solver options.intNumber of nodes per Prior, from options.samples (UQ.getUQNodes).booleanChecks if the model has a Prior distribution.protected voidinit()Exact hull throughPfqn_mva_interval.intervalBySampling(String why) Range of each metric across the alternatives that were solved.String[]Valid methods for this solver, UQ.listValidMethods in MATLAB verbatim.protected voidpost(int it) protected voidpre(int it) Whether the monotonicity theorems behindPfqn_mva_intervalhold for this model.voidRuns the posterior analysis.booleanChecks if this solver supports the given network model.Methods inherited from class jline.solvers.EnsembleSolver
aT, avgT, ensembleAvg, getAvgT, getNumThreads, getSolver, getStageResult, isStochastic, iterate, numberOfModels, numThreads, printEnsembleAvgTables, printEnsembleAvgTs, setNumThreadsMethods inherited from class jline.solvers.Solver
getMethodFeatureSet, getName, getOptions, getResults, hasResults, isJavaAvailable, isStochasticMethod, isValidOption, listValidOptions, parseOptions, parseOptions, reset, resetRandomGeneratorSeed, resolveMethod, runAnalyzerChecks, selectMethod, setChecks, setOptions, supportsModelMethod, supportsTransientAnalysis, timeExceeded
-
Field Details
-
originalModel
-
solverFactory
-
priorInfo
-
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
-
-
Constructor Details
-
SolverUQ
Creates a SolverUQ with the given model and solver factory.- Parameters:
model- the network model containing Prior distributionssolverFactory- function to create solvers for each alternative
-
SolverUQ
Creates a SolverUQ with solver options.- Parameters:
model- the network modelsolverFactory- function to create solversoptions- solver options
-
-
Method Details
-
defaultOptions
Returns default solver options. -
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
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
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:
getNumberOfModelsin classEnsembleSolver
-
deepCopyNetwork
Deep copies a Network using serialization. -
init
protected void init()- Specified by:
initin classEnsembleSolver
-
pre
protected void pre(int it) - Specified by:
prein classEnsembleSolver
-
analyze
- Specified by:
analyzein classEnsembleSolver
-
post
protected void post(int it) - Specified by:
postin classEnsembleSolver
-
finish
protected void finish()- Specified by:
finishin classEnsembleSolver
-
converged
protected boolean converged(int it) - Specified by:
convergedin classEnsembleSolver
-
aggregateResults
protected void aggregateResults()Aggregates results from all alternatives using prior weights. -
getEnsembleAvg
- Specified by:
getEnsembleAvgin classEnsembleSolver
-
getAvgTable
Returns the prior-weighted average results.- Specified by:
getAvgTablein classEnsembleSolver
-
getAvgTableImpl
Body ofgetAvgTable(), split out soLineResultRecordersees what the getter RETURNED. The JAVA cross-codebase parity row is measured from that rather than from what an example printed. -
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_intervalreturns 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.
- Returns:
- the interval-valued metrics
- exact: the model is a single-class closed product-form network with
load-independent single-server queues and delays, so
-
qualifiesForIntervalMVA
Whether the monotonicity theorems behindPfqn_mva_intervalhold for this model.- Returns:
- null when they do, otherwise the first violated condition
-
intervalByMVA
Exact hull throughPfqn_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
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
Returns a table with per-alternative results and probabilities.- Returns:
- PosteriorTable with all alternatives
-
getPosteriorDist
Returns the posterior distribution for a specific metric at a station/class.- Parameters:
metric- the metric name ("Q", "U", "R", "T", "A")station- the stationjobClass- the job class- Returns:
- EmpiricalCDF representing the posterior distribution
-
supports
Description copied from class:SolverChecks if this solver supports the given network model. Default implementation returns true; subclasses should override to provide specific feature validation. -
runAnalyzer
public void runAnalyzer()Runs the posterior analysis.- Specified by:
runAnalyzerin classSolver
-