SSJ  3.3.1
Stochastic Simulation in Java
Protected Attributes | Package Attributes | List of all members
MarkovChain Class Referenceabstract

This class defines a generic Markov chain and provides basic tools to simulate it for a given number of steps or until it stops, and to recover the performance measure. More...

Inheritance diagram for MarkovChain:
[legend]
Collaboration diagram for MarkovChain:
[legend]

Public Member Functions

Abstract methods
abstract void initialState ()
 Sets the Markov chain to its (deterministic) initial state and initializes the collectors for the performance measure, ready to start a simulation. More...
 
abstract void nextStep (RandomStream stream)
 Simulates one more step of the chain, from its current state, using stream for the randomness. More...
 
abstract double getPerformance ()
 Returns the performance measure (total or average cost or gain) so far, for the current simulation run.
 
Other methods
Object clone () throws CloneNotSupportedException
 Returns a clone of the chain.
 
boolean hasStopped ()
 Tells if the chain has stopped.
 
void simulSteps (int numSteps, RandomStream stream)
 Starts a new simulation run and simulates numSteps steps of the Markov chain or until the chain stops, using the given stream.
 
void simulSteps (RandomStream stream)
 Starts a new simulation run and simulates until the stopping time is reached, using the given stream. More...
 
void simulRuns (int n, int numSteps, RandomStream stream, Tally statRuns)
 Performs n simulation runs of the chain, for numSteps steps per run, using the given stream. More...
 
void simulRunsWithSubstreams (int n, int numSteps, RandomStream stream, Tally statRuns)
 Same as simulRuns, except that the stream is first reset to its initial seed and then reset to the first substream at the beginning and to the next substream after each run.
 
double simulMC (int n, int numSteps)
 Perform n simulation runs of the chain, each for numSteps steps, and returns average.
 
double simulMC (int n)
 Perform n runs, each one until the chain stops.
 
void simulRepMC (int n, int numSteps, int m, Tally t)
 Perform n runs and compute the average, reapeat m times and return the stats in t.
 
void simulRepMC (int n, int m, Tally t)
 Same as previous one, but run the chains until they stop.
 
void simulRQMC (PointSet p, int m, int numSteps, PointSetRandomization rand, Tally statReps)
 Performs m independent replicates of \(n\) simulation runs of the chain using a RQMC point set, each time storing the average of the performance over the \(n\) chains. More...
 
String simulRunsFormat (int n, int numSteps, RandomStream stream, Tally statRuns)
 Same as simulRuns but also returns the results as a formatted string.
 
String simulRunsWithSubstreamsFormat (int n, int numSteps, RandomStream stream, Tally statRuns)
 Same as simulRunsWithSubstreams but also returns the results as a formatted string.
 
String simulRQMCFormat (PointSet p, int m, int numSteps, PointSetRandomization rand, Tally statReps)
 Same as simulRQMC but also returns the results as a formatted string.
 
String testImprovementRQMCFormat (PointSet p, int m, int numSteps, PointSetRandomization rand, double varMC, Tally statReps)
 Similar to simulRQMCFormat, but also gives the variance improvement factor with respect to MC. More...
 
String formatResults (Tally stat)
 Returns a string containing the mean, the variance, and a 90% confidence interval for stat.
 
String formatResultsRQMC (Tally stat, int numPoints)
 Returns a string containing the mean, the variance multiplied by numPoints, and a 90% confidence interval for stat.
 

Protected Attributes

boolean stopped = false
 

Package Attributes

Chrono timer = Chrono.createForSingleThread()
 
int numSteps
 

Detailed Description

This class defines a generic Markov chain and provides basic tools to simulate it for a given number of steps or until it stops, and to recover the performance measure.

Chains can be cloned, so one can simulate many replicates in parallel. In a concrete subclass, it suffices to implement the three abstract methods initialState(), nextStep(stream) and getPerformance() to get things going. One would usually implement subclasses of MarkovChainComparable or MarkovChainDouble rather than direct subclasses of MarkovChain. Some other methods are then needed. It is also essential to override the method clone, if the class contains non primitive objects, in order to clone these objects.

The methods in this class permit one to simulate the chain over a certain number of steps via Monte Carlo or randomized quasi-Monte Carlo. Statistics on the performance measure of the chain are computed during these simulations.

Member Function Documentation

◆ initialState()

abstract void initialState ( )
abstract

Sets the Markov chain to its (deterministic) initial state and initializes the collectors for the performance measure, ready to start a simulation.

Must also set variable stopped to false.

◆ nextStep()

abstract void nextStep ( RandomStream  stream)
abstract

Simulates one more step of the chain, from its current state, using stream for the randomness.

If the chain stops, this method must set variable stopped to true.

◆ simulRQMC()

void simulRQMC ( PointSet  p,
int  m,
int  numSteps,
PointSetRandomization  rand,
Tally  statReps 
)

Performs m independent replicates of \(n\) simulation runs of the chain using a RQMC point set, each time storing the average of the performance over the \(n\) chains.

\(n\) is the number of points in RQMC point set p. Each run goes for numSteps steps. For each replicate, the point set p is randomized using rand, an iterator is created, and each run uses a different substream of this iterator (i.e., a different point). The statistics on the performance for the m independent replications are placed in statReps.

◆ simulRuns()

void simulRuns ( int  n,
int  numSteps,
RandomStream  stream,
Tally  statRuns 
)

Performs n simulation runs of the chain, for numSteps steps per run, using the given stream.

The statistics on the performance for the n runs are placed in statRuns.

◆ simulSteps()

void simulSteps ( RandomStream  stream)

Starts a new simulation run and simulates until the stopping time is reached, using the given stream.

Same as simulSteps(Integer.MAX_VALUE, stream).

◆ testImprovementRQMCFormat()

String testImprovementRQMCFormat ( PointSet  p,
int  m,
int  numSteps,
PointSetRandomization  rand,
double  varMC,
Tally  statReps 
)

Similar to simulRQMCFormat, but also gives the variance improvement factor with respect to MC.

Assuming that varMC gives the variance per run for MC.


The documentation for this class was generated from the following file: