LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::fluid::petri Namespace Reference

Classes

struct  MinMulti
 The result of the many-argument closure. More...
struct  PetriConservation
 The conserved quantities of a net, as equations. More...
struct  PetriConstraints
 Every finite place capacity as a linear row A x <= b. More...
struct  PetriImmediate
 The active set of the immediate modes and the equations pinning their flows. More...
struct  PetriMode
 One firing mode of one transition, with its arcs and its firing process. More...
struct  PetriOptions
 Tuning of the outer solve. More...
struct  PetriReport
 What the Petri route computes that the station table has no column for. More...
struct  PetriSolution
 Everything solver_fluid_petri returns. More...
struct  PetriTerms
 The assembled drift terms of a net. More...
struct  PetriTheta
 The closed enabling term of every mode and its derivative. More...
struct  PetriVerdict
 Whether the fluid Petri route can answer this model, and why not. More...

Functions

PetriConservation petri_conservation (const PetriTerms &t)
 The conserved quantities, as equations: u'D = 0 implies u'x is constant.
template<class T>
PetriConstraints petri_constraints (const qn::NetworkStruct< T > &sn, const PetriTerms &t)
 THE GATE IS A LOSS ON THE DEPOSIT: LINE loses the tokens a firing would push past a place's capacity, so the fluid analogue scales the DEPOSIT leg of every event adding mass to the capped place and leaves the removal leg alone.
void petri_immediate (const PetriTerms &t, const std::vector< double > &x, PetriImmediate &imm)
 An immediate transition has no rate: its fluid limit is a FLOW, an algebraic unknown pinned by the constraint that its binding input place holds no mass,.
template<class T>
PetriVerdict petri_applicable (const qn::NetworkStruct< T > &sn)
 A QUEUEING STATION IS THE ONE STRUCTURAL EXCLUSION: a net whose tokens also visit a Queue or a Delay is two formalisms at once, and LINE has no reference semantics for the hand-off.
template<class T>
PetriSolution solver_fluid_petri (const qn::NetworkStruct< T > &sn, const PetriOptions &opt=PetriOptions())
 Fluid analysis of a stochastic Petri net.
double norm_cdf (double z)
 The standard normal CDF, without a statistics dependency.
double norm_pdf (double z)
 The standard normal density.
std::pair< double, double > min_closure (double n, double c, double s2, double vc, double cov)
 E[min(X,Y)] and dE/dE[X] for jointly normal X, Y.
MinMulti minmulti_closure (const std::vector< double > &mu, const Matrix< double > &S, double c)
 Min-normal closure of E[min(X_1,...,X_A,c)] by Clark's (1961) recursion.
PetriTheta petri_theta (const PetriTerms &t, const std::vector< double > &x, const std::vector< double > &s2_in)
 The closed enabling term of every mode, and its derivative.
std::vector< double > petri_rates (const PetriTerms &t, const std::vector< double > &x, const std::vector< double > &phi, const std::vector< double > &mu, const PetriTheta &th)
 The rate of every event column.
Matrix< double > petri_jacobian (const PetriTerms &t, const PetriTheta &th)
 Drift Jacobian A = D * dR/dX.
double petri_fine_tol ()
 GlobalConstants.FineTol, the reference's own "effectively zero".
template<class T>
PetriTerms petri_build_terms (const qn::NetworkStruct< T > &sn)
 Assemble the drift terms of a net.

Function Documentation

◆ min_closure()

std::pair< double, double > line::fluid::petri::min_closure ( double n,
double c,
double s2,
double vc,
double cov )
inline

E[min(X,Y)] and dE/dE[X] for jointly normal X, Y.

Returns
the pair (expectation, derivative with respect to E[X])

Definition at line 48 of file fluid_petri_system.h.

References min_closure(), norm_cdf(), norm_pdf(), and petri_fine_tol().

Referenced by min_closure(), and minmulti_closure().

◆ minmulti_closure()

MinMulti line::fluid::petri::minmulti_closure ( const std::vector< double > & mu,
const Matrix< double > & S,
double c )
inline

Min-normal closure of E[min(X_1,...,X_A,c)] by Clark's (1961) recursion.

The recursion is ORDER DEPENDENT, as Clark's approximation always is: only the first two moments of the running min are kept. The order is the caller's, i.e. increasing state coordinate, which the layout fixes.

