1

这是我要解决的问题:

  • 有一个城镇在位置 (x,y) 有病人,他们会死去。
  • 患者需要在死前到达医院才能获救。
  • (x,y) 的一堆医院,有一些救护车,一次最多可以接 4 名患者,并将他们送到任何医院。
  • 救护车从医院出发,经过多次旅行,最终可以到达任何医院。
  • 我们应该尽可能多地挽救患者。
  • 完整的问题描述在这里:http ://cs.nyu.edu/courses/fall15/CSCI-GA.2965-001/ambulance.html

我正在尝试使用jsprit来解决这个问题,但无法弄清楚如何执行以下操作:(我想知道我应该查看 API 的哪一部分)

1) 指定有有限的救护车,但它们可以进行多次旅行。

  • 设置 VehicleRoutingProblem.Builder.setFleetSize(FleetSize.INFINITE) 会这样做吗?该代码没有记录确切的功能。

2) 限制病人在死前送到医院,或离开他们。

  • Shipment.Builder.newInstance("...").setDeliveryTimeWindow(time_of_patient_dying) 能做到这一点吗?

3) 为任何到达医院分娩的救护车增加 1 分钟的卸载时间。

  • 不知道要查看 API 的哪个部分。

4)让救护车选择更好的路线,让他们把病人送到任何医院。

  • 不知道要查看 API 的哪个部分。

到目前为止,这是我的代码:

// 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();
4

1 回答 1

0

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
  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.
  3. Adding a 1 minute unload time for any ambulance reaching a hospital for deliveries. - Inherit VehicleRoutingTransportCosts and add 1 to all distance and times.

  4. Let the ambulances choose better routes by letting them deliver patients to any hospital. - Still unresolved.

于 2015-10-30T00:04:01.453 回答