Package jline.solvers.posterior
Class SolverPosterior
java.lang.Object
jline.solvers.Solver
jline.solvers.EnsembleSolver
jline.solvers.posterior.SolverPosterior
- Direct Known Subclasses:
Posterior
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 ClassesModifier and TypeClassDescriptionstatic classEmpirical CDF representing a discrete posterior distribution.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 Networkprotected SolverPosterior.PriorInfoprotected SolverPosterior.SolverFactoryFields inherited from class jline.solvers.EnsembleSolver
ensemble, numThreads, results, solvers, threadPool -
Constructor Summary
ConstructorsConstructorDescriptionSolverPosterior(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 TypeMethodDescriptionprotected voidAggregates results from all alternatives using prior weights.protected SolverResultanalyze(int it, int e) protected booleanconverged(int it) protected NetworkdeepCopyNetwork(Network original) Deep copies a Network using serialization.static SolverOptionsReturns default solver options.protected SolverPosterior.PriorInfoDetects Prior distributions in the model.protected voidfinish()Returns the prior-weighted average results.protected AvgTableintReturns 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.booleanChecks if the model has a Prior distribution.protected voidinit()protected voidpost(int it) protected voidpre(int it) voidRuns the posterior analysis.booleanChecks if this solver supports the given network model.Methods inherited from class jline.solvers.EnsembleSolver
ensembleAvg, getNumThreads, iterate, numberOfModels, numThreads, printEnsembleAvgTables, printEnsembleAvgTs, setNumThreadsMethods inherited from class jline.solvers.Solver
getName, getOptions, getResults, hasResults, isJavaAvailable, isValidOption, listValidOptions, parseOptions, parseOptions, reset, resetRandomGeneratorSeed, runAnalyzerChecks, setChecks, setOptions
-
Field Details
-
originalModel
-
solverFactory
-
priorInfo
-
aggregatedResult
-
-
Constructor Details
-
SolverPosterior
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
public 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 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. -
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. -
getPosteriorTable
Returns a table with per-alternative results and probabilities.- Returns:
- PosteriorTable with all alternatives
-
getPosteriorDist
public 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
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
-