使用OptaPlanner解决带中断的车辆路径问题

时间:2020-10-23 05:11:12

标签: optaplanner

我正在安排两次探访之间的休息时间。休息时间由用户定义。每辆车都有一个以起点和终点为标志的休息时间,从中可以提取休息时间。每当到达时间超过开始时间时,我就在到达时间的计算中实现了一种变化,加上休息时间。但是我有一个问题,我得到了一辆发生故障的车辆的路线,并且在计划中没有增加时间。进行分析后,我推断问题出在某些访问之间的持续时间非常长,并且在比较时忽略了休息时间,

示例: 我有一辆从12:00到13:00休息的车辆1,该车辆的路线是前往访问1,然后访问2,

访问1的到达时间为11:45

访问2的到达时间为13:15

11:45和13:15都不输入中断间隔,将被忽略。我预计第2次访问的到达时间为14:15,但并非如此

问题:我该如何考虑由用户标记其开始,结束和持续时间的中断,并考虑到停靠点之间的距离可以大于或小于中断的持续时间。

为解决此问题,我在到达时间的计算中进行了以下更改:如果距离较小,为了影响到达时间并保持其余时间,请检查其是否在由标记的范围内其余的开始和结束。但是,如果距离较大,我会检查到达时间是否大于休息时间,但也要确保上一次访问没有休息,因此只能应用一次休息时间。

我的问题是:这是正确的方法吗?还是应该以我不考虑的其他方式来完成?

public class ArrivalTimeUpdatingVariableListener implements VariableListener<PlanningVisit> {

    ...

    private Long calculateArrivalTime(TimeWindowedVisit customer, Long previousDepartureTime) {
    long arrivalTime = 0;
    if (customer == null || customer.getPreviousStandstill() == null) {
        return null;
    }
    if (customer.getPreviousStandstill() instanceof PlanningVehicle) {
        // PreviousStandstill is the Vehicle, so we leave from the Depot at the best suitable time
        arrivalTime = Math.max(customer.getReadyTime(),
                previousDepartureTime + customer.distanceFromPreviousStandstill());
    } else {
        arrivalTime = previousDepartureTime + customer.distanceFromPreviousStandstill();
    }

    if (customer.getVehicle().getBreaks() != null
            && arrivalTime >= customer.getVehicle().getBreaks().getStart()) {
        // duration of the trip is less than the duration of the break
        if (customer.distanceFromPreviousStandstill() <= customer.getVehicle().durationBreak()
                && arrivalTime < customer.getVehicle().getBreaks().getEnd()) {
            arrivalTime += customer.getVehicle().durationBreak();
        }
        // duration of the trip is longer than the duration of the break
        else if (customer.distanceFromPreviousStandstill() > customer.getVehicle().durationBreak()
                && arrivalTime >= customer.getVehicle().getBreaks().getEnd()
                && previousDepartureTime < customer.getVehicle().getBreaks().getEnd()) {
            arrivalTime += customer.getVehicle().durationBreak();
        }
      
     }

      return arrivalTime;
  }
...

}

0 个答案:

没有答案