SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.simexp.RepSim Class Referenceabstract

Performs a simulation experiment on a finite horizon, using a certain number of independent runs or replications. More...

Inheritance diagram for umontreal.ssj.simexp.RepSim:
umontreal.ssj.simexp.SimExp

Public Member Functions

 RepSim (int minReps)
 Constructs a new replications-based simulator with a minimal number of runs, minReps, and no maximal number of runs.
 RepSim (int minReps, int maxReps)
 Constructs a new replications-based simulator with a minimal number of runs minReps, and a maximal number of runs maxReps.
 RepSim (Simulator sim, int minReps)
 Equivalent to the first constructor, with the given simulator sim.
 RepSim (Simulator sim, int minReps, int maxReps)
 Equivalent to the second constructor, with the given simulator sim.
int getMinReplications ()
 Returns the minimal number of replications to be simulated before an error check.
void setMinReplications (int minReps)
 Sets the minimal number of replications required before an error check to minReps.
int getMaxReplications ()
 Returns the maximal number of replications to be simulated before an error check.
void setMaxReplications (int maxReps)
 Sets the maximal number of replications required before an error check to maxReps.
int getTargetReplications ()
 Returns the actual target number of replications to be simulated before an error check.
void setTargetReplications (int targetReps)
 Sets the target number of simulated replications before an error check to targetReps.
int getCompletedReplications ()
 Returns the total number of completed replications for the current experiment.
abstract void initReplicationProbes ()
 Initializes any statistical collector used to collect values for replications.
void performReplication (int r)
 Contains the necessary logic to perform the rth replication of the simulation.
abstract void initReplication (int r)
 Initializes the simulation model for a new replication r.
abstract void addReplicationObs (int r)
 Adds statistical observations for the replication r.
int getRequiredNewReplications ()
 Returns the approximate number of additional replications to meet an experiment-specific stopping criterion.
void init ()
 Initializes this simulator for a new experiment.
void adjustTargetReplications (int numNewReplications)
 Adjusts the target number of replications to simulate numNewReplications additional replications.
void simulate ()
 Simulates several independent simulation replications of a system.
Public Member Functions inherited from umontreal.ssj.simexp.SimExp
final Simulator simulator ()
 Returns the simulator linked to this experiment object.
final void setSimulator (Simulator sim)
 Sets the simulator associated with this experiment to sim.
boolean isSimulating ()
 Determines if the simulation is in progress.

Protected Member Functions

void replicationDone ()
 Increments by one the number of completed replications.
Protected Member Functions inherited from umontreal.ssj.simexp.SimExp
 SimExp ()
 Constructs a new object for performing experiments using the default simulator returned by Simulator.getDefaultSimulator().
 SimExp (Simulator sim)
 Constructs a new object performing experiments using the given simulator sim.

Additional Inherited Members

Static Public Member Functions inherited from umontreal.ssj.simexp.SimExp
static int getRequiredNewObservations (StatProbe[] a, double targetError, double level)
 Returns the approximate number of additional observations required to reach a relative error smaller than or equal to targetError for each tally in the array a when confidence intervals are computed with confidence level level.
static int getRequiredNewObservations (Iterable<? extends StatProbe > it, double targetError, double level)
 Returns the approximate number of additional observations required to reach a relative error smaller than or equal to targetError for each tally enumerated by it when confidence intervals are computed with confidence level level.
static int getRequiredNewObservations (StatProbe probe, double targetError, double level)
 Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the statistical probe probe.
static int getRequiredNewObservationsTally (Tally ta, double targetError, double level)
 Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the tally ta.
static int getRequiredNewObservationsTally (FunctionOfMultipleMeansTally fmmt, double targetError, double level)
 Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the function of multiple means fmmt.
static int getRequiredNewObservations (double center, double radius, int numberObs, double targetError)
 Returns the approximate number of additional observations needed for the point estimator \(\bar{X}_n=\) center, computed using.
Protected Attributes inherited from umontreal.ssj.simexp.SimExp
boolean simulating = false
 Determines if the simulation is in progress.

Detailed Description

Performs a simulation experiment on a finite horizon, using a certain number of independent runs or replications.

During each run  \(r\), a complete simulation is executed, and the vector \(\mathbf{X}_r\) is generated. If simulation runs are independent, and the same system is simulated during each run, after \(n\) runs are performed, a sample

