public void add(IAgentEvaluationFactory evf, IAgentEvaluationConfig conf) { if (!_name2af.ContainsKey(evf.Name)) { _name2af.Add(evf.Name, evf); _aef2conf.Add(evf, conf); } }
public IBlauSpaceLattice getLattice(IDistribution d, IAgentEvaluationBundle aeb) { IAgentEvaluationFactory aef = null;; foreach (IAgentEvaluation iae in aeb.Evaluations) { aef = iae.Creator; break; } int[] steps = new int[d.SampleSpace.Dimension]; for (int j = 0; j < d.SampleSpace.Dimension; j++) { steps[j] = getAgentEvaluationConfig(aef).BlauSpaceGridding; } IBlauSpaceLattice bsl = BlauSpaceLattice.create(d.SampleSpace, steps); return(bsl); }
public IAgentEvaluationConfig getAgentEvaluationConfig(IAgentEvaluationFactory evf) { return(_aef2conf[evf]); }
public void add(IAgentEvaluationFactory af) { _aflist.Add(af); }
public override void run() { LoggerInitialization.SetThreshold(typeof(SingleDistributionExperiment), LogLevel.Debug); SingletonLogger.Instance().DebugLog(typeof(SingleDistributionExperiment), "run()"); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "distribution => " + theActualDistribution); IAgentFactory af = CreateAgentFactory(theActualDistribution, theTableConfig.AgentFactoryClassName); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "agent factory => " + theTableConfig.AgentFactoryClassName); af.Initialize(theTableConfig); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "creating initial orderbook"); IOrderbook_Observable ob = new Orderbook(); /* No Burnin at this point * * SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Executing burnin..."); * IPopulation popburn = CreatePopulation(af, theTableConfig.NumAgents, Path.Combine(ApplicationConfig.ROOTDIR, theTableConfig.InitialOrderbook)); * ISimulation simburn = new Simulation(popburn, ob, 0.0, COMMON_BURNIN_TIME_SECONDS, false, "burnin") ; * ISimulationResults resultsburn = simburn.run(); * ob = (IOrderbook_Observable)simburn.Orderbook; * SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Done with burnin."); */ ISimulationBundle accumulated_simb = null; ISimulationResultsBundle accumulated_resb = null; for (int popi = 0; popi < theTableConfig.Populations; popi++) { SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "creating population... " + theTableConfig.NumAgents); // Populations all contain an OrderBookLoader agent IPopulation pop = CreatePopulation(af, theTableConfig.NumAgents, Path.Combine(ApplicationConfig.ROOTDIR, theTableConfig.InitialOrderbook)); // SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "done."); string popname = POP_FILE_PREFIX + "." + popi + ".Validation"; string poppath = Path.Combine(_popdir, popname); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "population " + popi + " => " + poppath); savePopulation(poppath, pop); _simb = new SimulationBundle(pop, ob, 0.0, theTableConfig.DurationHours * 3600.0, LOG_FRAMES, "pop-" + popi); if (accumulated_simb == null) { accumulated_simb = _simb; } foreach (TrajectoryFactoryConfig tfc in theTrajConfig.getTrajectories()) { IPassiveTrajectoryFactory tf = CreatePassiveTrajectoryFactory(tfc); tf.Initialize(theTableConfig); _simb.add(tf); } /* * foreach (IAgent ag in pop) { * if (ag is IAgent_NonParticipant) continue; * * _simb.add (new TrajectoryFactory_AgentNamedMetric(ag, Agent1x0.NetWorth_METRICNAME, 1.0, 0.0)); * } */ double MAX_ALPHA = 0.10; double TEMPORAL_GRANULARITY_FOR_ALPHA_SLICES = 1.0; for (double alpha = 0.0; alpha <= MAX_ALPHA; alpha += MAX_ALPHA / (double)theTableConfig.NumCombs) { TrajectoryFactory_AlphaSlice tf = new TrajectoryFactory_AlphaSlice(TEMPORAL_GRANULARITY_FOR_ALPHA_SLICES, 0.0, alpha, true); tf.Initialize(theTableConfig); _simb.add(tf); TrajectoryFactory_AlphaSlice tf2 = new TrajectoryFactory_AlphaSlice(TEMPORAL_GRANULARITY_FOR_ALPHA_SLICES, 0.0, alpha, false); tf2.Initialize(theTableConfig); _simb.add(tf2); } foreach (AgentEvaluationConfig aefc in theAgentEvaluationFactorySetConfig.getAgentEvaluations()) { IAgentEvaluationFactory aef = CreateAgentEvaluationFactory(aefc); _simb.add(aef, aefc); } _resb = _simb.run(theTableConfig.Trials); //popname = POP_FILE_PREFIX+"."+popi+".Validation-Post"; //poppath = Path.Combine(_popdir, popname); //SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "population post "+popi+" => "+poppath); //savePopulation(poppath, pop); if (accumulated_resb == null) { accumulated_resb = _resb; } else { accumulated_resb.add(_resb); } //WriteTrajectories(popi, _simb, _resb); } //WriteTrajectories(-1, accumulated_simb, accumulated_resb); PresentationConfig.Directory = Path.Combine(OutputDirectory, "results"); if (!Directory.Exists(PresentationConfig.Directory)) { Directory.CreateDirectory(PresentationConfig.Directory); } Latex.ClearImages(); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Writing BlauSpaceEvaluations."); foreach (IAgentEvaluationBundle aeb in accumulated_resb.getAgentEvaluationBundles()) { IBlauSpaceLattice bsl = accumulated_simb.getLattice(theActualDistribution, aeb); IBlauSpaceEvaluation meanEval = aeb.MeanEvaluation(bsl); IBlauSpaceEvaluation stdEval = aeb.StdEvaluation(bsl); BlauSpaceEvaluationGnuplotPresenter pres = new BlauSpaceEvaluationGnuplotPresenter(_bsedir, PresentationConfig.Directory); pres.Present(this, meanEval, stdEval); } SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Writing TrajectoryBundles."); foreach (ITrajectoryBundle tb in accumulated_resb.getTrajectoryBundles()) { TrajectoryBundleGnuplotPresenter pres = new TrajectoryBundleGnuplotPresenter(_trajdir, PresentationConfig.Directory); pres.Present(this, tb); } SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Writing Latex."); Latex.Instance().Present(this); CreateReport(this); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Done."); }
public AgentEvaluation(string name, IAgentEvaluationFactory creator) { _name = name; _creator = creator; _evaluationData = new Dictionary <IAgent, double>(); }