Class ExperimentRunner<T extends Experiment<T>>
- Type Parameters:
T- the type ofExperimentthe runner will execute
- All Implemented Interfaces:
Runnable
- Since:
- CloudSim Plus 1.0
- Author:
- Manoel Campos da Silva Filho
-
Field Summary
Fields inherited from class org.cloudsimplus.testbeds.AbstractRunnable
verbose -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedExperimentRunner(long baseSeed, int simulationRuns) Creates an experiment runner with a giventhat runs sequentially.invalid reference
base seedprotectedExperimentRunner(long baseSeed, int simulationRuns, boolean applyAntitheticVariates) Creates an experiment runner with a given
invalid reference
base seed
that runs sequentially.
protectedExperimentRunner(long baseSeed, int simulationRuns, boolean latexTableResultsGeneration, boolean parallel) Creates an experiment runner with a given
invalid reference
base seed
that runs sequentially.
protectedExperimentRunner(long baseSeed, int simulationRuns, int batchesNumber, boolean applyAntitheticVariates) Creates an experiment runner with a given
invalid reference
base seed
that runs sequentially.
protectedExperimentRunner(long baseSeed, int simulationRuns, int batchesNumber, boolean applyAntitheticVariates, boolean parallel, boolean latexTableResultsGeneration) Creates an experiment runner with a given
.invalid reference
base seed
-
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddMetricValue(String metricName, Double value) Add a value to a given metric inside themetricsMap.intcomputeAntitheticMeans(List<Double> samples) Computes the antithetic means for the given samples if the
.invalid reference
"Antithetic Variates Technique" is to be applied
computeBatchMeans(List<Double> samples) Gets a list of samples and apply the "Batch Means Method" to reduce samples correlation, if the "Batch Means Method"is to be applied.protected ConfidenceIntervalcomputeFinalResults(Map.Entry<String, List<Double>> metricEntry) Computes final simulation results, including mean, standard deviations and confidence intervals for a given metric computed across all simulation runs.protected final org.apache.commons.math3.stat.descriptive.SummaryStatisticscomputeFinalStatistics(List<Double> values) Creates aSummaryStatisticsobject from a list of Double values, allowing computation of statistics such as mean over these values.protected abstract TcreateExperimentInternal(int index) Creates an experiment to be run for the i'th time.createRandomGen(int experimentIndex) Creates a pseudo random number generator (PRNG) for an experiment run that generates uniform values between [0..1[.createRandomGen(int experimentIndex, double minInclusive, double maxExclusive) Creates a pseudo random number generator (PRNG) for an experiment run that generates uniform values between [min .. max[.<S extends StatisticalDistribution>
ScreateRandomGen(int experimentIndex, @NonNull Function<Long, S> randomGenCreator) Uses the providedFunctionto create a pseudo random number generator (PRNG) for an experiment run.intgetMetricValues(String metricName) longgetSeed(int experimentIndex) intbooleanChecks if the "Batch Means Method" is to be applied to reduce correlation between the results for different experiment runs.booleanChecks if the experiment will run a single time or not.booleanisToReuseSeedFromFirstHalfOfExperiments(int currentExperimentIndex) protected abstract voidvoidrun()Setups and starts the execution of all experiments sequentially or inparallel.voidsetFirstExperimentCreated(int firstExperimentCreated) Methods inherited from class org.cloudsimplus.testbeds.AbstractRunnable
isNotVerbose, print, print, println, println, println
-
Constructor Details
-
ExperimentRunner
protected ExperimentRunner(long baseSeed, int simulationRuns) Creates an experiment runner with a giventhat runs sequentially.invalid reference
base seed- Parameters:
baseSeed- the seed to be used as base for each experiment seedsimulationRuns- the number of times the experiment will be executed
-
ExperimentRunner
protected ExperimentRunner(long baseSeed, int simulationRuns, boolean latexTableResultsGeneration, boolean parallel) Creates an experiment runner with a given
invalid reference
base seed
that runs sequentially.
- Parameters:
baseSeed- the seed to be used as base for each experiment seedsimulationRuns- the number of times the experiment will be executedlatexTableResultsGeneration- Enables/disables the generation of a result table in LaTeX format for computed metrics.parallel- whether experiments will run in parallel or sequentially
-
ExperimentRunner
protected ExperimentRunner(long baseSeed, int simulationRuns, boolean applyAntitheticVariates) Creates an experiment runner with a given
invalid reference
base seed
that runs sequentially.
- Parameters:
baseSeed- the seed to be used as base for each experiment seedsimulationRuns- the number of times the experiment will be executedapplyAntitheticVariates- indicates if it's to be applied the Antithetic Variates Technique.
-
ExperimentRunner
protected ExperimentRunner(long baseSeed, int simulationRuns, int batchesNumber, boolean applyAntitheticVariates) Creates an experiment runner with a given
invalid reference
base seed
that runs sequentially.
- Parameters:
baseSeed- the seed to be used as base for each experiment seedsimulationRuns- the number of times the experiment will be executedbatchesNumber- number of simulation run batches (zero disables the batch means method)applyAntitheticVariates- indicates if it's to be applied the Antithetic Variates Technique.
-
ExperimentRunner
protected ExperimentRunner(long baseSeed, int simulationRuns, int batchesNumber, boolean applyAntitheticVariates, boolean parallel, boolean latexTableResultsGeneration) Creates an experiment runner with a given
.invalid reference
base seed
- Parameters:
baseSeed- the seed to be used as base for each experiment seedsimulationRuns- the number of times the experiment will be executedbatchesNumber- number of simulation run batches (zero disables the batch means method)applyAntitheticVariates- indicates if it's to be applied the Antithetic Variates Technique.parallel- whether experiments will run in parallel or sequentially. It's just actually enabled when thesimulationRunsis larger than 1.latexTableResultsGeneration- Enables/disables the generation of a result table in LaTeX format for computed metrics.
-
-
Method Details
-
batchSizeCeil
public int batchSizeCeil()- Returns:
- the batch size rounded by the
Math.ceil(double)method.
-
isApplyBatchMeansMethod
public boolean isApplyBatchMeansMethod()Checks if the "Batch Means Method" is to be applied to reduce correlation between the results for different experiment runs. That happens if the number of simulation runs and the number of batches are compatible.- Returns:
- true if the "Batch Means Method" is to be applied, false otherwise.
-
computeBatchMeans
Gets a list of samples and apply the "Batch Means Method" to reduce samples correlation, if the "Batch Means Method"is to be applied.- Parameters:
samples- the list with samples to apply the "Batch Means Method". Samples size is defined by the.invalid reference
#getSimulationRuns()- Returns:
- the samples list after applying the "Batch Means Method", in case
the method is enabled to be applied, which will reduce the array to the
number of batches defined by
(each value in the returned array will be the mean of every sample batch). Otherwise, returns the same given array
invalid reference
#getBatchesNumber()
-
isSingleRun
public boolean isSingleRun()Checks if the experiment will run a single time or not.- Returns:
- true if the experiment will run a single time, false if there are multiple simulation runs.
-
getSeed
public long getSeed(int experimentIndex) -
createRandomGen
public <S extends StatisticalDistribution> S createRandomGen(int experimentIndex, @NonNull @NonNull Function<Long, S> randomGenCreator) Uses the provided
Functionto create a pseudo random number generator (PRNG) for an experiment run. The given Function defines the kind and parameters for this PRNG internally. This method calls that Function just providing the seed to be used for the current experiment run.If it is to apply the
invalid reference
Antithetic Variates Technique
to reduce results variance, the second half of experiments will use the seeds from the first half.
- Parameters:
experimentIndex- index of the experiment's run to create a PRNGrandomGenCreator- aFunctionthat receives a seed generated by the runner and returns a new instance of some PRNG- Returns:
- the created PRNG with the seed provided by the runner
- See Also:
-
createRandomGen
Creates a pseudo random number generator (PRNG) for an experiment run that generates uniform values between [0..1[. If it is to apply theto reduce results variance, the second half of experiments will use the seeds from the first half.invalid reference
"Antithetic Variates Technique"- Parameters:
experimentIndex- index of the experiment's run to create a PRNG- Returns:
- the created PRNG
- See Also:
-
createRandomGen
public ContinuousDistribution createRandomGen(int experimentIndex, double minInclusive, double maxExclusive) Creates a pseudo random number generator (PRNG) for an experiment run that generates uniform values between [min .. max[. If it is to apply the
invalid reference
"Antithetic Variates Technique"
to reduce results' variance, the second half of experiments will use the seeds from the first half.
- Parameters:
experimentIndex- index of the experiment's run to create a PRNGminInclusive- the minimum value the generator will return (inclusive)maxExclusive- the maximum value the generator will return (exclusive)- Returns:
- the created PRNG
- See Also:
-
isToReuseSeedFromFirstHalfOfExperiments
public boolean isToReuseSeedFromFirstHalfOfExperiments(int currentExperimentIndex) -
halfSimulationRuns
public int halfSimulationRuns()- Returns:
- the half of
invalid reference
#getSimulationRuns()
-
run
public void run()Setups and starts the execution of all experiments sequentially or inparallel. -
createExperimentInternal
Creates an experiment to be run for the i'th time.- Parameters:
index- a number that identifies the experiment- Returns:
- the created experiment
- See Also:
-
computeFinalResults
Computes final simulation results, including mean, standard deviations and confidence intervals for a given metric computed across all simulation runs.- Parameters:
metricEntry- a map entry represented by the name of the metric and its list of values across multiple simulation runs- Returns:
- the computed
ConfidenceIntervalfrom the provided values for the metric
-
computeFinalStatistics
protected final org.apache.commons.math3.stat.descriptive.SummaryStatistics computeFinalStatistics(List<Double> values) Creates a
SummaryStatisticsobject from a list of Double values, allowing computation of statistics such as mean over these values. The method also checks if theinvalid reference
Antithetic Variates
and the Batch Means techniques are enabled, applying them over the given list of Doubles. These techniques are used for variance reduction.
- Parameters:
values- the List of values to add to theSummaryStatisticsobject- Returns:
- the
SummaryStatisticsobject containing the double values, after applying the techniques for variance reduction.
-
addMetricValue
Add a value to a given metric inside the
metricsMap.This method must be called for each metric inside the experiment finish listener. The listener can be set inside the runner's
createExperimentInternal(int).- Parameters:
metricName- the name of the metric to collect the data for a simulation runvalue- the value for at metric for a given simulation run. If null is given, that means no value was collected for that metric in the run, but the metric entry must exist in the metrics map, so that the final results' table shows the metric entry with 0.- See Also:
-
getMetricValues
-
computeAntitheticMeans
Computes the antithetic means for the given samples if the
.invalid reference
"Antithetic Variates Technique" is to be applied
These values are the average between the first half of samples with the second half. By this way, the resulting value is an array with half the samples' length.
NOTE: To correctly compute the antithetic values, the seeds from the first half of experiments must be used for the second half.
- Parameters:
samples- the list of samples to compute the antithetic means from- Returns:
- the computed antithetic means from the given samples if the "Antithetic Variates Technique" is to be applied, otherwise return the same given samples list.
- See Also:
-
printSimulationParameters
protected abstract void printSimulationParameters() -
setFirstExperimentCreated
public void setFirstExperimentCreated(int firstExperimentCreated) -
getFinishedRuns
public int getFinishedRuns()
-