Class SolverPosterior

java.lang.Object
jline.solvers.Solver
jline.solvers.EnsembleSolver
jline.solvers.posterior.SolverPosterior
Direct Known Subclasses:
Posterior

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();
 
  • Field Details

  • Constructor Details

    • SolverPosterior

      public SolverPosterior(Network model, SolverPosterior.SolverFactory solverFactory)
      Creates a SolverPosterior with the given model and solver factory.
      Parameters:
      model - the network model containing Prior distributions
      solverFactory - 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 model
      solverFactory - function to create solvers
      options - solver options
  • Method Details

    • defaultOptions

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

      protected 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

      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:
      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.
    • getPosteriorTable

      public SolverPosterior.PosteriorTable 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 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