コード例 #1
0
    def setUp(self) -> None:
        self.vehicle = generate_one_vehicle()
        self.position = generate_one_position()
        stop0 = jit.Stop(self.vehicle, self.position, None)

        stop1 = jit.Stop(self.vehicle, generate_one_position(), stop0)
        stop0.following = stop1

        stop2 = jit.Stop(self.vehicle, generate_one_position(), stop1)
        stop1.following = stop2

        stop3 = jit.Stop(self.vehicle, generate_one_position(), stop2)
        stop2.following = stop3

        stop4 = jit.Stop(self.vehicle, generate_one_position(), stop3)
        stop3.following = stop4

        stops = [stop0, stop1, stop2, stop3, stop4]
        self.stops = stops

        self.route = jit.Route(self.vehicle, self.stops)
        self.planning = jit.Planning({self.route})

        self.job = jit.Job(generate_trips(10), objective_cls=jit.DialARideObjective)
        self.fleet = jit.Fleet(generate_vehicles(10))
        self.algorithm = jit.NaiveAlgorithm(self.fleet, self.job)
        self.result = jit.Result(self.algorithm, self.planning, computation_time=float(0.0))
コード例 #2
0
 def test_as_tuple(self):
     planning = jit.Planning(self.routes)
     expected = (
         ("uuid", planning.uuid),
         ("route_identifiers",
          tuple(route.identifier for route in self.routes)),
     )
     self.assertEqual(expected, tuple(planning))
コード例 #3
0
ファイル: utils.py プロジェクト: garciparedes/jinete
def generate_one_planning(routes_count: int = None,
                          routes_count_min: int = 1,
                          routes_count_max: int = 100,
                          *args,
                          **kwargs) -> jit.Planning:
    if routes_count is None:
        routes_count = randint(routes_count_min, routes_count_max)
    trips = generate_routes(routes_count, *args, **kwargs)
    planning = jit.Planning(trips)
    return planning
コード例 #4
0
ファイル: abc.py プロジェクト: garciparedes/jinete
    def setUpClass(cls) -> None:
        surface = jit.GeometricSurface(jit.DistanceMetric.MANHATTAN)
        origin = jit.Service(surface.get_or_create_position([0, 0]))
        vehicle = jit.Vehicle(
            identifier="TEST",
            origin=origin,
        )
        fleet = jit.Fleet({vehicle})

        trips = [
            jit.Trip(
                identifier="TEST_1",
                origin=jit.Service(
                    position=surface.get_or_create_position([0, 0]),
                    earliest=0.0,
                    latest=10.0,
                ),
                destination=jit.Service(
                    position=surface.get_or_create_position([1, 1]), ),
            ),
            jit.Trip(
                identifier="TEST_2",
                origin=jit.Service(
                    position=surface.get_or_create_position([1, 1]),
                    earliest=0.0,
                    latest=20.0,
                ),
                destination=jit.Service(
                    position=surface.get_or_create_position([10, 10]), ),
            ),
        ]
        job = jit.Job(set(trips), jit.DialARideObjective)
        route = jit.Route(vehicle)

        pickup_stop = jit.Stop(vehicle, surface.get_or_create_position([0, 0]),
                               route.current_stop)
        delivery_stop = jit.Stop(vehicle,
                                 surface.get_or_create_position([1, 1]),
                                 pickup_stop)

        cls.planned_trip = jit.PlannedTrip(
            vehicle=vehicle,
            trip=trips[0],
            pickup=pickup_stop,
            delivery=delivery_stop,
        )
        route.append_planned_trip(cls.planned_trip)

        cls.stop = route.stops[1]
        conjecture = jit.TailInsertionStrategy()
        cls.route = conjecture.compute(route, trips[1])[0]
        cls.planning = jit.Planning({cls.route})
        cls.algorithm = jit.NaiveAlgorithm(fleet, job)
        cls.result = jit.Result(cls.algorithm, cls.planning, 0.0)
コード例 #5
0
    def test_construction(self):
        planning = jit.Planning(self.routes)

        self.assertIsInstance(planning, jit.Planning)
        self.assertIsNotNone(planning.uuid)
        self.assertIsInstance(planning.uuid, UUID)
        self.assertIsNotNone(planning.routes)
        self.assertIsInstance(planning.routes, set)

        self.assertTrue(
            all(isinstance(route, jit.Route) for route in planning.routes))
        self.assertEqual(planning.routes, self.routes)
コード例 #6
0
    def test_deepcopy(self):
        planning = jit.Planning(self.routes)

        copied_planning = deepcopy(planning)
        self.assertNotEqual(planning, copied_planning)
        self.assertNotEqual(id(planning), id(copied_planning))
        self.assertNotEqual(planning.uuid, copied_planning.uuid)
        self.assertEqual(len(planning.routes), len(copied_planning.routes))
        self.assertTrue(planning.routes.isdisjoint(copied_planning.routes))
        for route in planning.routes:
            assert any(
                set(route.trips).isdisjoint(copied_route.trips)
                for copied_route in copied_planning.routes)
コード例 #7
0
 def test_trips(self):
     planning = jit.Planning(self.routes)
     self.assertEqual(list(planning.trips), self.trips)
コード例 #8
0
 def test_loaded_routes(self):
     planning = jit.Planning(self.routes)
     self.assertEqual(planning.loaded_routes, self.loaded_routes)