2024-09-30 02:32:46 发布
网友
在ortools中,我知道您可以使用每辆车的不同容量运行CVRP。但是,能否根据车辆传递不同的距离矩阵?例如,两个城市可能相距1000英里,但坐飞机到那里可能比坐汽车快得多,因此在进行CVRP工作时,我可能希望通过一个时间矩阵,而不是实际的距离矩阵。该时间矩阵将根据车辆类型而有所不同
应该接近这一点:
callback_indices = [] for vehicle_idx in range(data['n_vehicles']): def vehicle_callback(from_index, to_index, i=vehicle_idx): from_node = manager.IndexToNode(from_index) to_node = manager.IndexToNode(to_index) return data['vehicle_costs'][i] * data['time_matrices'][i][from_node][to_node] callback_index = routing.RegisterTransitCallback(vehicle_callback) callback_indices.append(callback_index) routing.AddDimensionWithVehicleTransits( callback_indices, 0, max, False, 'DimensionName')
您可以传递向量/评估器列表
这是C++ API/
应该接近这一点:
您可以传递向量/评估器列表
这是C++ API/
相关问题 更多 >
编程相关推荐