Tests that adding multiple routing profiles to the model works, and the solver finds the optimal solution.
()
| 825 | |
| 826 | |
| 827 | def 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 | |
| 870 | def test_profiles_build_on_base_edges(): |
nothing calls this directly
no test coverage detected