/// <summary> /// Exports the results to the specified path. /// </summary> /// <param name="path"></param> /// <param name="result"></param> private void ExportResults(string path, SimulationResult result) { //Dump snapshots if enabled if (_conf.ExportSnapshots) { var snapshotsFile = new StreamWriter(path + "/snapshots.csv", false); var csv = new CsvWriter(snapshotsFile); csv.Configuration.Delimiter = ";"; csv.WriteHeader <StatisticSnapshot>(); csv.NextRecord(); csv.WriteRecords(_statisticSnapshots); csv.NextRecord(); csv.Flush(); snapshotsFile.Flush(); } //Dump routing tables if enabled if (_conf.EnableDumpRoutingTables) { _constellation.PrintRoutingTables(path); } ResultOutputter.DumpResults(new List <SimulationResult> { result }, path, "/statistics.txt"); _conf.ExportConfiguration(path); }
/// <summary> /// Start the simulation. Results are automatically exported at the end of the simulation. /// Will run for the specified amount of simulation iterations. /// </summary> public void Start() { var simulationPath = "results/" + _conf.SimulationGroup + "/" + _conf.SimulationName; for (var i = 1; i <= _conf.NumberOfSimulationIterations; i++) { _statistics.NewSimulation(); _conf.OutputPath = "results/" + _conf.SimulationGroup + "/" + _conf.SimulationName + "/run " + i; Directory.CreateDirectory(_conf.OutputPath); Console.WriteLine("Running " + _conf.SimulationName + ", iteration " + i + " of " + _conf.NumberOfSimulationIterations); var result = Run(); ExportResults(_conf.OutputPath, result); } ResultOutputter.DumpResults(_statistics.GetResults(), simulationPath, "average-statistics.txt"); }