![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Classes | |
| struct | PriorSite |
| Where a Prior sits in the model, MATLAB's priorInfo entry. More... | |
| class | SolverUq |
| The ensemble surface of UQ: @UQ's EnsembleSolver implementation. More... | |
| struct | UqDesignPoint |
| One design point: a concrete distribution for every Prior, and its weight. More... | |
| struct | UqEmpiricalCdf |
| The weighted empirical law of a metric, sorted ascending; MATLAB's EmpiricalCDF. More... | |
| struct | UqInterval |
| UQ.getInterval: the RANGE of every metric over the support of the Priors. More... | |
| struct | UqMoments |
| The weighted mean and variance of a metric over the design. More... | |
| struct | UqOptions |
| UQ.defaultOptions plus the stream the Monte Carlo design draws from. More... | |
| struct | UqSolution |
| What solver_uq_run_analyzer returns. More... | |
| struct | UqStageOptions |
| The inner solver's knobs, carried through untranslated. More... | |
Typedefs | |
| template<class T> | |
| using | UqStageSolver = std::function<mva::AvgResult<T>(const qn::NetworkStruct<T>&)> |
| What solves one design point: the C++ spelling of @(m) SolverXXX(m). | |
Functions | |
| std::string | uq_resolve_method (const std::string &m) |
| UQ.getUQMethod: resolve the discretization method. | |
| std::vector< std::string > | uq_list_valid_methods () |
| UQ.listValidMethods. | |
| qn::FeatureSet | uq_feature_set () |
| UQ.getFeatureSet: the one construct UQ adds, and nothing else. | |
| template<class T> | |
| std::vector< PriorSite< T > > | uq_detect_priors (const qn::NetworkStruct< T > &sn) |
| UQ.detectPriors: find every Prior, in node order and then class order. | |
| template<class T> | |
| std::vector< UqDesignPoint< T > > | uq_build_design (const std::vector< PriorSite< T > > &sites, const UqOptions &opt) |
| UQ.buildDesign: reduce the detected Priors to weighted design points. | |
| template<class T> | |
| void | uq_aggregate (UqSolution< T > &sol) |
| UQ.aggregateResults: the prior-weighted expectation of the solved points. | |
| template<class T> | |
| UqSolution< T > | solver_uq_run_analyzer (qn::Network< T > &net, const UqStageSolver< T > &stage, const UqOptions &opt=UqOptions()) |
| UQ.runAnalyzer as a free call: expand, solve every design point, aggregate. | |
| template<class T> | |
| const Matrix< T > & | uq_metric_matrix (const mva::AvgResult< T > &r, const std::string &metric) |
The metric matrix a name selects, MATLAB's res.Avg. | |
| template<class T> | |
| std::vector< T > | uq_samples (const UqSolution< T > &sol, const std::string &metric, std::size_t ist, std::size_t r) |
| UQ.getSamples: the value of one metric at every design point, with weights. | |
| template<class T> | |
| UqMoments< T > | uq_moments (const UqSolution< T > &sol, const std::string &metric, std::size_t ist, std::size_t r) |
| UQ.getMoments: the unconditional mean of Trivedi and Bobbio Eq. | |
| template<class T> | |
| UqEmpiricalCdf< T > | uq_posterior_cdf (const UqSolution< T > &sol, const std::string &metric, std::size_t ist, std::size_t r) |
| UQ.getPosteriorDist: the posterior law of a metric across the design. | |
| template<class T> | |
| std::pair< T, T > | uq_credible_interval (const UqSolution< T > &sol, const std::string &metric, std::size_t ist, std::size_t r, double level=0.95) |
| UQ.getCredibleInterval: the equal-tailed interval of the weighted empirical law at coverage level. | |
| template<class T> | |
| std::pair< T, T > | uq_prior_mean_range (const lang::Distrib< T > &prior, std::size_t n) |
| UQ.priorMeanRange: the range of a Prior's MEAN over its alternatives. | |
| template<class T> | |
| std::pair< bool, std::string > | uq_qualifies_for_interval_mva (const qn::NetworkStruct< T > &sn, const std::vector< PriorSite< T > > &sites) |
| UQ.qualifiesForIntervalMVA: whether the monotonicity theorems behind pfqn_mva_interval hold for this model. | |
| template<class T> | |
| UqInterval< T > | uq_interval_by_mva (const qn::NetworkStruct< T > &sn, const std::vector< PriorSite< T > > &sites, std::size_t nodes) |
| UQ.intervalByMVA: the exact hull through pfqn_mva_interval. | |
| template<class T> | |
| UqInterval< T > | uq_interval_by_sampling (const UqSolution< T > &sol) |
| UQ.intervalBySampling: the range of each metric across the design points that were actually solved. | |
| template<class T> | |
| UqInterval< T > | uq_interval (const UqSolution< T > &sol, const qn::NetworkStruct< T > &sn) |
| UQ.getInterval: the exact hull where the monotonicity theorems apply, the sampled range otherwise. | |
| template<class T> | |
| UqInterval< T > | uq_interval_run (qn::Network< T > &net, const UqStageSolver< T > &stage, const UqOptions &opt=UqOptions()) |
| getInterval from the model, running the ensemble ONLY when it is needed. | |
| std::vector< std::string > | uq_list_stage_solvers () |
| The solver method names uq_stage_solver accepts, for a caller that lists them. | |
| template<class T> | |
| UqStageSolver< T > | uq_stage_solver (const UqStageOptions &o) |
| The stage solver named by o.solver. | |
Variables | |
| constexpr std::size_t | kMaxDesignPoints = 4096 |
| The cap on the tensor-product design, MATLAB UQ.MaxDesignPoints. | |
| using line::uq::UqStageSolver = std::function<mva::AvgResult<T>(const qn::NetworkStruct<T>&)> |
What solves one design point: the C++ spelling of @(m) SolverXXX(m).
It takes the REFRESHED struct of the expanded model and returns the same AvgResult every Network solver in this port returns, so the aggregation below is one loop rather than one loop per solver.
Definition at line 332 of file solver_uq.h.
| UqSolution< T > line::uq::solver_uq_run_analyzer | ( | qn::Network< T > & | net, |
| const UqStageSolver< T > & | stage, | ||
| const UqOptions & | opt = UqOptions() ) |
UQ.runAnalyzer as a free call: expand, solve every design point, aggregate.
The one-shot spelling of SolverUq::iterate, kept because most callers want the solution and not the lifecycle, and because it is what line_cli.cpp and uq_interval_run reach for.
Definition at line 574 of file solver_uq.h.
References line::uq::SolverUq< T >::iterate(), and solver_uq_run_analyzer().
Referenced by solver_uq_run_analyzer(), and uq_interval_run().
| void line::uq::uq_aggregate | ( | UqSolution< T > & | sol | ) |
UQ.aggregateResults: the prior-weighted expectation of the solved points.
Free rather than private to the solver below because it is a pure function of points and weights, and post() is not the only caller that has those: a host that solved the design itself – one point per process, one per machine – aggregates with this and needs nothing else from the class.
Definition at line 367 of file solver_uq.h.
References line::mva::AvgResult< T >::actualmethod, line::mva::AvgResult< T >::AN, line::uq::UqSolution< T >::avg, line::mva::AvgResult< T >::CN, line::uq::UqSolution< T >::points, line::mva::AvgResult< T >::QN, line::mva::AvgResult< T >::RN, line::mva::AvgResult< T >::TN, line::mva::AvgResult< T >::UN, uq_aggregate(), line::uq::UqSolution< T >::weights, line::mva::AvgResult< T >::WN, and line::mva::AvgResult< T >::XN.
Referenced by line::uq::SolverUq< T >::post(), and uq_aggregate().
| std::vector< UqDesignPoint< T > > line::uq::uq_build_design | ( | const std::vector< PriorSite< T > > & | sites, |
| const UqOptions & | opt ) |
UQ.buildDesign: reduce the detected Priors to weighted design points.
With no Prior there is ONE point of weight 1 substituting nothing, so the original model is solved once and the expectation is that solve – the degenerate case the reference also carries, and the reason a model without a Prior is not an error here.
Definition at line 258 of file solver_uq.h.
References line::lang::PriorDesign< T >::dists, line::uq::UqDesignPoint< T >::dists, line::InputError::InputError(), kMaxDesignPoints, line::NumericError::NumericError(), line::lang::prior_discretize(), line::UnsupportedError::UnsupportedError(), uq_build_design(), uq_resolve_method(), and line::uq::UqDesignPoint< T >::weight.
Referenced by line::uq::SolverUq< T >::init(), and uq_build_design().
| std::pair< T, T > line::uq::uq_credible_interval | ( | const UqSolution< T > & | sol, |
| const std::string & | metric, | ||
| std::size_t | ist, | ||
| std::size_t | r, | ||
| double | level = 0.95 ) |
UQ.getCredibleInterval: the equal-tailed interval of the weighted empirical law at coverage level.
The endpoints are DESIGN-POINT VALUES, not interpolations between them: the design is a finite set of models and the interval names two of them, which is what the reference's find(cw >= alpha, 1) returns. On a coarse design the interval is therefore conservative rather than smooth.
Definition at line 682 of file solver_uq.h.
References line::uq::UqEmpiricalCdf< T >::cdf, line::InputError::InputError(), line::uq::UqEmpiricalCdf< T >::probabilities, uq_credible_interval(), uq_posterior_cdf(), and line::uq::UqEmpiricalCdf< T >::values.
Referenced by uq_credible_interval().
| std::vector< PriorSite< T > > line::uq::uq_detect_priors | ( | const qn::NetworkStruct< T > & | sn | ) |
UQ.detectPriors: find every Prior, in node order and then class order.
SERVICE AT A QUEUE OR DELAY, ARRIVAL AT A SOURCE, which is the reference's own pair of branches. A Prior anywhere else – a Cache's read process, a Transition's firing law – is REFUSED by name rather than skipped: the reference's loop would ignore it and then solve a model in which the uncertainty silently became the mixture moments, which is a confident answer to a question nobody asked.
Definition at line 196 of file solver_uq.h.
References line::uq::PriorSite< T >::arrival, line::uq::PriorSite< T >::cls, line::lang::Distrib< T >::is_prior(), line::uq::PriorSite< T >::node, line::uq::PriorSite< T >::prior, line::uq::PriorSite< T >::station, line::UnsupportedError::UnsupportedError(), and uq_detect_priors().
Referenced by line::uq::SolverUq< T >::init(), uq_detect_priors(), and uq_interval_run().
|
inline |
UQ.getFeatureSet: the one construct UQ adds, and nothing else.
IT IS NOT USED AS A FEATURE GATE, here or in the reference: UQ solves nothing itself, so the set of models it admits is the inner solver's, applied per design point once the Prior is gone. It is declared because the registry is the vocabulary in which a capability is stated, and "SolverUQ is the solver that understands Prior" is a statement worth being able to make.
THE ONE THING UQ.supports DOES DECIDE is whether the model carries a Prior at all: a model with no uncertain parameter is not a UQ model, and its posterior is a single design point equal to the point estimate the inner solver already returns. has_prior_distribution() is that test here. MATLAB used to return true unconditionally – which made SolverAUTO offer every 'uq.*' method name on an ordinary network – and now gates on UQ.modelHasPrior, matching the JAR (detectPrior() != null) and native python (hasPriorDistribution).
Definition at line 179 of file solver_uq.h.
References line::qn::FeatureSet::set(), and uq_feature_set().
Referenced by uq_feature_set().
| UqInterval< T > line::uq::uq_interval | ( | const UqSolution< T > & | sol, |
| const qn::NetworkStruct< T > & | sn ) |
UQ.getInterval: the exact hull where the monotonicity theorems apply, the sampled range otherwise.
THE TWO PATHS DO NOT MEAN THE SAME THING and the caller must read exact before quoting the numbers. The MVA path returns the ATTAINED range over the whole (continuous) demand box; the sampled path returns the range over the points that happened to be solved, which for a continuous Prior lies strictly inside the true range. why carries the condition that forced the fallback, which is the reference's line_warning text made into a returned value – this port has no warning channel, and a range that is not an enclosure must not be silently indistinguishable from one that is.
Definition at line 955 of file solver_uq.h.
References line::uq::UqSolution< T >::options, line::uq::UqOptions::samples, line::uq::UqSolution< T >::sites, uq_interval(), uq_interval_by_mva(), uq_interval_by_sampling(), uq_qualifies_for_interval_mva(), and line::uq::UqInterval< T >::why.
Referenced by uq_interval().
| UqInterval< T > line::uq::uq_interval_by_mva | ( | const qn::NetworkStruct< T > & | sn, |
| const std::vector< PriorSite< T > > & | sites, | ||
| std::size_t | nodes ) |
UQ.intervalByMVA: the exact hull through pfqn_mva_interval.
The demand box is the nominal demand vector with the prior-carrying stations widened to the range of mean service times over the Prior support. NO ENSEMBLE RUN HAPPENS: 2*(m+2) MVA calls replace the whole tensor design, and the answer is the attained range rather than the range of what was sampled.
Definition at line 805 of file solver_uq.h.
References line::uq::UqInterval< T >::exact, line::uq::UqInterval< T >::has_totals, line::lang::INF, line::Matrix< T >::Matrix(), line::uq::UqInterval< T >::method, line::NumericError::NumericError(), line::pfqn::pfqn_mva_interval(), line::pfqn::MvaIntervalResult< T >::Q, line::uq::UqInterval< T >::Qlo, line::uq::UqInterval< T >::Qup, line::pfqn::MvaIntervalResult< T >::R, line::uq::UqInterval< T >::Rlo, line::pfqn::MvaIntervalResult< T >::Rtot_lo, line::uq::UqInterval< T >::Rtot_lo, line::pfqn::MvaIntervalResult< T >::Rtot_up, line::uq::UqInterval< T >::Rtot_up, line::uq::UqInterval< T >::Rup, line::uq::UqInterval< T >::Tlo, line::uq::UqInterval< T >::Tup, line::pfqn::MvaIntervalResult< T >::U, line::uq::UqInterval< T >::Ulo, line::UnsupportedError::UnsupportedError(), uq_interval_by_mva(), uq_prior_mean_range(), line::uq::UqInterval< T >::Uup, line::uq::UqInterval< T >::Wlo, line::uq::UqInterval< T >::Wup, line::pfqn::MvaIntervalResult< T >::Xlo, line::uq::UqInterval< T >::Xlo, line::pfqn::MvaIntervalResult< T >::Xup, and line::uq::UqInterval< T >::Xup.
Referenced by uq_interval(), uq_interval_by_mva(), and uq_interval_run().
| UqInterval< T > line::uq::uq_interval_by_sampling | ( | const UqSolution< T > & | sol | ) |
UQ.intervalBySampling: the range of each metric across the design points that were actually solved.
EXACT FOR A DISCRETE PRIOR, whose design visits the whole support, and an INNER approximation for a continuous one, since a quadrature node is a stratum median and never an endpoint. It is therefore not an enclosure, and exact is false to say so.
Definition at line 912 of file solver_uq.h.
References line::Matrix< T >::cols(), line::Matrix< T >::empty(), line::uq::UqInterval< T >::exact, line::uq::UqInterval< T >::method, line::uq::UqSolution< T >::points, line::uq::UqInterval< T >::Qlo, line::mva::AvgResult< T >::QN, line::uq::UqInterval< T >::Qup, line::uq::UqInterval< T >::Rlo, line::mva::AvgResult< T >::RN, line::Matrix< T >::rows(), line::uq::UqInterval< T >::Rup, line::uq::UqInterval< T >::Tlo, line::mva::AvgResult< T >::TN, line::uq::UqInterval< T >::Tup, line::uq::UqInterval< T >::Ulo, line::mva::AvgResult< T >::UN, uq_interval_by_sampling(), line::uq::UqInterval< T >::Uup, line::uq::UqInterval< T >::Wlo, line::mva::AvgResult< T >::WN, and line::uq::UqInterval< T >::Wup.
Referenced by uq_interval(), uq_interval_by_sampling(), and uq_interval_run().
| UqInterval< T > line::uq::uq_interval_run | ( | qn::Network< T > & | net, |
| const UqStageSolver< T > & | stage, | ||
| const UqOptions & | opt = UqOptions() ) |
getInterval from the model, running the ensemble ONLY when it is needed.
The exact path costs 2*(m+2) MVA calls and reads no design point, so a caller who wants the range and not the expectation should not pay for the tensor design: UQ.getInterval calls intervalByMVA without touching self.results and only the sampling fallback calls iterate. The stage solver is therefore never invoked on a qualifying model, which also means a model whose stage solver would refuse it still has a computable interval.
Definition at line 974 of file solver_uq.h.
References line::qn::Network< T >::get_struct(), solver_uq_run_analyzer(), uq_detect_priors(), uq_interval_by_mva(), uq_interval_by_sampling(), uq_interval_run(), uq_qualifies_for_interval_mva(), and line::uq::UqInterval< T >::why.
Referenced by uq_interval_run().
|
inline |
The solver method names uq_stage_solver accepts, for a caller that lists them.
Definition at line 79 of file uq_dispatch.h.
References uq_list_stage_solvers().
Referenced by uq_list_stage_solvers().
|
inline |
UQ.listValidMethods.
Definition at line 157 of file solver_uq.h.
References uq_list_valid_methods().
Referenced by uq_list_valid_methods().
| const Matrix< T > & line::uq::uq_metric_matrix | ( | const mva::AvgResult< T > & | r, |
| const std::string & | metric ) |
The metric matrix a name selects, MATLAB's res.Avg.
(metric) field.
Definition at line 586 of file solver_uq.h.
References line::mva::AvgResult< T >::AN, line::InputError::InputError(), line::mva::AvgResult< T >::QN, line::mva::AvgResult< T >::RN, line::mva::AvgResult< T >::TN, line::mva::AvgResult< T >::UN, uq_metric_matrix(), and line::mva::AvgResult< T >::WN.
Referenced by uq_metric_matrix(), and uq_samples().
| UqMoments< T > line::uq::uq_moments | ( | const UqSolution< T > & | sol, |
| const std::string & | metric, | ||
| std::size_t | ist, | ||
| std::size_t | r ) |
UQ.getMoments: the unconditional mean of Trivedi and Bobbio Eq.
(3.68) and the second moment of the same weighting.
Both are EXACT for a discrete Prior and quadrature- or sample-approximate for a continuous one, which is the only sense in which a variance over 11 stratum medians is a variance.
Definition at line 632 of file solver_uq.h.
References line::uq::UqMoments< T >::mean, uq_moments(), uq_samples(), line::uq::UqMoments< T >::var, and line::uq::UqSolution< T >::weights.
Referenced by uq_moments().
| UqEmpiricalCdf< T > line::uq::uq_posterior_cdf | ( | const UqSolution< T > & | sol, |
| const std::string & | metric, | ||
| std::size_t | ist, | ||
| std::size_t | r ) |
UQ.getPosteriorDist: the posterior law of a metric across the design.
Definition at line 654 of file solver_uq.h.
References line::uq::UqEmpiricalCdf< T >::cdf, line::uq::UqEmpiricalCdf< T >::probabilities, uq_posterior_cdf(), uq_samples(), line::uq::UqEmpiricalCdf< T >::values, and line::uq::UqSolution< T >::weights.
Referenced by uq_credible_interval(), and uq_posterior_cdf().
| std::pair< T, T > line::uq::uq_prior_mean_range | ( | const lang::Distrib< T > & | prior, |
| std::size_t | n ) |
UQ.priorMeanRange: the range of a Prior's MEAN over its alternatives.
Exact for a discrete Prior, whose alternatives ARE the support. A continuous Prior is discretized first, so the range is that of the discretized support: an unbounded parameter density is never reached at its tails, which is exactly why the interval built from it is an inner approximation.
Definition at line 750 of file solver_uq.h.
References line::lang::PriorDesign< T >::dists, line::lang::Distrib< T >::mean, line::NumericError::NumericError(), line::lang::prior_discretize(), and uq_prior_mean_range().
Referenced by uq_interval_by_mva(), and uq_prior_mean_range().
| std::pair< bool, std::string > line::uq::uq_qualifies_for_interval_mva | ( | const qn::NetworkStruct< T > & | sn, |
| const std::vector< PriorSite< T > > & | sites ) |
UQ.qualifiesForIntervalMVA: whether the monotonicity theorems behind pfqn_mva_interval hold for this model.
The returned string NAMES the first violated condition rather than reporting a bare false, because "this model does not qualify" leaves the modeller guessing which of six conditions to change.
Definition at line 771 of file solver_uq.h.
References line::lang::FCFS, line::lang::INF, line::lang::PS, and uq_qualifies_for_interval_mva().
Referenced by uq_interval(), uq_interval_run(), and uq_qualifies_for_interval_mva().
|
inline |
UQ.getUQMethod: resolve the discretization method.
default and discrete are aliases of quadrature and not separate rules: a discrete Prior is already exact, so expanding it as given IS the quadrature design for it, and the name survives only because the reference lists it.
Definition at line 149 of file solver_uq.h.
References line::InputError::InputError(), and uq_resolve_method().
Referenced by line::uq::SolverUq< T >::init(), uq_build_design(), and uq_resolve_method().
| std::vector< T > line::uq::uq_samples | ( | const UqSolution< T > & | sol, |
| const std::string & | metric, | ||
| std::size_t | ist, | ||
| std::size_t | r ) |
UQ.getSamples: the value of one metric at every design point, with weights.
ist and r are 1-based, as everywhere in the readable surface of this port.
Definition at line 602 of file solver_uq.h.
References line::Matrix< T >::cols(), line::Matrix< T >::empty(), line::InputError::InputError(), line::uq::UqSolution< T >::points, line::Matrix< T >::rows(), uq_metric_matrix(), and uq_samples().
Referenced by uq_moments(), uq_posterior_cdf(), and uq_samples().
| UqStageSolver< T > line::uq::uq_stage_solver | ( | const UqStageOptions & | o | ) |
The stage solver named by o.solver.
An unknown or unported name is refused BY NAME rather than answered with a default engine: which solver ran is a property of every number UQ reports.
Definition at line 125 of file uq_dispatch.h.
References line::uq::UqStageOptions::cutoff, line::InputError::InputError(), line::uq::UqStageOptions::iter_max, line::uq::UqStageOptions::iter_tol, line::uq::UqStageOptions::method, line::uq::UqStageOptions::samples, line::uq::UqStageOptions::seed, line::uq::UqStageOptions::solver, line::ba::solver_ba_run_analyzer(), line::ctmc::solver_ctmc_run_analyzer_any(), line::fluid::solver_fluid_run_analyzer(), line::mam::solver_mam_run_analyzer(), line::mva::solver_mva_run_analyzer(), line::nc::solver_nc_run_analyzer(), line::ssa::solver_ssa(), line::uq::UqStageOptions::tol, line::UnsupportedError::UnsupportedError(), and uq_stage_solver().
Referenced by uq_stage_solver().
|
inlineconstexpr |
The cap on the tensor-product design, MATLAB UQ.MaxDesignPoints.
A design point is one full solver run, so this bounds the cost of a quadrature design over several Priors.
Definition at line 82 of file solver_uq.h.
Referenced by uq_build_design().