Exemplo n.º 1
0
 def _collectTravelTime(self) -> None:
     for vehicle in self._road.removed:
         time = min(self.simulator.steps - vehicle.start,
                    self._travelLimit - 1)
         if isCar(vehicle):
             self.travel[time] += 1
         if isAutonomous(vehicle):
             self.travel_autonomous[time] += 1
         if isConventional(vehicle):
             self.travel_conventional[time] += 1
Exemplo n.º 2
0
 def _collectVelocity(self) -> None:
     for vehicle in self._road.getAllActiveVehicles():
         last_x, _ = self._road.getAbsolutePosition(vehicle.last_position)
         cur_x, lane = self._road.getAbsolutePosition(vehicle.position)
         for x in range(last_x, cur_x):
             if x >= self._road.length:
                 continue
             value = AverageResult(value=vehicle.velocity, count=1)
             if isCar(vehicle):
                 self.velocity[lane][x] += value
             if isAutonomous(vehicle):
                 self.velocity_autonomous[lane][x] += value
             if isConventional(vehicle):
                 self.velocity_conventional[lane][x] += value
Exemplo n.º 3
0
 def test_isAutonomous(self):
     car = self.getVehicle(position=(0, 0))
     self.assertTrue(isAutonomous(car))
     vehicle = Vehicle(position=(0, 0), velocity=0)
     self.assertFalse(isAutonomous(vehicle))