SSJ
3.3.1
Stochastic Simulation in Java
|
A special kind of Markov chain whose state space is a subset of the real numbers. More...
Public Member Functions | |
Abstract Methods | |
abstract double | initialStateDouble () |
Returns the initial (deterministic) state. | |
void | initialState () |
abstract double | nextStepDouble (int step, double s, RandomStream stream) |
Simulates one step of the chain, from state s , using stream for the randomness, assuming we are at step step . More... | |
void | nextStep (RandomStream stream) |
abstract double | getPerformanceDouble (double state, int numSteps) |
Returns the performance measure associated with state state , which may depend on the number of steps numsteps . | |
Other Methods | |
double | getPerformance (int numSteps) |
Returns the performance mesure associated with current state, which may depend on the number of steps numsteps . | |
double | getPerformance () |
Returns the value of perf which is computed when a chain stops. | |
boolean | hasStopped () |
Indicates if the chain has stopped. | |
int | getStateDimension () |
This method returns the number \(d\) of coordinates for which the method #compareTo can be invoked for this object. More... | |
int | compareTo (MarkovChainComparable other, int i) |
double | simulStepsDouble (int numSteps, RandomStream stream) |
After invoking initialStateDouble, starts a new simulation run, simulates numSteps steps of the Markov chain using the given stream , and returns the final state. 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. | |
Public Member Functions inherited from MarkovChainComparable | |
int | getStateDimension () |
Returns the dimension of the state. | |
Public Member Functions inherited from MarkovChain | |
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. | |
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 . | |
Public Member Functions inherited from MultiDimComparable< T > | |
int | compareTo (T other, int j) |
Similar to compareTo in the class Comparable, except that one specifies the index \(j\) of the criterion on which the objects are to be compared. More... | |
Protected Attributes | |
double | state = 0 |
int | step = 0 |
double | perf = 0 |
Protected Attributes inherited from MarkovChainComparable | |
int | stateDim |
Protected Attributes inherited from MarkovChain | |
boolean | stopped = false |
Additional Inherited Members | |
Package Attributes inherited from MarkovChain | |
Chrono | timer = Chrono.createForSingleThread() |
int | numSteps |
A special kind of Markov chain whose state space is a subset of the real numbers.
The state is stored in the double variable state
.
The "Double" version of the methods from Markov Chain now returns the state. This makes it possible to simulate several copies of this chain in parallel without cloning and without maintaining the state of the chain in a local variable. The states can be maintained in an external array and at each step, one passes the current state to the method nextStepDouble
, which returns the next state. This is exploited in the implementation of ArrayOfDoubleChains
.
The methods #initialState, #nextStep, getPerformance
and #compareTo, which are abstract in MarkovChainComparable, all have a default implementation here, so the methods of Markov Chain still work.
On the other hand, the abstract methods specified in the present class do not necessarily update local variables.
Abstract method compareTo
from class MarkovChainComparable
is implemented by comparing variable state
of the chains. And method dimension
now returns 1, there’s no need to set variable stateDim
.
int getStateDimension | ( | ) |
This method returns the number \(d\) of coordinates for which the method #compareTo can be invoked for this object.
That is, compareTo (other, j)
can be called only for \(\mathtt{j}=0,…,\mathtt{dimension()-1}\).
Implements MultiDimComparable< T >.
|
abstract |
Simulates one step of the chain, from state s
, using stream
for the randomness, assuming we are at step step
.
If the chain stops, this method must compute the performance and save it to variable perf
, then return Double.POSITIVE_INFINITY
. If not, it returns the new state.
double simulStepsDouble | ( | int | numSteps, |
RandomStream | stream | ||
) |
After invoking initialStateDouble, starts a new simulation run, simulates numSteps
steps of the Markov chain using the given stream
, and returns the final state.
The simulSteps method in MarkovChain
does the same, but returns nothing.