public void add(ISimulationResults res) { foreach (ITrajectory t in res.getTrajectories()) { ITrajectoryBundle tb = null; if (!_tbundles.ContainsKey(t.Name)) { tb = new TrajectoryBundle(t.Name); _tbundles.Add(t.Name, tb); } else { tb = _tbundles[t.Name]; } tb.addTrajectory(t); } foreach (IAgentEvaluation ae in res.getAgentEvaluations()) { IAgentEvaluationBundle aeb = null; if (!_aebundles.ContainsKey(ae.Name)) { aeb = new AgentEvaluationBundle(ae.Name); _aebundles.Add(ae.Name, aeb); } else { aeb = _aebundles[ae.Name]; } aeb.addAgentEvaluation(ae); } }
public void AgentOrderbookLoaderTest() { Console.WriteLine("AgentOrderbookLoaderTest"); LoggerInitialization.SetThreshold(typeof(sim_tests), LogLevel.Debug); LoggerInitialization.SetThreshold(typeof(AbstractAgent), LogLevel.Info); LoggerInitialization.SetThreshold(typeof(AgentOrderbookLoader), LogLevel.Info); string PATH = "" + ApplicationConfig.EXECDIR + "orderbooks/orderbook.csv"; AgentOrderbookLoader loader = MakeAgentOrderbookLoader(PATH); SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "AgentOrderbookLoader: " + loader); IOrderbook_Observable ob = new Orderbook(); IPopulation pop = new Population(); pop.addAgent(loader); ISimulation sim = new Simulation(pop, ob, 0.0, 100.0); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Running Simulation"); ISimulationResults res = sim.run(); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Stopping Simulation"); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "ob: " + ob.ToStringLong()); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "res: " + res.ToStringLong()); Assert.AreEqual(res.Valid, true); }
public SimRunner(IMapFactory mapFactory, IVehicle vehicle, IPathPlanner pathPlanner, IReactivePathPlanner reactivePathPlanner, ISimulationResults simulationResults) { _mapFactory = mapFactory; _vehicle = vehicle; _pathPlanner = pathPlanner; _reactivePathPlanner = reactivePathPlanner; _simulationResults = simulationResults; }
public void Agent0x1Simulation_ZeroDimensional() { Console.WriteLine("Agent0x1Simulation_ZeroDimensional"); LoggerInitialization.SetThreshold(typeof(sim_tests), LogLevel.Debug); LoggerInitialization.SetThreshold(typeof(AbstractAgent), LogLevel.Info); LoggerInitialization.SetThreshold(typeof(AgentOrderbookLoader), LogLevel.Info); LoggerInitialization.SetThreshold(typeof(Agent0x0), LogLevel.Info); int dim = 0; string [] names = new string [0]; double [] mins = new double [0]; double [] maxs = new double [0]; IBlauSpace s = BlauSpace.create(dim, names, mins, maxs); IBlauPoint mean = new BlauPoint(s); IBlauPoint std = new BlauPoint(s); IDistribution d = new Distribution_Gaussian(s, mean, std); IAgentFactory afact = new Agent0x0_Factory(d); int NUMAGENTS = 10; IPopulation pop = PopulationFactory.Instance().create(afact, NUMAGENTS); foreach (IAgent ag in pop) { SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "agent: " + ag); } string PATH = "" + ApplicationConfig.EXECDIR + "orderbooks/orderbook.csv"; AgentOrderbookLoader loader = MakeAgentOrderbookLoader(PATH); pop.addAgent(loader); IOrderbook_Observable ob = new Orderbook(); string PROPERTY = "NetWorth"; IAgentEvaluationBundle aeb = new AgentEvaluationBundle(PROPERTY); // 1 hours ISimulation sim = new Simulation(pop, ob, 0.0, 3600.0); NamedMetricAgentEvaluationFactory metricEF = new NamedMetricAgentEvaluationFactory(PROPERTY); sim.add(metricEF); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Running Simulation"); ISimulationResults res = sim.run(); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Stopping Simulation"); IAgentEvaluation ae = metricEF.create(); aeb.addAgentEvaluation(ae); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "ob: " + ob.ToStringLong()); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "aeb: " + aeb.ToStringLong()); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "res: " + res.ToStringLong()); Assert.AreEqual(res.Valid, true); }
public TextFilePresentation(ISimulationResults results) { MaxNoOfSolutionsInOutput = 50; BoardSize = results.BoardSize; Solutions = new ObservableCollection <Solution>(results.Solutions); NoOfSolutions = Solutions.Count; ElapsedTimeInSec = results.ElapsedTimeInSec; NoOfSolutionsInOutput = Math.Min(NoOfSolutions, MaxNoOfSolutionsInOutput); }
public void Agent0x1Simulation_AgentTrajectories1() { Console.WriteLine("Agent0x1Simulation_AgentTrajectories1"); LoggerInitialization.SetThreshold(typeof(sim_tests), LogLevel.Debug); LoggerInitialization.SetThreshold(typeof(Agent0x0), LogLevel.Info); int dim = 0; string [] names = new string [0]; double [] mins = new double [0]; double [] maxs = new double [0]; IBlauSpace s = BlauSpace.create(dim, names, mins, maxs); IBlauPoint mean = new BlauPoint(s); IBlauPoint std = new BlauPoint(s); IDistribution d = new Distribution_Gaussian(s, mean, std); IAgentFactory afact = new Agent0x0_Factory(d); int NUMAGENTS = 10; IPopulation pop = PopulationFactory.Instance().create(afact, NUMAGENTS); foreach (IAgent ag in pop) { SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "agent: " + ag); } string PATH = "" + ApplicationConfig.EXECDIR + "orderbooks/orderbook.csv"; AgentOrderbookLoader loader = MakeAgentOrderbookLoader(PATH); pop.addAgent(loader); IOrderbook_Observable ob = new Orderbook(); // 1 hours ISimulation sim = new Simulation(pop, ob, 0.0, 3600.0); IAgent agent = PopulationSelector.Select(pop); ITrajectoryFactory agTF = new TrajectoryFactory_AgentOrders(agent, 10.0, 0.0); sim.add(agTF); ITrajectoryFactory agTF2 = new TrajectoryFactory_AgentNamedMetric(agent, "NetWorth", 10.0, 0.0); sim.add(agTF2); ITrajectoryFactory agTF3 = new TrajectoryFactory_AgentNamedMetric(agent, "NetWorth", 10.0, 0.99); sim.add(agTF3); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Running Simulation"); ISimulationResults res = sim.run(); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Stopping Simulation"); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Results\n" + res.ToStringLong()); Assert.AreEqual(res.Valid, true); }
public ISimulationResultsBundle run(int trials) { ISimulationResultsBundle resbundle = new SimulationResultsBundle(); for (int i = 0; i < trials; i++) { SingletonLogger.Instance().DebugLog(typeof(SimulationBundle), "Running Simulation trial " + i); ISimulation sim2 = MakeSimulation(i, trials); // Console.WriteLine("FFF Running trial "+i); // Console.WriteLine("FFF Simulation pop size "+sim2.Population.Size); ISimulationResults res2 = sim2.run(); // Console.WriteLine("FFF Done trial "+i); SingletonLogger.Instance().DebugLog(typeof(SimulationBundle), "Completed Simulation trial " + i); resbundle.add(res2); } return(resbundle); }
public void DummySimulation1() { Console.WriteLine("DummySimulation1"); LoggerInitialization.SetThreshold(typeof(sim_tests), LogLevel.Debug); LoggerInitialization.SetThreshold(typeof(AbstractAgent), LogLevel.Info); LoggerInitialization.SetThreshold(typeof(AgentDummy), LogLevel.Info); int dim = 3; string [] names = new string [3] { "x", "y", "z" }; double [] mins = new double [3] { 0.0, 0.0, 0.0 }; double [] maxs = new double [3] { 100.0, 100.0, 100.0 }; IBlauSpace s = BlauSpace.create(dim, names, mins, maxs); IBlauPoint mean = new BlauPoint(s); mean.setCoordinate(0, 10.0); mean.setCoordinate(1, 20.0); mean.setCoordinate(2, 30.0); IBlauPoint std = new BlauPoint(s); std.setCoordinate(0, 2.0); std.setCoordinate(1, 4.0); std.setCoordinate(2, 6.0); IDistribution d = new Distribution_Gaussian(s, mean, std); IAgentFactory afact = new AgentDummy_Factory(d); int NUMAGENTS = 100; IPopulation pop = PopulationFactory.Instance().create(afact, NUMAGENTS); foreach (IAgent ag in pop) { SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "agent: " + ag); } IOrderbook_Observable ob = new Orderbook(); string PROPERTY = "NetWorth"; IAgentEvaluationBundle aeb = new AgentEvaluationBundle(PROPERTY); ISimulation sim = new Simulation(pop.clone(), ob.clone(), 0.0, 100.0); NamedMetricAgentEvaluationFactory metricEF = new NamedMetricAgentEvaluationFactory(PROPERTY); sim.add(metricEF); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Running Simulation"); ISimulationResults res = sim.run(); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Stopping Simulation"); IAgentEvaluation ae = metricEF.create(); aeb.addAgentEvaluation(ae); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "aeb: " + aeb.ToStringLong()); SingletonLogger.Instance().DebugLog(typeof(sim_tests), "res: " + res.ToStringLong()); Assert.AreEqual(res.Valid, true); }