Tests that initialising the model from a data instance results in a valid model representation of that data instance.
(small_cvrp)
| 283 | |
| 284 | |
| 285 | def test_from_data(small_cvrp): |
| 286 | """ |
| 287 | Tests that initialising the model from a data instance results in a valid |
| 288 | model representation of that data instance. |
| 289 | """ |
| 290 | m = Model.from_data(small_cvrp) |
| 291 | m_data = m.data() |
| 292 | |
| 293 | # We can first check if the overall problem dimension numbers agree. |
| 294 | assert_equal(m_data.num_clients, small_cvrp.num_clients) |
| 295 | assert_equal(m_data.num_vehicles, small_cvrp.num_vehicles) |
| 296 | assert_equal( |
| 297 | m_data.vehicle_type(0).capacity, |
| 298 | small_cvrp.vehicle_type(0).capacity, |
| 299 | ) |
| 300 | |
| 301 | assert_equal(m_data.distance_matrices(), small_cvrp.distance_matrices()) |
| 302 | assert_equal(m_data.duration_matrices(), small_cvrp.duration_matrices()) |
| 303 | |
| 304 | |
| 305 | def test_from_data_and_solve(small_cvrp, ok_small): |