Topics to be covered here are examples in package examples.experiments.running from project_template_standalone

  • RunExistingExperiment: setting parameter, executing, inspecting results

  • RunExistingExperimentExcelOutput: produce Excel output

  • RunMultipleReplications: perform multiple independent replications of any base experiment

  • RunParameterCombinations: test different parameter settings

Running An Experiment

Running an existing experiment (see RunExistingExperiment.java)
		// create experiment and set parameter
		DynamicShopExperiment dse = new DynamicShopExperiment();
		dse.setInitialSeed(23);
		dse.setNumMachines(10);
		dse.setUtilLevel(0.85);

		// run experiment
		Map<String, Object> res = dse.runExperiment();

		// show results on the console, SummaryStats first, then normal values
		dse.printResults();

		// we can also access individual results by their name and so something with
		// them
		SummaryStat flowtimes = (SummaryStat) res.get("flowtime");
		String msg = String.format(ENGLISH, "experiment finished %d jobs with an average flowtime of %.1f minutes.",
				flowtimes.numObs(), flowtimes.mean());
		System.out.println();
		System.out.println(msg);

Creating Excel Output

Add a listener to create Excel output (see RunExistingExperimentExcelOutput.java)
		// create experiment and set parameter
		DynamicShopExperiment dse = new DynamicShopExperiment();
		dse.setInitialSeed(23);
		dse.setNumMachines(10);
		dse.setUtilLevel(0.85);
		
		// NEW: add ExcelSaver
		dse.addListener(new ExcelSaver("dseResults")); (1)

		// run experiment
		dse.runExperiment();

		// show results on the console, SummaryStats first, then normal values
		dse.printResults();
1 add ExcelSaver to produce an Excel file

Multiple Replications

Running multiple independent replications (see RunMultipleReplications.java)
		// create base experiment, set default parameters; initialSeed is varied
		// automatically by the MultipleReplicationExperiment created below
		DynamicShopExperiment dse = new DynamicShopExperiment();
		dse.setNumMachines(10);
		dse.setUtilLevel(0.85);

		// create a MultipleReplicationExperiment executing the base experiment "dse" 10
		// times
		MultipleReplicationExperiment mre = new MultipleReplicationExperiment(dse, 10);

		// report results as Excel file
		mre.addListener(new ExcelSaver("mreResults"));

		// run and print averaged results over all 10 replications
		mre.runExperiment();
		mre.printResults();

Testing Various Parameter Settings

Running different parameter configurations (see RunParameterCombinations.java)
		// create base experiment, set default parameters; initialSeed and created below
		DynamicShopExperiment dse = new DynamicShopExperiment(); 
		dse.setNumMachines(10);

		// create a MultipleReplicationExperiment executing the base experiment "dse" 15
		// times (all combinations of utilLevel and initialSeed)
		FullFactorialExperiment ffe = new FullFactorialExperiment(dse);
		ffe.addFactor("utilLevel", 0.8, 0.85, 0.9);
		ffe.addFactor("initialSeed", 1, 2, 3, 4, 5);

		// report results as Excel file
		ffe.addListener(new ExcelSaver("ffeResults"));

		// run and print averaged results over all 10 replications
		ffe.runExperiment();
		ffe.printResults();