Tests that read() correctly parses a small instance with allowed clients for each vehicle.
()
| 431 | |
| 432 | |
| 433 | def test_reading_allowed_clients(): |
| 434 | """ |
| 435 | Tests that read() correctly parses a small instance with allowed clients |
| 436 | for each vehicle. |
| 437 | """ |
| 438 | data = read("data/OkSmallAllowedClients.txt") |
| 439 | assert_equal(data.num_vehicle_types, 2) |
| 440 | |
| 441 | veh_type1 = data.vehicle_type(0) |
| 442 | assert_equal(veh_type1.capacity, [10]) |
| 443 | assert_equal(veh_type1.num_available, 2) |
| 444 | assert_equal(veh_type1.profile, 0) |
| 445 | |
| 446 | distance_matrix = data.distance_matrix(veh_type1.profile) |
| 447 | duration_matrix = data.duration_matrix(veh_type1.profile) |
| 448 | |
| 449 | # First vehicle type has no vehicle-client restrictions. |
| 450 | assert_(np.all(distance_matrix != MAX_VALUE)) |
| 451 | assert_(np.all(duration_matrix != MAX_VALUE)) |
| 452 | |
| 453 | veh_type2 = data.vehicle_type(1) |
| 454 | assert_equal(veh_type2.capacity, [10]) |
| 455 | assert_equal(veh_type2.num_available, 1) |
| 456 | assert_equal(veh_type2.profile, 1) |
| 457 | |
| 458 | distance_matrix = data.distance_matrix(veh_type2.profile) |
| 459 | duration_matrix = data.duration_matrix(veh_type2.profile) |
| 460 | |
| 461 | # Second vehicle type is not allowed to serve client idx 4. |
| 462 | assert_equal(distance_matrix[:3, 4], MAX_VALUE) |
| 463 | assert_equal(distance_matrix[4, :3], MAX_VALUE) |
| 464 | assert_equal(duration_matrix[:3, 4], MAX_VALUE) |
| 465 | assert_equal(duration_matrix[4, :3], MAX_VALUE) |
| 466 | |
| 467 | |
| 468 | def test_sdvrptw_instance(): |