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...
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. | |
| abstract void | nextStep (RandomStream stream) |
| Simulates one more step of the chain, from its current state, using stream for the randomness. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
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.
Definition at line 34 of file MarkovChain.java.
| Object umontreal.ssj.markovchainrqmc.MarkovChain.clone | ( | ) | throws CloneNotSupportedException |
Returns a clone of the chain.
Definition at line 75 of file MarkovChain.java.
| String umontreal.ssj.markovchainrqmc.MarkovChain.formatResults | ( | Tally | stat | ) |
Returns a string containing the mean, the variance, and a 90% confidence interval for stat.
Definition at line 263 of file MarkovChain.java.
| String umontreal.ssj.markovchainrqmc.MarkovChain.formatResultsRQMC | ( | Tally | stat, |
| int | numPoints ) |
Returns a string containing the mean, the variance multiplied by numPoints, and a 90% confidence interval for stat.
Definition at line 276 of file MarkovChain.java.
|
abstract |
Returns the performance measure (total or average cost or gain) so far, for the current simulation run.
Reimplemented in umontreal.ssj.markovchainrqmc.MarkovChainDouble.
| boolean umontreal.ssj.markovchainrqmc.MarkovChain.hasStopped | ( | ) |
Tells if the chain has stopped.
Reimplemented in umontreal.ssj.markovchainrqmc.MarkovChainDouble.
Definition at line 88 of file MarkovChain.java.
|
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.
Reimplemented in umontreal.ssj.markovchainrqmc.MarkovChainDouble.
|
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.
Reimplemented in umontreal.ssj.markovchainrqmc.MarkovChainDouble.
| double umontreal.ssj.markovchainrqmc.MarkovChain.simulMC | ( | int | n | ) |
Perform n runs, each one until the chain stops.
Definition at line 156 of file MarkovChain.java.
| double umontreal.ssj.markovchainrqmc.MarkovChain.simulMC | ( | int | n, |
| int | numSteps ) |
Perform n simulation runs of the chain, each for numSteps steps, and returns average.
Definition at line 147 of file MarkovChain.java.
| void umontreal.ssj.markovchainrqmc.MarkovChain.simulRepMC | ( | int | n, |
| int | m, | ||
| Tally | t ) |
Same as previous one, but run the chains until they stop.
Definition at line 173 of file MarkovChain.java.
| void umontreal.ssj.markovchainrqmc.MarkovChain.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.
Definition at line 164 of file MarkovChain.java.
| void umontreal.ssj.markovchainrqmc.MarkovChain.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.
Definition at line 187 of file MarkovChain.java.
| String umontreal.ssj.markovchainrqmc.MarkovChain.simulRQMCFormat | ( | PointSet | p, |
| int | m, | ||
| int | numSteps, | ||
| PointSetRandomization | rand, | ||
| Tally | statReps ) |
Same as simulRQMC but also returns the results as a formatted string.
Definition at line 231 of file MarkovChain.java.
| void umontreal.ssj.markovchainrqmc.MarkovChain.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.
Definition at line 120 of file MarkovChain.java.
| String umontreal.ssj.markovchainrqmc.MarkovChain.simulRunsFormat | ( | int | n, |
| int | numSteps, | ||
| RandomStream | stream, | ||
| Tally | statRuns ) |
Same as simulRuns but also returns the results as a formatted string.
Definition at line 202 of file MarkovChain.java.
| void umontreal.ssj.markovchainrqmc.MarkovChain.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.
Reimplemented in umontreal.ssj.markovchainrqmc.MarkovChainDouble.
Definition at line 133 of file MarkovChain.java.
| String umontreal.ssj.markovchainrqmc.MarkovChain.simulRunsWithSubstreamsFormat | ( | int | n, |
| int | numSteps, | ||
| RandomStream | stream, | ||
| Tally | statRuns ) |
Same as simulRunsWithSubstreams but also returns the results as a formatted string.
Definition at line 217 of file MarkovChain.java.
| void umontreal.ssj.markovchainrqmc.MarkovChain.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.
Definition at line 96 of file MarkovChain.java.
| void umontreal.ssj.markovchainrqmc.MarkovChain.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).
Definition at line 111 of file MarkovChain.java.
| String umontreal.ssj.markovchainrqmc.MarkovChain.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.
Definition at line 249 of file MarkovChain.java.