Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route duration (via StateManager) is always null in HardRouteConstraint #469

Open
Rzpeg opened this issue Jun 25, 2019 · 3 comments
Open

Comments

@Rzpeg
Copy link

Rzpeg commented Jun 25, 2019

Hi,

Trying to implement a hard route constraint that depends on the route cost and duration, however the route duration is always returned as null. The route costs return is OK.
jsprit version 1.7.3

var stateManager = new StateManager(problem);

HardRouteConstraint customConstraint = insertionContext -> {
    var route = insertionContext.getRoute();
    var routeDuration = stateManager.getRouteState(route, InternalStates.DURATION, Double.class);
    var routeCosts = stateManager.getRouteState(route, InternalStates.COSTS, Double.class);
    ...
 }

var constraintManager = new ConstraintManager(problem, stateManager);
constraintManager.addConstraint(customConstraint);
@briandilley
Copy link

be sure to call: stateManager.updateLoadStates(); (and the other update* methods) so that the state that you're looking for is tracked.

@Rzpeg
Copy link
Author

Rzpeg commented Jul 13, 2019

Thanks for the hint. I'll try it later this week.

@Rzpeg
Copy link
Author

Rzpeg commented Aug 14, 2019

@briandilley It works, but the states are accessible only in constraints.
I need to access a few states for the best solution found. I can use the SolutionAnalyser to get built-in states but there's no way I can add my custom StateUpdaters to the analyzer. The only way I've found is just copy-pate the analyser code, add my updaters to its statesManager.
Is there a better way of doing it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants