我嘗試使用jsprit解決具有多個TimeWindows
的VRP。因此,我創建了一個新的約束類,其中包含一個將「TimeWindowsNotAvailable」類與服務關聯的Map。具有多個時間窗口的Jsprit VRP
「TimeWindowsNotAvailable」類包含一個列表TimeWindows
,服務無法完成(例如,客戶不在家等)。 主要問題是,newAct.getArrTime()
始終爲0.0,但您可以在VRP的解決方案中看到arrTime
不是0.0。
有沒有人有一個想法,我可以如何解決這個問題或多個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;
}
}
非常感謝!我會在考試後嘗試;) – 2014-09-22 23:27:25