SSJ
V. labo.

umontreal.iro.lecuyer.markovchain
Class ArrayOfComparableChains

java.lang.Object
  extended by umontreal.iro.lecuyer.markovchain.ArrayOfComparableChains
Direct Known Subclasses:
ArrayOfComparableChainsStop, ArrayOfDoubleChains

public class ArrayOfComparableChains
extends Object

Permits one to simulate an array of MarkovChainComparable using the array-RQMC method of[#!vLEC05a!#], where n copies of the chain are simulated in parallel, and sorted using a multi-dimensional sort (see MultiDimSort) at each step of the chain. The transitions of the n chains at any given step are determined from the n points of a d-dimensional RQMC PointSet, where d is the number of uniforms required at each step of the chain. The PointSet is randomized at each step using a PointSetRandomization.


Constructor Summary
ArrayOfComparableChains(MarkovChainComparable baseChain)
          Same as ArrayOfComparableChains(baseChain, new RandomShift(new MRG32k3a()), new SplitSort(baseChain.stateDim)).
ArrayOfComparableChains(MarkovChainComparable baseChain, PointSetRandomization rand, MultiDimSort sort)
          Creates an array of the comparable chain baseChain.
 
Method Summary
 double calcMeanPerf()
          Computes and returns the mean performance of the n chains.
 MarkovChainComparable[] getChains()
          Returns the underlying array of n MarkovChainComparable.
 int getN()
          Returns the number n of chains.
 double[] getPerformances()
          Returns the performance of the n chains in an array.
 PointSetRandomization getRandomization()
          Returns the internal PointSetRandomization.
 MultiDimSort getSort()
          Returns the MultiDimSort used.
 void initialStates()
          Initializes the n copies (clones) of the chain baseChain to their initial state by calling initialState() on each chain.
 void makeCopies(int n)
          Creates n copies (clones) of the chain baseChain and puts them in an array, ready for the array RQMC simulation.
 void setRandomization(PointSetRandomization rand)
          Sets the internal PointSetRandomization to rand.
 void setSort(MultiDimSort sort)
          Sets MultiDimSort to sort.
 double simulArrayRQMC(PointSet p, int numSteps)
          Simulates the n copies of the chain, numSteps steps for each copy, using PointSet p, where n is the current number of copies (clones) of the chain and is assumed to equal the number of points in p.
 int simulOneStepArrayRQMC(PointSet p)
          Simulates the n copies of the chain, one step for each copy, using PointSet p, where n is the current number of copies (clones) of the chain and is assumed to equal the number of points in p.
 String simulReplicatesArrayRQMC(PointSet p, int m, int numSteps, Tally statReps)
          Performs m independent replications of an array-RQMC simulation as in simulArrayRQMC.
 void sortChains()
          Sorts the chains using the stored MultiDimSort.
 void sortNotStoppedChains()
          Sorts the chains that have not stopped yet using the stored MultiDimSort.
 String testImprovementArrayRQMC(PointSet p, int m, int numSteps, double varMC, Tally statReps)
          Similar to simulReplicatesArrayRQMC, but also gives the variance improvement factor with respect to MC, assuming that varMC gives the variance per run for MC.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayOfComparableChains

public ArrayOfComparableChains(MarkovChainComparable baseChain,
                               PointSetRandomization rand,
                               MultiDimSort sort)
Creates an array of the comparable chain baseChain. The method makeCopies must be called to make the copies. rand will be used to randomize the point sets in the simulations. sort will be used to sort the chains.


ArrayOfComparableChains

public ArrayOfComparableChains(MarkovChainComparable baseChain)
Same as ArrayOfComparableChains(baseChain, new RandomShift(new MRG32k3a()), new SplitSort(baseChain.stateDim)).

Method Detail

makeCopies

public void makeCopies(int n)
Creates n copies (clones) of the chain baseChain and puts them in an array, ready for the array RQMC simulation.


initialStates

public void initialStates()
Initializes the n copies (clones) of the chain baseChain to their initial state by calling initialState() on each chain.


getPerformances

public double[] getPerformances()
Returns the performance of the n chains in an array.


getN

public int getN()
Returns the number n of chains.


getChains

public MarkovChainComparable[] getChains()
Returns the underlying array of n MarkovChainComparable.


setRandomization

public void setRandomization(PointSetRandomization rand)
Sets the internal PointSetRandomization to rand.


getRandomization

public PointSetRandomization getRandomization()
Returns the internal PointSetRandomization.


setSort

public void setSort(MultiDimSort sort)
Sets MultiDimSort to sort.


getSort

public MultiDimSort getSort()
Returns the MultiDimSort used.


simulOneStepArrayRQMC

public int simulOneStepArrayRQMC(PointSet p)
Simulates the n copies of the chain, one step for each copy, using PointSet p, where n is the current number of copies (clones) of the chain and is assumed to equal the number of points in p. The points are randomized before the simulation using the stored PointSetRandomization. The dimension of p must be at least as large as the number of uniforms required to simulate one step of the chain. Returns the number of chains that have not stopped yet.


simulArrayRQMC

public double simulArrayRQMC(PointSet p,
                             int numSteps)
Simulates the n copies of the chain, numSteps steps for each copy, using PointSet p, where n is the current number of copies (clones) of the chain and is assumed to equal the number of points in p. At each step, the points are randomized using the stored PointSetRandomization. The dimension of p must be at least as large as the number of uniforms required to simulate one step of the chain. Returns the average performance per run.


calcMeanPerf

public double calcMeanPerf()
Computes and returns the mean performance of the n chains.


simulReplicatesArrayRQMC

public String simulReplicatesArrayRQMC(PointSet p,
                                       int m,
                                       int numSteps,
                                       Tally statReps)
Performs m independent replications of an array-RQMC simulation as in simulArrayRQMC. The statistics on the m corresponding averages are collected in statReps and the results are also returned in a string.


testImprovementArrayRQMC

public String testImprovementArrayRQMC(PointSet p,
                                       int m,
                                       int numSteps,
                                       double varMC,
                                       Tally statReps)
Similar to simulReplicatesArrayRQMC, but also gives the variance improvement factor with respect to MC, assuming that varMC gives the variance per run for MC.


sortNotStoppedChains

public void sortNotStoppedChains()
Sorts the chains that have not stopped yet using the stored MultiDimSort. All the stopped chains are placed at the end, then the chains that have not stopped are sorted.


sortChains

public void sortChains()
Sorts the chains using the stored MultiDimSort.


SSJ
V. labo.

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