首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多时间Windows下的Jsprit VRP

多时间Windows下的Jsprit VRP
EN

Stack Overflow用户
提问于 2014-08-28 11:20:00
回答 1查看 1.2K关注 0票数 1

我尝试使用jsprit来解决多个TimeWindows的VRP问题。因此,我创建了一个新的约束类,它包含一个映射,该映射将"TimeWindowsNotAvailable"-class与服务相关联。

"TimeWindowsNotAvailable"-class包含无法完成服务的TimeWindows列表(例如,客户不在家等)。主要的问题是,newAct.getArrTime()始终是0.0,尽管在VRP的解决方案中可以看到arrTime不是0.0。

有人知道我如何解决这个问题吗?还是多个TimeWindows更难实现?

代码语言:javascript
复制
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;
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-05 06:46:25

您还不能对多个时间窗口进行开箱即用的建模,但它将被实现。目前,您可以实现您自己的。例如,假设服务有以下两个时间窗口:(e1,l1),(e2,l2),其中e表示最早的操作开始和l最新操作。如果l1 < e2,则实现起来相当“容易”。看看我是如何实现单一硬时间窗口的。看看哪个是TimeWindowConstraint哪个是实用的时间窗口状态更新器?。您可能只需要对这些类进行轻微的修改,所以只需复制它们并添加多个时间窗口,并将这两个新类添加到您的状态-和ConstraintManager (不要忘记禁用默认的时间窗口约束/状态更新程序)。

newAct没有任何arrTime,因为它还没有插入到路由中,最佳插入位置仍有待确定(通过检查约束和计算边际插入成本)。但是,您可以轻松地按以下方式计算它:

代码语言:javascript
复制
double newActArrTime = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), newAct.getLocationId(), prevActDepTime,iFacts.getNewDriver(),iFacts.getNewVehicle);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25547563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档