当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectID::getSimulationObjectID方法代码示例

本文整理汇总了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);
}
开发者ID:CindyYang85,项目名称:pdes,代码行数:14,代码来源:CostAdaptiveStateManager.cpp

示例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;
	}
}
开发者ID:CindyYang85,项目名称:pdes,代码行数:41,代码来源:ThreadedCostAdaptiveStateManager.cpp

示例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);
	}
}
开发者ID:CindyYang85,项目名称:pdes,代码行数:36,代码来源:ThreadedCostAdaptiveStateManager.cpp

示例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();
	}
}
开发者ID:putnampp,项目名称:pdes,代码行数:68,代码来源:ThreadedOptFossilCollManager.cpp


注:本文中的ObjectID::getSimulationObjectID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。