void evaluate (const pathNode &pred,double cargoLimit){  
        distPrev=distance(pred);      //vehicle last move
        totDist=pred.gettotDist();
        twv=lateArrival(totDist);     //Time Window Violation
             
        waitTime=earlyArrival(totDist)? opens()-totDist:0;
        totDist+=waitTime+getServiceTime(); //totDist=opens()   should gice the same result

        cargo=pred.getcargo()+getdemand();       //loading or unloading 
        cv= cargo>cargoLimit or cargo < 0;  //capacity Violation
        twvTot = (twv)? pred.twvTot+pred.twvTot:pred.twvTot;
        cvTot = (cv)? pred.cvTot+1:pred.cvTot;
   };
示例#2
0
void GateProcessor::beginService( Person *aPerson, ElapsedTime curTime )
{
	if(m_emGateType == DepGate)
	{
		//get linkage processor
		if(m_vGateGroupIndex.size() > 0)
		{
			ElapsedTime nextAvailableTime = curTime;

			ElapsedTime eSafeTime = ElapsedTime(10L);

			//get linkage gate processor
			int nGateCount = static_cast<int>(m_vGateGroupIndex.size());
			for( int i = 0; i < nGateCount; ++ i)
			{
				GroupIndex gpIndex = m_vGateGroupIndex[i];
				for (int i = gpIndex.start; i <= gpIndex.end; i++)
				{
					Processor *pProc = m_pTerm->procList->getProcessor(i);
					if(pProc == NULL || pProc->getProcessorType() != GateProc)
						break;

					GateProcessor *gateProc = (GateProcessor *)m_pTerm->procList->getProcessor(i);
					//get the last person walk out of the service point, if have out constraint, compare two time, use lager one
					ElapsedTime eLastServiceTime =	gateProc->GetLastServicePaxTime();
					ElapsedTime eLastOurConsTime = gateProc->GetLastPaxOutConsTime();
					ElapsedTime eLastTime = eLastServiceTime;
					if(eLastOurConsTime >eLastServiceTime)
						eLastTime = eLastOurConsTime;

					if( nextAvailableTime >= eSafeTime + eLastTime)
					{
						//if the next available time is fit the safe time range, check the queue has person or not
						//if have ,wait 10 seconds and check it again
						if(gateProc->getTotalQueueLength() > 0)
						{
							nextAvailableTime += eSafeTime;
							break;
						}

					}
					else// if not fit, wait more 10 seconds and check it again
					{
						nextAvailableTime = eSafeTime + eLastTime;
					}
				}
			}

			//can go through 
			if(curTime >= nextAvailableTime)
			{
				aPerson->regetAttatchedNopax();
				// determine service time, based on the Person's type
				ElapsedTime serviceTime;

				serviceTime = getServiceTime(aPerson,curTime);
				aPerson->generateEvent (curTime+serviceTime,false);
				writeLogEvent (aPerson, curTime, BeginService);
				
				m_eLastPaxServiceTime = curTime + serviceTime;
			}
			else
			{
				aPerson->setState(ArriveAtServer);
				aPerson->generateEvent(nextAvailableTime,false);
			}
		}
		else
		{
			aPerson->regetAttatchedNopax();
			// determine service time, based on the Person's type
			ElapsedTime serviceTime;

			serviceTime = getServiceTime(aPerson,curTime);
			aPerson->generateEvent (curTime+serviceTime,false);
			writeLogEvent (aPerson, curTime, BeginService);
			
			m_eLastPaxServiceTime = curTime + serviceTime;
			
			//Processor::beginService(aPerson,curTime);
		}
	}
	else
	{		
		aPerson->regetAttatchedNopax();
		// determine service time, based on the Person's type
		ElapsedTime serviceTime;

		serviceTime = getServiceTime(aPerson,curTime);
		aPerson->generateEvent (curTime+serviceTime,false);
		writeLogEvent (aPerson, curTime, BeginService);
		//Processor::beginService(aPerson,curTime);

		m_eLastPaxServiceTime = curTime + serviceTime;

	}
}
示例#3
0
 int64 Matrix::  distancePlusServiceTime(RoutingModel::NodeIndex from, RoutingModel::NodeIndex to) {
     return Distance(from, to) + getServiceTime(from.value());
 }