Class SolverPosterior
-
- All Implemented Interfaces:
public class SolverPosterior extends EnsembleSolver
Posterior 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); SolverPosterior solver = new SolverPosterior(model, m -> new SolverMVA(m)); AvgTable avgTable = solver.getAvgTable();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceSolverPosterior.SolverFactoryFunctional interface for creating solvers.
public classSolverPosterior.PriorInfoInformation about a detected Prior distribution.
public classSolverPosterior.PosteriorTableRowRow in the posterior table.
public classSolverPosterior.PosteriorTableTable containing per-alternative posterior results.
public classSolverPosterior.EmpiricalCDFEmpirical CDF representing a discrete posterior distribution.
-
Field Summary
Fields Modifier and Type Field Description protected NetworkoriginalModelprotected SolverPosterior.SolverFactorysolverFactoryprotected SolverPosterior.PriorInfopriorInfoprotected SolverResultaggregatedResultprotected Array<Network>ensembleprotected Array<NetworkSolver>solversprotected Map<Integer, Map<Integer, SolverResult>>resultsprotected ExecutorServicethreadPoolprotected intnumThreadspublic Modelmodelpublic Stringnamepublic SolverOptionsoptionspublic SolverResultresultpublic booleanenableCheckspublic Randomrandom
-
Constructor Summary
Constructors Constructor Description SolverPosterior(Network model, SolverPosterior.SolverFactory solverFactory)Creates a SolverPosterior with the given model and solver factory. SolverPosterior(Network model, SolverPosterior.SolverFactory solverFactory, SolverOptions options)Creates a SolverPosterior with solver options.
-
Method Summary
Modifier and Type Method Description static SolverOptionsdefaultOptions()Returns default solver options. SolverPosterior.PriorInfodetectPrior()Detects Prior distributions in the model. booleanhasPriorDistribution()Checks if the model has a Prior distribution. intgetNumAlternatives()Returns the number of alternatives in the Prior. intgetNumberOfModels()NetworkdeepCopyNetwork(Network original)Deep copies a Network using serialization. voidinit()voidpre(int it)SolverResultanalyze(int it, int e)voidpost(int it)voidfinish()booleanconverged(int it)voidaggregateResults()Aggregates results from all alternatives using prior weights. AvgTablegetEnsembleAvg()AvgTablegetAvgTable()Returns the prior-weighted average results. SolverPosterior.PosteriorTablegetPosteriorTable()Returns a table with per-alternative results and probabilities. SolverPosterior.EmpiricalCDFgetPosteriorDist(String metric, Station station, JobClass jobClass)Returns the posterior distribution for a specific metric at a station/class. booleansupports(Network model)Checks if this solver supports the given network model. voidrunAnalyzer()Runs the posterior analysis. -
Methods inherited from class jline.solvers.EnsembleSolver
ensembleAvg, getNumThreads, iterate, numThreads, numberOfModels, printEnsembleAvgTables, printEnsembleAvgTs, setNumThreads -
Methods inherited from class jline.solvers.Solver
getName, getOptions, getResults, hasResults, isJavaAvailable, isValidOption, listValidOptions, parseOptions, parseOptions, reset, resetRandomGeneratorSeed, runAnalyzerChecks, setChecks, setOptions -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
SolverPosterior
SolverPosterior(Network model, SolverPosterior.SolverFactory solverFactory)
Creates a SolverPosterior with the given model and solver factory.- Parameters:
model- the network model containing Prior distributionssolverFactory- function to create solvers for each alternative
-
SolverPosterior
SolverPosterior(Network model, SolverPosterior.SolverFactory solverFactory, SolverOptions options)
Creates a SolverPosterior with solver options.- Parameters:
model- the network modelsolverFactory- function to create solversoptions- solver options
-
-
Method Detail
-
defaultOptions
static SolverOptions defaultOptions()
Returns default solver options.
-
detectPrior
SolverPosterior.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
boolean hasPriorDistribution()
Checks if the model has a Prior distribution.
-
getNumAlternatives
int getNumAlternatives()
Returns the number of alternatives in the Prior.
-
getNumberOfModels
int getNumberOfModels()
-
deepCopyNetwork
Network deepCopyNetwork(Network original)
Deep copies a Network using serialization.
-
init
void init()
-
pre
void pre(int it)
-
analyze
SolverResult analyze(int it, int e)
-
post
void post(int it)
-
finish
void finish()
-
converged
boolean converged(int it)
-
aggregateResults
void aggregateResults()
Aggregates results from all alternatives using prior weights.
-
getEnsembleAvg
AvgTable getEnsembleAvg()
-
getAvgTable
AvgTable getAvgTable()
Returns the prior-weighted average results.
-
getPosteriorTable
SolverPosterior.PosteriorTable getPosteriorTable()
Returns a table with per-alternative results and probabilities.
- Returns:
PosteriorTable with all alternatives
-
getPosteriorDist
SolverPosterior.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 stationjobClass- the job class- Returns:
EmpiricalCDF representing the posterior distribution
-
supports
boolean supports(Network model)
Checks if this solver supports the given network model. Default implementation returns true; subclasses should override to provide specific feature validation.
- Parameters:
model- the network model to check- Returns:
true if the model is supported, false otherwise
-
runAnalyzer
void runAnalyzer()
Runs the posterior analysis.
-
-
-
-