Parameters
mumeans of the arguments, already scaled by the arc weights
Scovariance of the arguments, symmetric positive semi-definite
cdeterministic cap (the mode's server count); infinite for none

Definition at line 86 of file fluid_petri_system.h.

References line::Matrix< T >::cols(), line::fluid::petri::MinMulti::g, line::fluid::petri::MinMulti::h, min_closure(), minmulti_closure(), norm_cdf(), norm_pdf(), petri_fine_tol(), line::Matrix< T >::rows(), and line::fluid::petri::MinMulti::v.

Referenced by minmulti_closure(), and petri_theta().

◆ norm_cdf()

double line::fluid::petri::norm_cdf ( double z)
inline

The standard normal CDF, without a statistics dependency.

Definition at line 36 of file fluid_petri_system.h.

References norm_cdf().

Referenced by min_closure(), minmulti_closure(), norm_cdf(), and petri_theta().

◆ norm_pdf()

double line::fluid::petri::norm_pdf ( double z)
inline

The standard normal density.

Definition at line 39 of file fluid_petri_system.h.

References norm_pdf().

Referenced by min_closure(), minmulti_closure(), norm_pdf(), and petri_theta().

◆ petri_applicable()

template<class T>
PetriVerdict line::fluid::petri::petri_applicable ( const qn::NetworkStruct< T > & sn)
inline

A QUEUEING STATION IS THE ONE STRUCTURAL EXCLUSION: a net whose tokens also visit a Queue or a Delay is two formalisms at once, and LINE has no reference semantics for the hand-off.

Definition at line 459 of file fluid_petri.h.

References line::lang::node_type_to_text(), line::fluid::petri::PetriVerdict::ok, petri_applicable(), line::lang::Place, line::fluid::petri::PetriVerdict::reason, line::lang::Sink, line::lang::Source, and line::lang::Transition.

Referenced by petri_applicable(), and solver_fluid_petri().

◆ petri_build_terms()

template<class T>
PetriTerms line::fluid::petri::petri_build_terms ( const qn::NetworkStruct< T > & sn)
inline

Assemble the drift terms of a net.

Parameters
sna model whose nodes are Places, Transitions, Sources and Sinks only

Definition at line 325 of file fluid_petri_terms.h.

References line::fluid::petri::PetriMode::arc_slot, line::fluid::petri::PetriMode::arc_w, line::fluid::petri::PetriMode::c, line::fluid::petri::PetriMode::closable, line::fluid::petri::PetriTerms::consumer_w, line::fluid::petri::PetriTerms::consumers, line::fluid::petri::PetriTerms::coord_class, line::fluid::petri::PetriTerms::coord_node, line::fluid::petri::PetriTerms::coord_station, line::fluid::petri::PetriTerms::cov_idx, line::fluid::petri::PetriTerms::cov_pairs, line::fluid::petri::PetriMode::cvec, line::fluid::petri::PetriTerms::D, line::fluid::petri::PetriMode::D0, line::fluid::petri::PetriMode::D1, line::fluid::petri::PetriMode::d1, line::qn::TransitionParam< T >::enabling, line::fluid::petri::PetriTerms::ev_class, line::fluid::petri::PetriTerms::ev_kind, line::fluid::petri::PetriTerms::ev_mode, line::fluid::petri::PetriTerms::ev_phase, line::fluid::petri::PetriTerms::ev_station, line::fluid::petri::PetriTerms::ev_to, line::lang::EXP, line::qn::TransitionParam< T >::firing, line::fluid::petri::PetriTerms::I, line::fluid::petri::PetriTerms::imm_col, line::fluid::petri::PetriTerms::imm_idx, line::fluid::petri::PetriMode::inh_slot, line::qn::TransitionParam< T >::inhibiting, line::InputError::InputError(), line::fluid::petri::PetriTerms::K, line::fluid::petri::PetriTerms::latch_col, line::fluid::petri::PetriTerms::latch_mode, line::fluid::petri::PetriTerms::M, line::fluid::petri::PetriTerms::m0full, line::fluid::petri::PetriTerms::modes, line::fluid::petri::PetriTerms::names_node, line::fluid::petri::PetriTerms::nev, line::fluid::petri::PetriTerms::nm, line::qn::TransitionParam< T >::nmodes, line::fluid::petri::PetriTerms::npair, line::fluid::petri::PetriMode::nph, line::fluid::petri::PetriTerms::nstate, line::fluid::petri::PetriTerms::pair_index, petri_build_terms(), line::fluid::petri::PetriTerms::pidx, line::fluid::petri::PetriMode::pie, line::lang::Place, line::fluid::petri::PetriTerms::places, line::fluid::petri::PetriTerms::producers, line::fluid::petri::PetriTerms::rate_base, line::lang::Source, line::fluid::petri::PetriTerms::stoch_col, line::lang::TIMED, line::fluid::petri::PetriTerms::timed_idx, line::fluid::petri::PetriMode::timing, line::lang::Transition, line::fluid::petri::PetriTerms::transitions, line::UnsupportedError::UnsupportedError(), line::fluid::petri::PetriTerms::x0, and line::fluid::petri::PetriMode::zblk.

Referenced by petri_build_terms(), and solver_fluid_petri().

◆ petri_conservation()

PetriConservation line::fluid::petri::petri_conservation ( const PetriTerms & t)
inline

The conserved quantities, as equations: u'D = 0 implies u'x is constant.

On the marking coordinates those u are the net's P-invariants; on a mode's phase block the all-ones vector is one of them, which is the statement that the phase coordinates are a distribution. Both come out of the SAME null space, so the phase normalisation needs no separate row.

AN OPEN NET LOSES THE ROWS ITS ARRIVALS BREAK, automatically: the arrival columns are part of D, so a u an arrival moves is not in the null space.

Definition at line 166 of file fluid_petri.h.

References line::fluid::petri::PetriConservation::C, line::Matrix< T >::cols(), line::fluid::petri::PetriTerms::D, line::fluid::petri::PetriConservation::label, line::fluid::petri::PetriConservation::leak, line::fluid::petri::PetriConservation::N, line::fluid::petri::PetriTerms::nev, line::fluid::petri::PetriTerms::nstate, petri_conservation(), line::Matrix< T >::rows(), and line::fluid::petri::PetriTerms::x0.

Referenced by petri_conservation(), and solver_fluid_petri().

◆ petri_constraints()

template<class T>
PetriConstraints line::fluid::petri::petri_constraints ( const qn::NetworkStruct< T > & sn,
const PetriTerms & t )
inline

THE GATE IS A LOSS ON THE DEPOSIT: LINE loses the tokens a firing would push past a place's capacity, so the fluid analogue scales the DEPOSIT leg of every event adding mass to the capped place and leaves the removal leg alone.

The rows here name which coordinates are capped; the scaling lives in the tangent clamp.

Definition at line 233 of file fluid_petri.h.

References line::fluid::petri::PetriConstraints::A, line::fluid::petri::PetriConstraints::b, line::fluid::petri::PetriConstraints::cover, line::fluid::petri::PetriTerms::K, line::fluid::petri::PetriConstraints::label, line::fluid::petri::PetriTerms::names_node, line::fluid::petri::PetriTerms::nstate, petri_constraints(), line::fluid::petri::PetriTerms::pidx, and line::fluid::petri::PetriTerms::places.

Referenced by petri_constraints(), and solver_fluid_petri().

◆ petri_fine_tol()

double line::fluid::petri::petri_fine_tol ( )
inline

GlobalConstants.FineTol, the reference's own "effectively zero".

Definition at line 71 of file fluid_petri_terms.h.

References petri_fine_tol().

Referenced by min_closure(), minmulti_closure(), petri_fine_tol(), petri_theta(), and solver_fluid_petri().

◆ petri_immediate()

void line::fluid::petri::petri_immediate ( const PetriTerms & t,
const std::vector< double > & x,
PetriImmediate & imm )
inline

An immediate transition has no rate: its fluid limit is a FLOW, an algebraic unknown pinned by the constraint that its binding input place holds no mass,.

phi_j >= 0,   x_b = 0 for the coordinate b that binds mode j

with the GSPN conflict rule supplying the extra equation when two modes drain one place: phi_j*weight_l = phi_l*weight_j among the enabled modes of highest firing priority, and phi = 0 below it.

THE COUNT IS SQUARE BY CONSTRUCTION: V pins plus (F-V) ratio rows is F equations for F flows.

Definition at line 351 of file fluid_petri.h.

References line::fluid::petri::PetriImmediate::Row::a, line::fluid::petri::PetriImmediate::active, line::fluid::petri::PetriMode::arc_slot, line::fluid::petri::PetriMode::arc_w, line::fluid::petri::PetriImmediate::Row::b, line::fluid::petri::PetriImmediate::bind, line::fluid::petri::PetriTerms::imm_idx, line::fluid::petri::PetriImmediate::initialized, line::InputError::InputError(), line::fluid::petri::PetriImmediate::Row::kind, line::fluid::petri::PetriMode::label, line::fluid::petri::PetriTerms::modes, line::fluid::petri::PetriImmediate::n, petri_immediate(), line::fluid::petri::PetriImmediate::PIN, line::fluid::petri::PetriImmediate::pins, line::fluid::petri::PetriImmediate::RATIO, line::fluid::petri::PetriImmediate::rows, line::fluid::petri::PetriImmediate::Row::wa, line::fluid::petri::PetriImmediate::Row::wb, and line::fluid::petri::PetriImmediate::ZERO.

Referenced by petri_immediate(), and solver_fluid_petri().

◆ petri_jacobian()

Matrix< double > line::fluid::petri::petri_jacobian ( const PetriTerms & t,
const PetriTheta & th )
inline

◆ petri_rates()

std::vector< double > line::fluid::petri::petri_rates ( const PetriTerms & t,
const std::vector< double > & x,
const std::vector< double > & phi,
const std::vector< double > & mu,
const PetriTheta & th )
inline

The rate of every event column.

kind 1 firing of mode j single phase: rateBase*theta*dep multi phase: rateBase*y(j,h) kind 2 internal phase change rateBase*y(j,h) kind 3 exogenous arrival a constant kind 4 firing of an IMMEDIATE mode phi_j, an algebraic unknown kind 5 the server latch mu_j, a free-sign unknown

Definition at line 310 of file fluid_petri_system.h.

References line::fluid::petri::PetriTheta::dep, line::fluid::petri::PetriTerms::ev_kind, line::fluid::petri::PetriTerms::ev_mode, line::fluid::petri::PetriTerms::ev_phase, line::fluid::petri::PetriTerms::imm_idx, line::fluid::petri::PetriTerms::latch_mode, line::fluid::petri::PetriTerms::modes, line::fluid::petri::PetriTerms::nev, line::fluid::petri::PetriMode::nph, petri_rates(), line::fluid::petri::PetriTerms::rate_base, line::fluid::petri::PetriTheta::theta, and line::fluid::petri::PetriMode::zblk.

Referenced by petri_rates().

◆ petri_theta()

PetriTheta line::fluid::petri::petri_theta ( const PetriTerms & t,
const std::vector< double > & x,
const std::vector< double > & s2_in )
inline

The closed enabling term of every mode, and its derivative.

theta_j = ( prod_b Phi((thr_b - m_b)/sd_b) ) * E[ min_a(m_a/w_a), c_j ]

Both factors collapse to their first-order form at zero variance – Phi becomes the hard indicator and the min closure becomes min() – so the mean-field limit is one code path, not two.

THE INHIBITOR GATE IS WHY A PETRI NET NEEDS A SMOOTHED CLOSURE AT ALL, quite apart from accuracy: the indicator is a step, and a Newton solver has no derivative to descend on a step.

THE VARIANCES ARE UNKNOWNS, NOT FUNCTIONS OF X: s2 is pinned by its own consistency row in the DAE, so the derivative is with respect to the MEANS only.

Definition at line 226 of file fluid_petri_system.h.

References line::fluid::petri::PetriMode::arc_slot, line::fluid::petri::PetriMode::arc_w, line::fluid::petri::PetriMode::c, line::fluid::petri::PetriMode::closable, line::fluid::petri::PetriMode::dep, line::fluid::petri::PetriTheta::dep, line::fluid::petri::PetriTheta::depslot, line::fluid::petri::PetriTheta::depval, line::fluid::petri::PetriTheta::dslot, line::fluid::petri::PetriTheta::dval, line::fluid::petri::MinMulti::g, line::fluid::petri::MinMulti::h, line::fluid::petri::PetriMode::inh_slot, line::fluid::petri::PetriMode::inh_thr, minmulti_closure(), line::fluid::petri::PetriTerms::modes, norm_cdf(), norm_pdf(), line::fluid::petri::PetriTerms::npair, petri_fine_tol(), petri_theta(), and line::fluid::petri::PetriTheta::theta.

Referenced by petri_theta().

◆ solver_fluid_petri()

template<class T>
PetriSolution line::fluid::petri::solver_fluid_petri ( const qn::NetworkStruct< T > & sn,
const PetriOptions & opt = PetriOptions() )
inline

Fluid analysis of a stochastic Petri net.

Parameters
sna model whose nodes are Places, Transitions, Sources and Sinks only
optthe state-size cap, the Newton tolerance and its iteration cap

Definition at line 1023 of file fluid_petri.h.

References line::fluid::petri::PetriConstraints::A, line::fluid::petri::PetriImmediate::active, line::fluid::petri::PetriMode::arc_slot, line::OdeOptions< T >::atol, line::fluid::petri::PetriConstraints::b, line::fluid::petri::PetriImmediate::bind, line::fluid::petri::PetriConservation::C, line::fluid::petri::PetriReport::capacity_active, line::fluid::petri::PetriReport::capacity_fraction, line::fluid::petri::PetriReport::capacity_label, line::fluid::petri::PetriTerms::consumer_w, line::fluid::petri::PetriTerms::consumers, line::fluid::petri::PetriSolution::converged, line::fluid::petri::PetriTerms::coord_class, line::fluid::petri::PetriTerms::coord_node, line::fluid::petri::PetriTerms::coord_station, line::fluid::petri::PetriTerms::cov_pairs, line::fluid::petri::PetriTerms::ev_kind, line::fluid::petri::PetriTerms::ev_mode, line::fluid::petri::PetriTerms::I, line::fluid::petri::PetriTerms::imm_idx, line::fluid::petri::PetriReport::immediate_flow, line::fluid::petri::PetriReport::invariant_error, line::fluid::petri::PetriReport::invariant_label, line::fluid::petri::PetriReport::invariant_value, line::fluid::petri::PetriSolution::iters, line::fluid::petri::PetriTerms::K, line::fluid::petri::PetriConservation::label, line::fluid::petri::PetriConstraints::label, line::fluid::petri::PetriMode::label, line::fluid::petri::PetriTerms::latch_mode, line::fluid::petri::PetriConservation::leak, line::fluid::petri::PetriReport::marking, line::fluid::petri::PetriReport::marking_var, line::OdeOptions< T >::max_steps, line::fluid::petri::PetriReport::mode_flow, line::fluid::petri::PetriReport::mode_label, line::fluid::petri::PetriTerms::modes, line::fluid::petri::PetriConservation::N, line::fluid::petri::PetriImmediate::n, line::fluid::petri::PetriTerms::names_node, line::fluid::petri::PetriTerms::nev, line::fluid::petri::PetriTerms::nm, line::fluid::petri::PetriTerms::npair, line::fluid::petri::PetriTerms::nstate, line::NumericError::NumericError(), line::ode_rosenbrock4(), line::fluid::petri::PetriVerdict::ok, line::fluid::petri::PetriSolution::petri, petri_applicable(), petri_build_terms(), petri_conservation(), petri_constraints(), petri_fine_tol(), petri_immediate(), line::fluid::petri::PetriReport::pinned, line::fluid::petri::PetriImmediate::pins, line::fluid::petri::PetriTerms::producers, line::fluid::petri::PetriSolution::QN, line::fluid::petri::PetriSolution::QStd, line::fluid::petri::PetriSolution::QVar, line::fluid::petri::PetriTerms::rate_base, line::fluid::petri::PetriVerdict::reason, line::fluid::petri::PetriSolution::resnorm, line::fluid::petri::PetriSolution::RN, line::Matrix< T >::rows(), line::OdeOptions< T >::rtol, line::fluid::petri::PetriReport::Sigma, line::fluid::petri::PetriSolution::Sigma, solver_fluid_petri(), line::OdeOptions< T >::store_trajectory, line::fluid::petri::PetriSolution::t, line::OdeSolution< T >::t, line::fluid::petri::PetriTerms::timed_idx, line::fluid::petri::PetriSolution::TN, line::fluid::petri::PetriSolution::UN, line::UnsupportedError::UnsupportedError(), line::fluid::petri::PetriSolution::warnings, line::fluid::petri::PetriSolution::x, line::fluid::petri::PetriTerms::x0, line::fluid::petri::PetriSolution::xvec_t, and line::OdeSolution< T >::y.

Referenced by solver_fluid_petri().