本文整理汇总了C++中ObjectID::getSimulationObjectID方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectID::getSimulationObjectID方法的具体用法?C++ ObjectID::getSimulationObjectID怎么用?C++ ObjectID::getSimulationObjectID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectID
的用法示例。
在下文中一共展示了ObjectID::getSimulationObjectID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveState
void CostAdaptiveStateManager::saveState(const VTime& currentTime, SimulationObject *object) {
ObjectID *currentObjectID = object->getObjectID();
unsigned int simObjectID = currentObjectID->getSimulationObjectID();
// The period is only recalculated after the specified number of events.
if (forwardExecutionLength[simObjectID] < eventsBetweenRecalculation[simObjectID]) {
forwardExecutionLength[simObjectID]++;
}
else{
calculatePeriod( object );
}
AdaptiveStateManagerBase::saveState(currentTime, object);
}
示例2: saveState
void ThreadedCostAdaptiveStateManager::saveState(const VTime& currentTime,
SimulationObject *object, int threadID) {
ObjectID *currentObjectID = object->getObjectID();
unsigned int simObjectID = currentObjectID->getSimulationObjectID();
// The period is only recalculated after the specified number of events.
if (forwardExecutionLength[simObjectID]
< eventsBetweenRecalculation[simObjectID]) {
forwardExecutionLength[simObjectID]++;
} else {
calculatePeriod(object);
}
if (periodCounter[simObjectID] <= 1) {
// we need to first allocate a state. Copy the current state into
// this newly created state. Then allocate a state object and
// fill in the current time and a pointer to the newly copied
// current state.
startStateTiming(simObjectID);
State *newState = object->allocateState();
newState->copyState(object->getState());
SetObject<State> stateObject(currentTime, newState);
// look up the state queue of the simulation object and insert the
// newly allocated state object
ThreadedStateManagerImplementationBase::getStateQueueLock(threadID,
simObjectID);
myStateQueue[simObjectID].insert(stateObject);
/*cout << "Saving at the Time Stamp :::::"
<< currentTime.getApproximateIntTime() << endl;*/
ThreadedStateManagerImplementationBase::releaseStateQueueLock(threadID,
simObjectID);
// reset period counter to state period
periodCounter[simObjectID] = objectStatePeriod[simObjectID];
stopStateTiming(simObjectID);
} else {
// decrement period counter
periodCounter[simObjectID] = periodCounter[simObjectID] - 1;
}
}
示例3: updateStateWhileCoastForward
void ThreadedCostAdaptiveStateManager::updateStateWhileCoastForward(
const VTime& currentTime, unsigned int eventNumber,
SimulationObject *object, const ObjectID senderId, int threadID) {
// store this object's id temporarily
OBJECT_ID *currentObjectID = object->getObjectID();
unsigned int simObjectID = currentObjectID->getSimulationObjectID();
if (mySimulationManager->isRollbackJustCompleted(simObjectID)) {
/*cout << "Last Rollback Time ::{{{{{{{{{{{{{{{{{}}}}}}}} "
<< *(lastRollbackTime[simObjectID]) << endl;*/
multiset<SetObject<State> >::iterator iter_end =
myStateQueue[simObjectID].end();
/*cout << "Current Num = " << eventNumber << "::::: Old Number = "
<< rollbackEventNumber[simObjectID] << endl;*/
if (*(lastRollbackTime[simObjectID]) == currentTime && eventNumber
<= rollbackEventNumber[simObjectID]) {
/*cout << " Need to update the Event Number in the state ::::"
<< eventNumber << endl;*/
ThreadedStateManagerImplementationBase::getStateQueueLock(threadID,
simObjectID);
State *newState = object->allocateState();
newState->copyState(object->getState());
SetObject<State> stateObject(currentTime, newState, eventNumber,
senderId.getSimulationObjectID(),
senderId.getSimulationObjectID());
//object->deallocateState((*iter_end).getElement());
//myStateQueue[simObjectID].erase(iter_end);
// look up the state queue of the simulation object and insert the
// newly allocated state object
myStateQueue[simObjectID].insert(stateObject);
ThreadedStateManagerImplementationBase::releaseStateQueueLock(
threadID, simObjectID);
}
mySimulationManager->resetRollbackCompletedStatus(simObjectID);
}
}
示例4: checkpoint
void ThreadedOptFossilCollManager::checkpoint(const VTime &checkTime,
const ObjectID &objId, const unsigned int &threadId) {
int time = checkTime.getApproximateIntTime();
int id = objId.getSimulationObjectID();
// If the time is less than the last checkpoint time, then save at the last
// checkpoint time again.
updateCheckpointTime(id, time);
while (time >= nextCheckpointTime[id]) {
utils::debug << mySimManager->getSimulationManagerID()
<< " - Checkpointing object " << id << " at " << time << endl;
int highestNextCheckpointTime = nextCheckpointTime[0];
for (int iter = 1; iter < mySimManager->getNumberOfSimulationObjects(); iter++) {
if (nextCheckpointTime[iter] > highestNextCheckpointTime)
highestNextCheckpointTime = nextCheckpointTime[iter];
}
vector<State *> *states;
if (nextCheckpointTime[id] == highestNextCheckpointTime) {
// No states have been check pointed for this time yet.
// Thus we create a state vector for all the objects
utils::debug << "Creating new states to be saved at time "
<< nextCheckpointTime[id] << endl;
states = new vector<State*> (
mySimManager->getNumberOfSimulationObjects(), NULL);
checkpointedStates.insert(
pair<int, vector<State*> *> (nextCheckpointTime[id], states));
} else {
// States have been saved for other objects but not this object at this time
// or a roll back in this object is causing this to happen.
utils::debug
<< "Adding the current state of the object to checkpointedStates "
<< nextCheckpointTime[id] << endl;
map<int, vector<State*>*>::iterator it = checkpointedStates.find(
nextCheckpointTime[id]);
states = it->second;
}
SimulationObject *object = mySimManager->getObjectHandle(objId);
// Save the state of the object at the checkpoint time.
State *newState = object->allocateState();
newState->copyState(object->getState());
(*states)[id] = newState;
lastCheckpointTime[id] = nextCheckpointTime[id];
nextCheckpointTime[id] += checkpointPeriod;
stringstream filename;
filename << ckptFilePath << "LP"
<< mySimManager->getSimulationManagerID() << "."
<< lastCheckpointTime[id] << "." << id;
ofstream ckFile(filename.str().c_str(), ofstream::binary);
if (!ckFile.is_open()) {
cerr << mySimManager->getSimulationManagerID()
<< " - Could not open file: " << filename.str()
<< ", aborting simulation." << endl;
abort();
}
mySimManager->getOutputManagerNew()->saveOutputCheckpoint(&ckFile,
objId, lastCheckpointTime[id], threadId);
ckFile.close();
}
}