LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
sim_runlength.h File Reference

Run-length planning for steady-state simulation. More...

#include <cmath>
#include <limits>
#include <cstddef>
#include <vector>
#include "line/num/number.h"
#include "line/util/error.h"
#include "line/util/lu.h"
#include "line/util/matrix.h"
Include dependency graph for sim_runlength.h:

Go to the source code of this file.

Classes

struct  line::sim::AsymVarResult< T >
 Second-order description of a steady-state estimator. More...
struct  line::sim::RunLengthResult< T >
 Outcome of the run-length plan. More...
struct  line::sim::RunLengthPlan< T >
 The plan of sim_runlength_plan: what the run should have been. More...

Namespaces

namespace  line
namespace  line::sim

Functions

template<class T>
AsymVarResult< T > line::sim::sim_asymvar_mm1 (const T &lambda, const T &mu)
 Asymptotic variance of the M/M/1 number-in-system process.
template<class T>
AsymVarResult< T > line::sim::sim_asymvar_ctmc (const Matrix< T > &A, const std::vector< T > &f, const std::vector< T > &pi=std::vector< T >())
 Asymptotic variance of a reward on a CTMC: 2 sum_x pi(x)g(x)d(x) with g = f - E_pi[f] and A d = -g, pi d = 0.
template<class T>
RunLengthResult< T > line::sim::sim_runlength (const T &mean, const T &asymVar, const T &relPrecision=num_traits< T >::from_rational(1, 20), const T &confidence=num_traits< T >::from_rational(19, 20), const T &runLength=num_traits< T >::from_int(0))
 Run length for a steady-state estimate of a given relative precision.
template<class T>
RunLengthPlan< T > line::sim::sim_runlength_plan (const Matrix< T > &means, const Matrix< T > &ciHalfWidth, const T &samplesUsed, const T &relPrecision=num_traits< T >::from_rational(1, 20), const T &confidence=num_traits< T >::from_rational(19, 20))
 How long a simulation run should have been, from the one it already did.

Detailed Description

Run-length planning for steady-state simulation.

Templated port of matlab/src/api/sim/sim_runlength.m, sim_asymvar_mm1.m and sim_asymvar_ctmc.m, cross-checked against jar/src/main/java/jline/api/sim/SimRunlength.java.

THE QUANTITY THAT MATTERS is not the variance of the process but its ASYMPTOTIC VARIANCE sigma^2 = lim t Var(time-average over [0,t]), twice the integral of the autocovariance: a time average of a positively correlated process converges at rate sigma^2/t, not Var(X)/t. Then

t* = (z/eps)^2 sigma^2 / mean^2

is the run needed for relative precision eps at confidence 1-alpha.

For M/M/1, sigma^2 = 2 rho(1+rho)/(mu (1-rho)^4) in closed form; the FOURTH power is the whole story, and dividing by the squared mean leaves a run length growing like (1-rho)^-2. Checked here against the general CTMC deviation-vector computation, which agrees to 1e-6 at rho up to 0.9.

ARITHMETIC. The normal quantile needs erfc, so the planner is transcendental; the CTMC asymptotic variance is a linear solve and stays exact.

Reference: W. Whitt (1989). Planning queueing simulations. Management Science 35(11), 1341-1366.

Definition in file sim_runlength.h.