gpt4 book ai didi

java - Optaplanner VRP 从工作解决方案中移除客户

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:23:55 27 4
gpt4 key购买 nike

基于此example从云平衡问题中,我正在尝试将客户从工作解决方案中删除,如下所示:

Location toBeRemovedLocation = customerToBeRemoved.getLocation();
Location lookUpWorkingObject = (Location) scoreDirector.lookUpWorkingObject(toBeRemovedLocation);
scoreDirector.beforeProblemFactRemoved(lookUpWorkingObject);
routingSolution.getLocationList().remove(lookUpWorkingObject);
scoreDirector.afterProblemFactRemoved(lookUpWorkingObject);

Customer workingCustomer=(Customer) scoreDirector.lookUpWorkingObject(customerToBeRemoved);

for (Customer customer : routingSolution.getCustomerList()) {
nextCustomer=customer.getNextCustomer();
if (nextCustomer==workingCustomer) {
scoreDirector.beforeVariableChanged(customer, "nextCustomer");
customer.setNextCustomer(null);
scoreDirector.afterVariableChanged(customer, "nextCustomer");
}
}

scoreDirector.beforeEntityRemoved(workingCustomer);
routingSolution.getCustomerList().remove(workingCustomer);
scoreDirector.afterEntityRemoved(workingCustomer);
scoreDirector.triggerVariableListeners();

结果我得到了这个异常:

java.lang.IllegalStateException: The entity (Customer--6361356485874019865) has a variable (previousStandstill) with value (Customer--9027426768799526425) which has a sourceVariableName variable (nextCustomer) with a value (null) which is not that entity.Verify the consistency of your input problem for that sourceVariableName variable

在那之后,我也尝试将 setPreviousStandstill 设置为 null:

scoreDirector.beforeVariableChanged(customer, "previousStandstill");
customer.setPreviousStandstill(null);
scoreDirector.afterVariableChanged(customer, "previousStandstill");

但是,我收到了:

java.lang.IllegalStateException: The entity (Customer--6361368382933429785) has a variable (previousStandstill) with value (Customer--9027434800388369945) which has a sourceVariableName variable (nextCustomer) with a value (null) which is not that entity.Verify the consistency of your input problem for that sourceVariableName variable.

需要帮助,请。

最佳答案

VRP 中的客户是链接/链接的,如果您当前有一个链 [Customer1, Customer2, Customer3]

- Customer1: nextCustomer = Customer2
- Customer2: nextCustomer = Customer2, prevStandstill = Customer1
- Customer3: prevStandstill = Customer2

并且您正试图从中删除 Customer2,您必须同时修复前一个和下一个元素:

- Customer1: nextCustomer = Customer3
- Customer2: nextCustomer = null, prevStandstill = null
- Customer3: prevStandStill = Customer1

关于java - Optaplanner VRP 从工作解决方案中移除客户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47913276/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com