SSJ
V. labo.

umontreal.iro.lecuyer.markovchain
Class MarkovChainDouble

java.lang.Object
  extended by umontreal.iro.lecuyer.markovchain.MarkovChain
      extended by umontreal.iro.lecuyer.markovchain.MarkovChainComparable
          extended by umontreal.iro.lecuyer.markovchain.MarkovChainDouble
All Implemented Interfaces:
Cloneable, MultiDimComparable<MarkovChainComparable>
Direct Known Subclasses:
MarkovChainDoubleStop

public abstract class MarkovChainDouble
extends MarkovChainComparable

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.


Constructor Summary
MarkovChainDouble()
           
 
Method Summary
 int compareTo(MarkovChainComparable other, int i)
          Compares objects of type T in the i-th dimension.
 int dimension()
          Returns the dimension of the state.
 double getPerformance()
          Returns the value of perf which is computed when a chain stops.
 double getPerformance(int numSteps)
          Returns the performance mesure associated with current state, which may depend on the number of steps numsteps.
abstract  double getPerformanceDouble(double state, int numSteps)
          Returns the performance measure associated with state state, which may depend on the number of steps numsteps.
 boolean hasStopped()
          Indicates if the chain has stopped.
 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  double initialStateDouble()
          Returns the initial (deterministic) state.
 void nextStep(RandomStream stream)
          Simulates one more step of the chain, from its current state, using stream for the randomness.
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.
 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 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.
 
Methods inherited from class umontreal.iro.lecuyer.markovchain.MarkovChain
clone, formatResults, formatResultsRQMC, simulRQMC, simulRQMC, simulRQMCFormat, simulRuns, simulRunsFormat, simulRunsWithSubstreamsFormat, simulSteps, simulSteps, testImprovementRQMC
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkovChainDouble

public MarkovChainDouble()
Method Detail

initialStateDouble

public abstract double initialStateDouble()
Returns the initial (deterministic) state.


initialState

public void initialState()
Description copied from class: MarkovChain
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.

Specified by:
initialState in class MarkovChain

nextStepDouble

public 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. 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.


nextStep

public void nextStep(RandomStream stream)
Description copied from class: MarkovChain
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.

Specified by:
nextStep in class MarkovChain

getPerformanceDouble

public abstract double getPerformanceDouble(double state,
                                            int numSteps)
Returns the performance measure associated with state state, which may depend on the number of steps numsteps.


getPerformance

public double getPerformance(int numSteps)
Returns the performance mesure associated with current state, which may depend on the number of steps numsteps.


getPerformance

public double getPerformance()
Returns the value of perf which is computed when a chain stops.

Specified by:
getPerformance in class MarkovChain

hasStopped

public boolean hasStopped()
Indicates if the chain has stopped.

Overrides:
hasStopped in class MarkovChain

dimension

public int dimension()
Description copied from class: MarkovChainComparable
Returns the dimension of the state.

Specified by:
dimension in interface MultiDimComparable<MarkovChainComparable>
Overrides:
dimension in class MarkovChainComparable

compareTo

public int compareTo(MarkovChainComparable other,
                     int i)
Description copied from interface: MultiDimComparable
Compares objects of type T in the i-th dimension. This method must return a negative integer, zero, or a positive integer depending on whether the implicit object is less than, equal to, or greater than o, in dimension i. If i is negative or greater than or equal to the value returned by dimension(), then this method should throw an IllegalArgumentException.


simulStepsDouble

public 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.


simulRunsWithSubstreams

public 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.

Overrides:
simulRunsWithSubstreams in class MarkovChain

SSJ
V. labo.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.