1

複数の VRP を解決するために jsprit を使用しようとしていますTimeWindows。したがって、「TimeWindowsNotAvailable」クラスをサービスに関連付けるマップを含む新しい Constraint-Class を作成しました。

「TimeWindowsNotAvailable」クラスにはTimeWindows、サービスを実行できない場所のリストが含まれています (たとえば、顧客が家にいないなど)。主な問題は、newAct.getArrTime()が常に 0.0 であることですが、VRP の解では が 0.0 ではないことがわかりますarrTime

この問題を解決する方法を知っている人はいますか、それとも複数のTimeWindows実装がはるかに難しいですか?

public class TimeConstraint implements HardActivityStateLevelConstraint {

    private Map<Service, TimeWindowsNotAvailable> notAvailableMap;

    private RouteAndActivityStateGetter states;

    private VehicleRoutingTransportCosts routingCosts;

    public TimeConstraint() {
        super();
    }

    public boolean checkDepTime(Service service, Double depTime){
        TimeWindowsNotAvailable timeWindowsNotAvailable = notAvailableMap.get(service);
        if(timeWindowsNotAvailable == null) return true;
        System.out.println(depTime);
        return timeWindowsNotAvailable.isAvailable(depTime);
    }

    public void setNotAvailableMap(Map<Service, TimeWindowsNotAvailable> notAvailableMap){
        this.notAvailableMap = notAvailableMap;
    }

    @Override
    public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
        Service currentService = (Service)iFacts.getJob();
        if(checkDepTime(currentService, **newAct.getArrTime()**)) return ConstraintsStatus.FULFILLED;
        return ConstraintsStatus.NOT_FULFILLED;
    }
}
4

1 に答える 1

1

すぐに使用できる複数の時間枠をモデル化することはまだできませんが、実装される予定です。当分の間、独自に実装できます。たとえば、サービスに次の 2 つのタイム ウィンドウがあると仮定します。l1 < e2 の場合、実装は比較的「簡単」です。私が単一のハードタイムウィンドウをどのように実装したかを見てください。どれがTimeWindowConstraintで、どれが実用的なタイム ウィンドウ状態updaterであるかを見てください。おそらく、これらのクラスを少し変更するだけでよいので、それらをコピーして複数の時間ウィンドウを追加し、これら 2 つの新しいクラスを State- および ConstraintManager に追加します (デフォルトの時間ウィンドウの制約/stateUpdater を無効にすることを忘れないでください)。

newAct はまだルートに挿入されておらず、最適な挿入位置がまだ決定されていないため (制約を確認し、限界挿入コストを計算することによって)、arrTime はありません。しかし、次のように簡単に計算できます。

double newActArrTime = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), newAct.getLocationId(), prevActDepTime,iFacts.getNewDriver(),iFacts.getNewVehicle);
于 2014-09-05T06:46:25.930 に答える