Package jasima.core.experiment
Class AbstractMultiExperiment
- java.lang.Object
-
- jasima.core.experiment.Experiment
-
- jasima.core.experiment.AbstractMultiExperiment
-
- All Implemented Interfaces:
Notifier<Experiment,Experiment.ExperimentEvent>,ValueStore,Serializable,Cloneable
- Direct Known Subclasses:
AbstractMultiConfExperiment,MultipleReplicationExperiment
public abstract class AbstractMultiExperiment extends Experiment
Parent class of an experiment which runs a number of child experiments.- Author:
- Torsten Hildebrandt
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractMultiExperiment.BaseExperimentCompletedComplex event object triggered upon sub-experiment completion.-
Nested classes/interfaces inherited from class jasima.core.experiment.Experiment
Experiment.ExperimentEvent, Experiment.ExperimentState, Experiment.UniqueNamesCheckingHashMap
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>detailedResultsNumericprotected Map<String,Object>detailedResultsOtherprotected List<Experiment>experimentsstatic StringNUM_TASKS_EXECUTEDprotected intnumTasksExecutedprotected RandomseedStream-
Fields inherited from class jasima.core.experiment.Experiment
aborted, DEFAULT_SEED, error, EXCEPTION, EXCEPTION_MESSAGE, EXP_ABORTED, resultMap, RUNTIME
-
-
Constructor Summary
Constructors Constructor Description AbstractMultiExperiment()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddKeepResultName(String name)AbstractMultiExperimentclone()protected voidconfigureRunExperiment(Experiment e)protected abstract voidcreateExperiments()protected voidexecuteExperiments()protected longgetExperimentSeed()String[]getKeepResults()abstract intgetNumExperiments()intgetNumTasks()intgetNumTasksExecuted()intgetSkipSeedCount()protected voidhandleNumericValue(String key, Object val)Handles a numeric value "val" by averaging it over all runs performed.protected voidhandleOtherValue(String key, Object val)Handles arbitrary values "val" by storing them in an object array.protected booleanhasMoreTasks()voidinit()This method is called to perform any initializations required before the experiment is run.booleanisAbortUponBaseExperimentAbort()booleanisAllowParallelExecution()booleanisCommonRandomNumbers()booleanisKeepTaskResults()booleanisProduceAveragedResults()protected booleanisSpecialKey(String key)protected voidperformRun()Contains the code to actually do something useful.protected abstract Stringprefix()protected voidproduceResults()Populates the result mapExperiment.resultMapwith values produced during experiment execution.booleanremoveKeepResultName(String name)voidsetAbortUponBaseExperimentAbort(boolean abortUponBaseExperimentAbort)If set totrue, this experiment aborts immediately (indicating an abort in its results) after the first sub-experiment aborting.voidsetAllowParallelExecution(boolean allowParallelExecution)If this attribute is set totrue, sub-experiments will be executed concurrently in parallel.protected voidsetCommonRandomNumbers(boolean commonRandomNumbers)Whether to use the variance reduction technique of common random numbers.voidsetKeepResults(String... keepResults)Sets the names of all results where detailed results of all sub-experiment executions should be preserved.voidsetProduceAveragedResults(boolean produceAveragedResults)Whether or not to produce averaged results across all sub-experiments as a result of this experiment.voidsetSkipSeedCount(int skipSeedCount)Before starting, throw away this many seed values.protected voidstoreRunResults(Experiment e, Map<String,Object> r)-
Methods inherited from class jasima.core.experiment.Experiment
abort, addErrorResults, addStandardResults, afterRun, beforeRun, cancel, checkCancelledOrInterrupted, done, executeSubExperiment, finalActions, finish, getError, getInitialSeed, getLogLevel, getName, getPropsWithValues, getResults, getState, handleExecutionError, isCancelled, main, nestingLevel, nestingLevel, notifierImpl, print, print, print, print, printResults, readResolve, requireState, runExperiment, runExperimentAsync, runExperimentAsync, runExperimentInternal, runTimeReal, setInitialSeed, setLogLevel, setName, starting, state, toString, valueStoreImpl
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jasima.core.util.observer.Notifier
addListener, addListener, addListener, fire, fire, getListener, numListener, removeCurrentListener, removeListener
-
Methods inherited from interface jasima.core.util.ValueStore
valueStoreContains, valueStoreGet, valueStoreGet, valueStoreGetAllKeys, valueStoreGetNumKeys, valueStorePut, valueStoreRemove, valueStoreUpdate
-
-
-
-
Field Detail
-
NUM_TASKS_EXECUTED
public static final String NUM_TASKS_EXECUTED
- See Also:
- Constant Field Values
-
seedStream
protected Random seedStream
-
experiments
protected List<Experiment> experiments
-
numTasksExecuted
protected int numTasksExecuted
-
-
Method Detail
-
init
public void init()
Description copied from class:ExperimentThis method is called to perform any initializations required before the experiment is run.- Overrides:
initin classExperiment
-
performRun
protected void performRun()
Description copied from class:ExperimentContains the code to actually do something useful. This is the only abstract method that sub-classes are required to implement.- Specified by:
performRunin classExperiment
-
hasMoreTasks
protected boolean hasMoreTasks()
-
createExperiments
protected abstract void createExperiments()
-
executeExperiments
protected void executeExperiments()
-
configureRunExperiment
protected void configureRunExperiment(Experiment e)
-
getExperimentSeed
protected long getExperimentSeed()
-
storeRunResults
protected void storeRunResults(Experiment e, Map<String,Object> r)
-
getNumExperiments
public abstract int getNumExperiments()
-
getNumTasks
public int getNumTasks()
-
getNumTasksExecuted
public int getNumTasksExecuted()
-
prefix
protected abstract String prefix()
-
handleOtherValue
protected void handleOtherValue(String key, Object val)
Handles arbitrary values "val" by storing them in an object array.- Parameters:
key- Name of the value to store.val- The value to store. Can be null.
-
handleNumericValue
protected void handleNumericValue(String key, Object val)
Handles a numeric value "val" by averaging it over all runs performed. If "val" is of type SummaryStat, averaging is performed with its mean()-value.- Parameters:
key- The name if the value.val- The numeric value to store. Either aNumber, or aSummaryStat
-
isSpecialKey
protected boolean isSpecialKey(String key)
-
produceResults
protected void produceResults()
Description copied from class:ExperimentPopulates the result mapExperiment.resultMapwith values produced during experiment execution. The Experiment always adds the two results "runTime" and "expAborted".- Overrides:
produceResultsin classExperiment
-
clone
public AbstractMultiExperiment clone()
- Overrides:
clonein classExperiment
-
addKeepResultName
public void addKeepResultName(String name)
-
removeKeepResultName
public boolean removeKeepResultName(String name)
-
isKeepTaskResults
public boolean isKeepTaskResults()
-
getKeepResults
public String[] getKeepResults()
-
setKeepResults
public void setKeepResults(String... keepResults)
Sets the names of all results where detailed results of all sub-experiment executions should be preserved.- Parameters:
keepResults- The names of all results for which detailed run results from sub-experiments should be stored.
-
setAllowParallelExecution
public void setAllowParallelExecution(boolean allowParallelExecution)
If this attribute is set totrue, sub-experiments will be executed concurrently in parallel. Setting this property tofalse(therefore using only a single CPU core) is sometimes useful for debugging purposes or when fine-grained control over parallelization of nested (multi-)experiments is required.- Parameters:
allowParallelExecution- Whether or not to allow parallel execution of sub-experiments.
-
isAllowParallelExecution
public boolean isAllowParallelExecution()
-
setCommonRandomNumbers
protected void setCommonRandomNumbers(boolean commonRandomNumbers)
Whether to use the variance reduction technique of common random numbers. If set to true, all sub-experiments are executed using the same random seed, so random influences will be the same for all sub-experiments. If set tofalse, all sub-experiments will be assigned a differentinitialSeed, depending only on this experiment'sinitialSeed.- Parameters:
commonRandomNumbers- Whether or not all sub-experiments are assigned the sameinitialSeed.
-
isCommonRandomNumbers
public boolean isCommonRandomNumbers()
-
setSkipSeedCount
public void setSkipSeedCount(int skipSeedCount)
Before starting, throw away this many seed values. This setting can be useful to resume interrupted sub-experiments.- Parameters:
skipSeedCount- The number of seeds to skip.
-
getSkipSeedCount
public int getSkipSeedCount()
-
setAbortUponBaseExperimentAbort
public void setAbortUponBaseExperimentAbort(boolean abortUponBaseExperimentAbort)
If set totrue, this experiment aborts immediately (indicating an abort in its results) after the first sub-experiment aborting. If this is set tofalse, execution of sub-experiments continues, ignoring aborting experiments.- Parameters:
abortUponBaseExperimentAbort- Whether or not to abort execution of sub-experiments upon the first execution error.
-
isAbortUponBaseExperimentAbort
public boolean isAbortUponBaseExperimentAbort()
-
isProduceAveragedResults
public boolean isProduceAveragedResults()
-
setProduceAveragedResults
public void setProduceAveragedResults(boolean produceAveragedResults)
Whether or not to produce averaged results across all sub-experiments as a result of this experiment.- Parameters:
produceAveragedResults- Whether or not to produce averaged results.
-
-