[英]Optaplanner constraints for time windows
I am trying to solve VRP with OptaPlanner.我正在尝试使用 OptaPlanner 解决 VRP。 I have multiple customers that have different time windows.我有多个客户有不同的时间 windows。 Here are my constraint providers这是我的约束提供者
protected Constraint arrivalAfterDueTime(ConstraintFactory factory) {
return factory.from(TimeWindowedCustomer.class)
.filter(customer -> customer.getArrivalTime() >= customer.getDueTime())
.penalizeLong("arrivalAfterDueTime",
HardSoftLongScore.ONE_HARD,
customer -> customer.getArrivalTime() - customer.getDueTime());
}
protected Constraint arrivalBeforeReadyTime(ConstraintFactory factory) {
return factory.from(TimeWindowedCustomer.class)
.filter(customer -> customer.getArrivalTime() > customer.getReadyTime()
&& customer.getArrivalTime() < customer.getDueTime() )
.penalizeLong("arrivalBeforeReadyTime",
HardSoftLongScore.ONE_HARD,
customer -> customer.getReadyTime() - customer.getArrivalTime());
}
But in the solution I get arrival times that are < ready time.但在解决方案中,我得到的到达时间是<准备时间。 How can I fix this?我怎样才能解决这个问题? Thank you in advance.先感谢您。
There are generally three approaches when arriving too early:过早到达时通常有三种方法:
In any case, use ConstraintVerifier
to unit test your constraints!无论如何,请使用ConstraintVerifier
对您的约束进行单元测试!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.