A question about JobsInRouteMemorizer

Hi,

I have a question about the JobsInRouteMemorizer in the related jobs code:

When a job is ruined and not inserted yet, what makes sure that its associated memorized route will be reset and not point to the route which it was assigned in the previous iteration?

Thanks.

Best regards,
He

Hi He,
The StateManager listens itself to the overall algorithm, i.e. it knows when an iteration starts, when insertion starts etc… It uses these information to clear and recalculate states.
Does this answer your question?
Best,
Stefan

Hi Stefan,

Thanks for your quick answer. So the clear() will make it null by

Arrays.fill(problemStates,null); 

to start with in the next iteration.

What I intend to do is to use a

Map<String, VehicleRoute> jobIdRouteMap;

to record the jobId-route relationship, and update the state as

this.stateManager.putProblemState(
    this.stateManager.createStateId("jobRouteMemorizer"), 
    Map.class, 
    this.jobIdRouteMap
);

in the finish() of ActivityVisitor, to replace updating the state for each jobId as its associated route.

The purpose is to avoid the error IllegalArgumentExceptions raised by the Capacity.max function, which is also reported in this post in the old mailing list and this post on stackoverflow.

The thing is, it seems jobIdRouteMap is not reset to null (or empty map) and for a ruined job its jobId still has a matched route in the map.

EDIT:

I think I figure it out: I need to do this in the begin() of ActivityVisitor:

this.jobIdRouteMap = this.stateManager.getProblemState(
    this.stateManager.createStateId("jobRouteMemorizer"), 
    Map.class
);
if (this.jobIdRouteMap == null)
    this.jobIdRouteMap = new HashMap<>();

EDIT 2:

Another way to avoid the error is to update the state (in the old way, i.e., not using the map) only for those jobs in the relation constraints - so it seems the error occurs when the number of jobIds that need to be updated is large? Just my guess.

Hopefully I have made myself understood. Thanks.

Best regards,
He

the same IllegalArgumentExceptions error which is raised by the Capacity.max function is also recently reported in #269.

I am going to have a look at this in detail asap.