MCPcopy Index your code
hub / github.com/PyVRP/PyVRP / test_adding_multiple_routing_profiles

Function test_adding_multiple_routing_profiles

tests/test_Model.py:827–867  ·  view source on GitHub ↗

Tests that adding multiple routing profiles to the model works, and the solver finds the optimal solution.

()

Source from the content-addressed store, hash-verified

825
826
827def test_adding_multiple_routing_profiles():
828 """
829 Tests that adding multiple routing profiles to the model works, and the
830 solver finds the optimal solution.
831 """
832 m = Model()
833
834 profile1 = m.add_profile()
835 assert_(m.profiles[0] is profile1)
836
837 profile2 = m.add_profile()
838 assert_(m.profiles[1] is profile2)
839
840 veh_type1 = m.add_vehicle_type(profile=profile1)
841 assert_equal(veh_type1.profile, 0)
842
843 veh_type2 = m.add_vehicle_type(profile=profile2)
844 assert_equal(veh_type2.profile, 1)
845
846 m.add_depot(x=1, y=1)
847 m.add_client(x=2, y=2)
848
849 for frm in m.locations:
850 for to in m.locations:
851 if frm != to:
852 m.add_edge(frm, to, distance=10, duration=5, profile=profile1)
853 m.add_edge(frm, to, distance=5, duration=10, profile=profile2)
854
855 data = m.data()
856 assert_equal(data.num_profiles, 2)
857
858 # Check that the distance and duration matrices of both profiles are
859 # defined correctly.
860 assert_equal(data.distance_matrix(profile=0), [[0, 10], [10, 0]])
861 assert_equal(data.duration_matrix(profile=0), [[0, 5], [5, 0]])
862 assert_equal(data.distance_matrix(profile=1), [[0, 5], [5, 0]])
863 assert_equal(data.duration_matrix(profile=1), [[0, 10], [10, 0]])
864
865 res = m.solve(stop=MaxIterations(10))
866 assert_(res.is_feasible())
867 assert_equal(res.cost(), 10)
868
869
870def test_profiles_build_on_base_edges():

Callers

nothing calls this directly

Calls 11

add_profileMethod · 0.95
add_vehicle_typeMethod · 0.95
add_depotMethod · 0.95
add_clientMethod · 0.95
add_edgeMethod · 0.95
dataMethod · 0.95
solveMethod · 0.95
ModelClass · 0.90
MaxIterationsClass · 0.90
is_feasibleMethod · 0.80
costMethod · 0.45

Tested by

no test coverage detected