[英]Ambulance rescue as vehicle routing (capacitated, time bound)
Here's the problem that I'm trying to solve: 这是我要解决的问题:
I'm trying to use jsprit for solving this problem and can't figure out how to do the following: (I want to know what part of the API should I look into) 我正在尝试使用jsprit解决此问题,但无法弄清楚如何执行以下操作:(我想知道我应该研究API的哪一部分)
1) Specifying that there are finite ambulances, but they can go on multiple trips. 1)指定有有限的救护车,但它们可以多次旅行。
2) Constraining the patients to be delivered to the hospital before they die, or leave them. 2)限制患者在死亡或离开医院之前被送往医院。
3) Adding a 1 minute unload time for any ambulance reaching a hospital for deliveries. 3)对于到达医院进行分娩的任何救护车,增加1分钟的卸载时间。
4) Let the ambulances choose better routes by letting them deliver patients to any hospital. 4)让救护车将病人送至任何医院,从而选择更好的路线。
Here's my code until now: 到目前为止,这是我的代码:
// make vehicle routing problem builder
VehicleRoutingProblem.Builder vrpBuilder =
VehicleRoutingProblem.Builder.newInstance();
// make vehicle type
VehicleTypeImpl.Builder vehicleTypeBuilder =
VehicleTypeImpl.Builder.newInstance("ambulanceWithFourBeds")
.addCapacityDimension(0, 4);
VehicleType vehicleType = vehicleTypeBuilder.build();
// putting multiple vehicles at every hospital
List<Location> locations = state.getVehicleLocations();
int counter = 0;
for (Location location : locations) {
VehicleImpl.Builder vehicleBuilder =
VehicleImpl.Builder.newInstance("ambulance_" + counter++);
vehicleBuilder.setStartLocation(location);
vehicleBuilder.setType(vehicleType);
vrpBuilder.addVehicle(vehicleBuilder.build());
}
List<Patient> patients = state.getPatients();
counter = 0;
for (Patient patient : patients) {
Shipment shipment = Shipment.Builder.newInstance("patient_" + counter++)
.addSizeDimension(0, 1).setDeliveryTimeWindow(patient.getTimeWindow())
.setPickupLocation(Location.newInstance(patient.x, patient.y))
.setDeliveryLocation(patient.getAssignedClusterCentroid()).build();
vrpBuilder.addJob(shipment);
}
vrpBuilder.setRoutingCost(new ManhattanCosts(vrpBuilder.getLocations()));
VehicleRoutingProblem problem = vrpBuilder.build();
Hmm, I'm still learning the ropes in terms of how to ask a question. 嗯,我仍在学习如何提出问题方面的知识。 I have almost solved the problem described above.
我几乎解决了上述问题。 Here's my results (and a link to the whole code ):
这是我的结果(以及指向整个代码的链接):
Adding a 1 minute unload time for any ambulance reaching a hospital for deliveries. 对于任何一辆到达医院进行分娩的救护车,增加1分钟的卸载时间。 - Inherit VehicleRoutingTransportCosts and add 1 to all distance and times.
-继承VehicleRoutingTransportCosts并将所有距离和时间加1。
Let the ambulances choose better routes by letting them deliver patients to any hospital. 让救护车将病人送至任何医院,从而选择更好的路线。 - Still unresolved.
-仍未解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.