Based on this example from cloud balancing problem, I'm trying to remove customer from a working solution as follows:
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();
I got this exception as a result:
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
After that, I tried to also setPreviousStandstill
to null
:
scoreDirector.beforeVariableChanged(customer, "previousStandstill");
customer.setPreviousStandstill(null);
scoreDirector.afterVariableChanged(customer, "previousStandstill");
But, I received:
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.
Need help, please.