简体   繁体   English

救护车抢救作为车辆路线(载人,有时间限制)

[英]Ambulance rescue as vehicle routing (capacitated, time bound)

Here's the problem that I'm trying to solve: 这是我要解决的问题:

  • There's a town with patients at location (x,y) and a time when they will die. 有一个城镇,病人在(x,y)位置,并且他们会死亡。
  • The patient needs to reach the hospital before he/she dies in order to be rescued. 患者需要在死亡之前到达医院才能得到救助。
  • A bunch of hospitals at (x,y) with some ambulances which can pick up maximum of four patients on one trip, and deliver them to any hospital. (x,y)的一堆医院有一些救护车,一次最多可以接诊四名患者,并将他们送往任何一家医院。
  • An ambulance starts at a hospital, takes multiple trips and can end up at any hospital. 一辆救护车从医院开始,要旅行多次,并且可以在任何一家医院结束。
  • We are supposed to save the maximum number of patients we can. 我们应该保存尽可能多的患者。
  • full problem description here: http://cs.nyu.edu/courses/fall15/CSCI-GA.2965-001/ambulance.html 完整的问题描述在这里: http : //cs.nyu.edu/courses/fall15/CSCI-GA.2965-001/ambulance.html

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)指定有有限的救护车,但它们可以多次旅行。

  • Does setting VehicleRoutingProblem.Builder.setFleetSize(FleetSize.INFINITE) do this? 设置VehicleRoutingProblem.Builder.setFleetSize(FleetSize.INFINITE)会这样做吗? The code doesn't document the exact functionality. 该代码未记录确切的功能。

2) Constraining the patients to be delivered to the hospital before they die, or leave them. 2)限制患者在死亡或离开医院之前被送往医院。

  • Does Shipment.Builder.newInstance("...").setDeliveryTimeWindow(time_of_patient_dying) achieve this? Shipment.Builder.newInstance(“ ...”)。setDeliveryTimeWindow(time_of_ Patient_dying)是否可以实现此目的?

3) Adding a 1 minute unload time for any ambulance reaching a hospital for deliveries. 3)对于到达医院进行分娩的任何救护车,增加1分钟的卸载时间。

  • Don't know which part of the API to look at for this. 不知道该看API的哪一部分。

4) Let the ambulances choose better routes by letting them deliver patients to any hospital. 4)让救护车将病人送至任何医院,从而选择更好的路线。

  • Don't know which part of the API to look at for this. 不知道该看API的哪一部分。

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 ): 这是我的结果(以及指向整个代码的链接):

  1. Specifying that there are finite ambulances, but they can go on multiple trips. 指定有有限的救护车,但它们可以多次旅行。 - Set FleetSize to FINITE -将FleetSize设置为FINITE
  2. Constraining the patients to be delivered to the hospital before they die, or leave them. 限制患者在死亡或离开医院之前被送往医院。 Shipment.Builder.newInstance("...").setDeliveryTimeWindow(time_of_patient_dying) achieves this. Shipment.Builder.newInstance(“ ...”)。setDeliveryTimeWindow(time_of_ Patient_dying)实现了此目的。
  3. 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。

  4. Let the ambulances choose better routes by letting them deliver patients to any hospital. 让救护车将病人送至任何医院,从而选择更好的路线。 - Still unresolved. -仍未解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM