Beispiel #1
0
 def checkBoarding(self):
     step = vehicleControl.getStep()
     wait = 0
     running = []
     for task in self.running:
         if task.target == self.position:
             statistics.personUnloaded(task.person.id, step)
             self.load -= 1
             wait += WAIT_PER_PERSON
             self.costMatrix[(task.source,
                              task.target)] = step - task.startStep
             self.totalEstimatedCost -= task.estCost
         else:
             running.append(task)
     self.running = running
     if self.load < vehicleControl.getCapacity():
         tasks = []
         for task in self.tasks:
             if task.source == self.position and self.load < vehicleControl.getCapacity(
             ):
                 vehicleControl.leaveStop(task.person.id)
                 statistics.personLoaded(task.person.id, step)
                 self.load += 1
                 wait += WAIT_PER_PERSON
                 task.startStep = step
                 self.running.append(task)
             else:
                 tasks.append(task)
         self.tasks = tasks
     self._findNextTarget(wait)
 def checkBoarding(self):
     step = vehicleControl.getStep()
     wait = 0
     running = []
     for task in self.running:
         if task.target == self.position:
             statistics.personUnloaded(task.person.id, step)
             self.load -= 1
             wait += WAIT_PER_PERSON
             self.costMatrix[(task.source, task.target)] = step - task.startStep
             self.totalEstimatedCost -= task.estCost
         else:
             running.append(task)
     self.running = running
     if self.load < vehicleControl.getCapacity(): 
         tasks = []
         for task in self.tasks:
             if task.source == self.position and self.load < vehicleControl.getCapacity():
                 vehicleControl.leaveStop(task.person.id)
                 statistics.personLoaded(task.person.id, step)
                 self.load += 1
                 wait += WAIT_PER_PERSON
                 task.startStep = step
                 self.running.append(task)
             else:
                 tasks.append(task)
         self.tasks = tasks
     self._findNextTarget(wait)
Beispiel #3
0
 def cyberCarArrived(self, vehicleID, edge):
     step = vehicleControl.getStep()
     footEdge = edge.replace("cyber", "footmain")
     wait = 0
     load = []
     for person, target in self.cyberCarLoad.get(vehicleID, []):
         if target == footEdge:
             statistics.personUnloaded(person, step)
             wait += WAIT_PER_PERSON
         else:
             load.append((person, target))
     while self.personsWaitingAt.get(footEdge, []) and len(load) < vehicleControl.getCapacity():
         person, target = self.personsWaitingAt[footEdge].pop(0)
         vehicleControl.leaveStop(person)
         statistics.personLoaded(person, step)
         load.append((person, target))
         wait += WAIT_PER_PERSON
     vehicleControl.leaveStop(vehicleID, delay=wait)
     if edge == "cyberout" or edge == "cyberin":
         row = -1
     else:
         row = int(edge[5])
     if row < DOUBLE_ROWS - 1:
         vehicleControl.stopAt(
             vehicleID, "cyber%sto%s" % (row + 1, row + 2))
     else:
         vehicleControl.stopAt(vehicleID, "cyberout")
     self.cyberCarLoad[vehicleID] = load
Beispiel #4
0
 def cyberCarArrived(self, vehicleID, edge):
     step = vehicleControl.getStep()
     footEdge = edge.replace("cyber", "footmain")
     wait = 0
     load = []
     for person, target in self.cyberCarLoad.get(vehicleID, []):
         if target == footEdge:
             statistics.personUnloaded(person, step)
             wait += WAIT_PER_PERSON
         else:
             load.append((person, target))
     while self.personsWaitingAt.get(
             footEdge, []) and len(load) < vehicleControl.getCapacity():
         person, target = self.personsWaitingAt[footEdge].pop(0)
         vehicleControl.leaveStop(person)
         statistics.personLoaded(person, step)
         load.append((person, target))
         wait += WAIT_PER_PERSON
     vehicleControl.leaveStop(vehicleID, delay=wait)
     if edge == "cyberout" or edge == "cyberin":
         row = -1
     else:
         row = int(edge[5])
     if row < DOUBLE_ROWS - 1:
         vehicleControl.stopAt(vehicleID,
                               "cyber%sto%s" % (row + 1, row + 2))
     else:
         vehicleControl.stopAt(vehicleID, "cyberout")
     self.cyberCarLoad[vehicleID] = load
Beispiel #5
0
 def _findNextTarget(self, wait):
     minTarget = "z"
     minDownstreamTarget = "z"
     minSource = "z"
     minDownstreamSource = "z"
     edge = vehicleControl.getPosition(self.id)
     if edge == "cyberin":
         edge = "cyber"
     for task in self.running:
         if task.target < minTarget:
             minTarget = task.target
         if task.target < minDownstreamTarget and task.target > edge:
             minDownstreamTarget = task.target
     for task in self.tasks[:vehicleControl.getCapacity() - self.load]:
         if task.source < minSource:
             minSource = task.source
         if task.source < minDownstreamSource and task.source > edge:
             minDownstreamSource = task.source
     if minDownstreamTarget != "z":
         minTarget = minDownstreamTarget
     elif minDownstreamSource < minTarget:
         minTarget = minDownstreamSource
     elif minTarget < edge and minSource < minTarget:
         minTarget = minSource
     if minTarget == "z":
         minTarget = "cyberin"
     if minTarget != vehicleControl.getPosition(self.id):
         vehicleControl.leaveStop(self.id, delay=wait)
         vehicleControl.stopAt(self.id, minTarget)
 def _findNextTarget(self, wait):
     minTarget = "z"
     minDownstreamTarget = "z"
     minSource = "z"
     minDownstreamSource = "z"
     edge = vehicleControl.getPosition(self.id)
     if edge == "cyberin":
         edge = "cyber"
     for task in self.running:
         if task.target < minTarget:
             minTarget = task.target
         if task.target < minDownstreamTarget and task.target > edge:
             minDownstreamTarget = task.target
     for task in self.tasks[:vehicleControl.getCapacity() - self.load]:
         if task.source < minSource:
             minSource = task.source
         if task.source < minDownstreamSource and task.source > edge:
             minDownstreamSource = task.source
     if minDownstreamTarget != "z":
         minTarget = minDownstreamTarget 
     elif minDownstreamSource < minTarget:
         minTarget = minDownstreamSource
     elif minTarget < edge and minSource < minTarget:
         minTarget = minSource
     if minTarget == "z":
         minTarget = "cyberin"
     if minTarget != vehicleControl.getPosition(self.id):
         vehicleControl.leaveStop(self.id, delay=wait)
         vehicleControl.stopAt(self.id, minTarget)