Configurable* GVTManagerFactory::allocate(SimulationConfiguration& configuration, Configurable* parent) const { Configurable* retval = 0; TimeWarpSimulationManager* mySimulationManager = dynamic_cast<TimeWarpSimulationManager*>(parent); ASSERT(mySimulationManager != NULL); // the following cases are possible: // (1) GVTManager is Mattern. In this is the case, we need to find // a GVT estimation period (if any; defaults to 1). Then // instantiate the MatternGVTStateManager with a state period (if // one is found). std::string gvtManagerType = configuration.get_string({"TimeWarp", "GVTManager", "Type"}, "Mattern"); std::string simulationType = configuration.get_string({"Simulation"}, "Sequential"); int gvtPeriod = configuration.get_int({"TimeWarp", "GVTManager", "Period"}, 1000); if (simulationType == "ThreadedTimeWarp") { if (gvtManagerType == "Mattern") { retval = new ThreadedMatternGVTManager( dynamic_cast<ThreadedTimeWarpSimulationManager*>(parent), gvtPeriod); debug::debugout << "(" << mySimulationManager->getSimulationManagerID() << ") configured a Mattern GVT Manager with period = " << gvtPeriod << endl; return retval; } else { mySimulationManager->shutdown("Unknown GVTManager choice \"" + gvtManagerType + "\""); } } if (gvtManagerType == "Mattern") { retval = new MatternGVTManager(mySimulationManager, gvtPeriod); debug::debugout << "(" << mySimulationManager->getSimulationManagerID() << ") configured a Mattern GVT Manager with period = " << gvtPeriod << endl; } else { mySimulationManager->shutdown( "Unknown GVTManager choice \"" + gvtManagerType + "\""); } return retval; }
Configurable * OptFossilCollManagerFactory::allocate(SimulationConfiguration &configuration, Configurable *parent) const { Configurable *retval = NULL; TimeWarpSimulationManager *mySimulationManager = dynamic_cast<TimeWarpSimulationManager *> (parent); ThreadedTimeWarpSimulationManager *myThreadedSimulationManager = dynamic_cast<ThreadedTimeWarpSimulationManager *> (parent); ASSERT( mySimulationManager != NULL ); // the following cases are possible: // (1) Manager is Cheby. // (2) None is used. if (configuration.optFossilCollManagerTypeIs("CHEBY")) { unsigned int checkpointPeriod = 1000; unsigned int minSamples = 64; unsigned int maxSamples = 100; unsigned int defaultLength = 2000; double riskFactor = 0.99; configuration.getOptFossilCollPeriod(checkpointPeriod); configuration.getOptFossilCollMinSamples(minSamples); configuration.getOptFossilCollMaxSamples(maxSamples); configuration.getOptFossilCollDefaultLength(defaultLength); configuration.getOptFossilCollRiskFactor(riskFactor); if (configuration.simulationTypeIs("ThreadedTimeWarp")) { retval = new ThreadedChebyFossilCollManager(myThreadedSimulationManager, checkpointPeriod, minSamples, maxSamples, defaultLength, riskFactor); myThreadedSimulationManager->setOptFossilColl(true); } else { retval = new ChebyFossilCollManager(mySimulationManager, checkpointPeriod, minSamples, maxSamples, defaultLength, riskFactor); mySimulationManager->setOptFossilColl(true); utils::debug << "(" << mySimulationManager->getSimulationManagerID() << ") configured a Cheby Optimistic Fossil Collection Manager " << "with checkpoint interval: " << checkpointPeriod << ", and risk factor: " << riskFactor << endl; } } else if (configuration.optFossilCollManagerTypeIs("NONE")) { retval = NULL; } else { mySimulationManager->shutdown( "Unknown FossilManager choice \"" + configuration.getGVTManagerType() + "\""); } return retval; }
Configurable* StateManagerFactory::allocate(SimulationConfiguration& configuration, Configurable* parent) const { StateManager* retval = 0; ThreadedStateManager* retvalue = 0; TimeWarpSimulationManager* mySimulationManager = dynamic_cast<TimeWarpSimulationManager*>(parent); ASSERT(mySimulationManager != 0); // the following cases are possible: // (1) StateManager is InfrequentStateManager. In this is the case, // we need to find a state period (if any; defaults to 1). Then // instantiate the InfrequentStateManager with a state period // (if one is found). // (2) StateManager is AdaptiveStateManager. In this case, we just // instantiate the AdaptiveStateManager and go on. std::string simulationType = configuration.get_string({"Simulation"}, "Sequential"); std::string stateManagerType = configuration.get_string({"TimeWarp", "StateManager", "Type"}, "Periodic"); int stateManagerPeriod = configuration.get_int({"TimeWarp", "StateManager", "Period"}, 10); if (simulationType == "ThreadedTimeWarp") { if (stateManagerType == "Periodic") { retvalue = new ThreadedPeriodicStateManager( dynamic_cast<ThreadedTimeWarpSimulationManager*>(parent), stateManagerPeriod); mySimulationManager->setStateMgrType(STATICSTATE); debug::debugout << "(" << mySimulationManager->getSimulationManagerID() << ") configured a Threaded Periodic State Manager with period = " << stateManagerPeriod << endl; return retvalue; } else if (stateManagerType == "Adaptive") { retvalue = new ThreadedCostAdaptiveStateManager( dynamic_cast<ThreadedTimeWarpSimulationManager*>(parent)); mySimulationManager->setStateMgrType(ADAPTIVESTATE); debug::debugout << "(" << mySimulationManager->getSimulationManagerID() << ") configured an Adaptive State Manager with period = " << stateManagerPeriod << endl; return retvalue; } else { mySimulationManager->shutdown("Unknown StateManager choice \"" + stateManagerType + "\""); } } if (stateManagerType == "Periodic") { retval = new PeriodicStateManager(mySimulationManager, stateManagerPeriod); mySimulationManager->setStateMgrType(STATICSTATE); debug::debugout << "(" << mySimulationManager->getSimulationManagerID() << ") configured a Periodic State Manager with period = " << stateManagerPeriod << endl; } else if (stateManagerType == "Adaptive") { retval = new CostAdaptiveStateManager(mySimulationManager); mySimulationManager->setStateMgrType(ADAPTIVESTATE); debug::debugout << "(" << mySimulationManager->getSimulationManagerID() << ") configured an Adaptive State Manager with period = " << stateManagerPeriod << endl; } else { mySimulationManager->shutdown("Unknown StateManager choice \"" + stateManagerType + "\""); } return retval; }