\((\mathbf{X}_0, …, \mathbf{X}_{n-1})\) is obtained.

              For such a simulation to be implemented, this class must be
              extended to override the required methods:
              #initReplicationProbes to initialize the statistical probes
              collecting @f$\mathbf{X}_r’s@f$, #initReplication(int) to
              initialize the simulation model at the beginning of each
              replication, and #addReplicationObs(int) to
              add @f$\mathbf{X}_r@f$ to the statistical probes.

              <div class="SSJ-bigskip"></div>

Definition at line 47 of file RepSim.java.

Constructor & Destructor Documentation

◆ RepSim() [1/4]

umontreal.ssj.simexp.RepSim.RepSim ( int minReps)

Constructs a new replications-based simulator with a minimal number of runs, minReps, and no maximal number of runs.

Parameters
minRepsthe minimal number of replications.
Exceptions
IllegalArgumentExceptionif the minimal number of replications is smaller than 0.

Definition at line 61 of file RepSim.java.

◆ RepSim() [2/4]

umontreal.ssj.simexp.RepSim.RepSim ( int minReps,
int maxReps )

Constructs a new replications-based simulator with a minimal number of runs minReps, and a maximal number of runs maxReps.

This maximum is used to avoid too long simulations when using sequential sampling.

Parameters
minRepsthe minimal number of replications.
maxRepsthe maximal number of replications.
Exceptions
IllegalArgumentExceptionif the minimal or maximal numbers of replications is smaller than 0, or if minReps is greater than maxReps.

Definition at line 76 of file RepSim.java.

◆ RepSim() [3/4]

umontreal.ssj.simexp.RepSim.RepSim ( Simulator sim,
int minReps )

Equivalent to the first constructor, with the given simulator sim.

Parameters
simthe simulator attached to this object.
minRepsthe minimal number of replications.
Exceptions
IllegalArgumentExceptionif the minimal number of replications is smaller than 0.

Definition at line 88 of file RepSim.java.

◆ RepSim() [4/4]

umontreal.ssj.simexp.RepSim.RepSim ( Simulator sim,
int minReps,
int maxReps )

Equivalent to the second constructor, with the given simulator sim.

Parameters
simthe simulator attached to this object.
minRepsthe minimal number of replications.
maxRepsthe maximal number of replications.
Exceptions
IllegalArgumentExceptionif the minimal or maximal numbers of replications is smaller than 0, or if minReps is greater than maxReps.

Definition at line 102 of file RepSim.java.

Member Function Documentation

◆ addReplicationObs()

abstract void umontreal.ssj.simexp.RepSim.addReplicationObs ( int r)
abstract

Adds statistical observations for the replication r.

This method is called just after the replication r is simulated.

Parameters
rthe index of the replication.

◆ adjustTargetReplications()

void umontreal.ssj.simexp.RepSim.adjustTargetReplications ( int numNewReplications)

Adjusts the target number of replications to simulate numNewReplications additional replications.

This method increases the target number of replications by numNewReplications, and sets the target number of replications to getMaxReplications if the new target exceeds the maximal number of replications. This is called by simulate for sequential sampling.

Parameters
numNewReplicationsthe number of additionnal replications needed.

Definition at line 295 of file RepSim.java.

◆ getCompletedReplications()

int umontreal.ssj.simexp.RepSim.getCompletedReplications ( )

Returns the total number of completed replications for the current experiment.

Returns
the number of completed replications.

Definition at line 203 of file RepSim.java.

◆ getMaxReplications()

int umontreal.ssj.simexp.RepSim.getMaxReplications ( )

Returns the maximal number of replications to be simulated before an error check.

By default, this is set to java.lang.Integer.MAX_VALUE, which is equivalent to infinity in practice.

Returns
the maximal number of replications.

Definition at line 148 of file RepSim.java.

◆ getMinReplications()

int umontreal.ssj.simexp.RepSim.getMinReplications ( )

Returns the minimal number of replications to be simulated before an error check.

Returns
the minimal number of replications.

Definition at line 119 of file RepSim.java.

◆ getRequiredNewReplications()

int umontreal.ssj.simexp.RepSim.getRequiredNewReplications ( )

