observers.add(policyObserver);
List<String> blackList = new ArrayList<>();
blackList.add("SomeFactory");
// Configure experiment with given model, policy, etc.
BaseExperiment experiment = new BaseExperiment();
experiment.setModelLocation(new URI(modelLocation));
experiment.setBackupEnabled(false);
experiment.setRepeatRuns(replications);
experiment.setDefaultSimStopTime(stopTime);
// Define experiment
List<ExperimentVariable<?>> expModelVars =
new ArrayList<>();
expModelVars.add(new ExperimentVariable<>("someVariable",
new IncrementModifierInteger(3, 1, 5)));
expModelVars.add(new ExperimentVariable<>("anotherVariable",
new IncrementModifierInteger(1, 1, 2)));
experiment.setupVariables(expModelVars);
// Get all possible options
File optionFile = new File(OPTION_FILE);
List<ParameterBlock> options = null;
if (optionFile.exists()) {
options = (List<ParameterBlock>) Files.load(OPTION_FILE);
} else {
options = createParameterBlocks(modelLocation, blackList);
Files.save(options, OPTION_FILE);
}
// Set parameters of runner
policyParams.setValue(factory.getClass().getName());
ParameterBlock runnerParams = new ParameterBlock();
runnerParams
.addSubBl(AdaptiveTaskRunnerFactory.POLICY_OBSERVERS, observers)
.addSubBl(AdaptiveTaskRunnerFactory.POLICY, policyParams)
.addSubBl(AdaptiveTaskRunnerFactory.BLACK_LIST, blackList)
.addSubBl(AdaptiveTaskRunnerFactory.PORTFOLIO, options)
.addSubBl(ParallelComputationTaskRunnerFactory.NUM_CORES, 4);
experiment
.setTaskRunnerFactory(new ParameterizedFactory<TaskRunnerFactory>(
new AdaptiveTaskRunnerFactory(), runnerParams));
// Execute experiment
experiment.execute();
// Analyse and reset observer
policyObserver.reset();
}