Returns the approximate number of additional replications to meet an experiment-specific stopping criterion.

This is called after getTargetReplications replications are simulated. Since sequential sampling is not used by default, the default implementation returns 0, which stops the simulation after getTargetReplications replications.

Returns
the number of required additional replications.

Definition at line 267 of file RepSim.java.

◆ getTargetReplications()

int umontreal.ssj.simexp.RepSim.getTargetReplications ( )

Returns the actual target number of replications to be simulated before an error check.

By default, this is initialized to the minimal number of replications, and is increased if new replications are needed. However, it is not decreased by default, even upon a new call to simulate.

Returns
the target number of replications.

Definition at line 174 of file RepSim.java.

◆ init()

void umontreal.ssj.simexp.RepSim.init ( )

Initializes this simulator for a new experiment.

This method resets the number of completed replications to 0, and calls initReplicationProbes to initialize statistical probes. This method is called by simulate.

Definition at line 276 of file RepSim.java.

◆ initReplication()

abstract void umontreal.ssj.simexp.RepSim.initReplication ( int r)
abstract

Initializes the simulation model for a new replication r.

This method should reset any counter and model state, and schedule needed events. After the method returns, the model should be ready for calling umontreal.ssj.simevents.Sim.start. This method is called just after the simulator is initialized.

Parameters
rthe index of the replication.

◆ initReplicationProbes()

abstract void umontreal.ssj.simexp.RepSim.initReplicationProbes ( )
abstract

Initializes any statistical collector used to collect values for replications.

◆ performReplication()

void umontreal.ssj.simexp.RepSim.performReplication ( int r)

Contains the necessary logic to perform the rth replication of the simulation.

By default, the method calls umontreal.ssj.simevents.Sim.init to clear the event list, and uses initReplication(int) to initialize the model. It then calls umontreal.ssj.simevents.Sim.start to start the simulation, calls replicationDone to increment the number of completed replications, and addReplicationObs(int) to add observations to statistical probes.

Parameters
rthe index of the replication.

Definition at line 223 of file RepSim.java.

◆ replicationDone()

void umontreal.ssj.simexp.RepSim.replicationDone ( )
protected

Increments by one the number of completed replications.

This is used by performReplication(int).

Definition at line 235 of file RepSim.java.

◆ setMaxReplications()

void umontreal.ssj.simexp.RepSim.setMaxReplications ( int maxReps)

Sets the maximal number of replications required before an error check to maxReps.

This will take effect only at the next call to simulate.

Parameters
maxRepsthe maximal number of replications.
Exceptions
IllegalArgumentExceptionif the specified number of replications is negative.

Definition at line 160 of file RepSim.java.

◆ setMinReplications()

void umontreal.ssj.simexp.RepSim.setMinReplications ( int minReps)

Sets the minimal number of replications required before an error check to minReps.

This also updates the maximal number of replications if this maximum is smaller than the new minimum. This will take effect only at the next call to simulate.

Parameters
minRepsthe minimal number of replications.
Exceptions
IllegalArgumentExceptionif the specified number of replications is negative.

Definition at line 133 of file RepSim.java.

◆ setTargetReplications()

void umontreal.ssj.simexp.RepSim.setTargetReplications ( int targetReps)

Sets the target number of simulated replications before an error check to targetReps.

The value of targetReps must not be smaller than the minimal number of replications returned by getMinReplications, or greater than the maximal number of replications returned by getMaxReplications.

Parameters
targetRepsthe target number of replications.
Exceptions
IllegalArgumentExceptionif the new target number of replications is smaller than the minimal number of replications.

Definition at line 189 of file RepSim.java.

◆ simulate()

void umontreal.ssj.simexp.RepSim.simulate ( )

Simulates several independent simulation replications of a system.

When this method is called, the method init is called to initialize the system, and getTargetReplications replications are simulated by using performReplication(int). When the target number of replications is simulated, the stopping condition is checked using getRequiredNewReplications, and the target number of replications is adjusted using adjustTargetReplications(int). Additional replications are simulated until the method getRequiredNewReplications returns 0, or getMaxReplications replications are simulated.

Reimplemented from umontreal.ssj.simexp.SimExp.

Definition at line 316 of file RepSim.java.


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