Migrating 1.3.1-1.4: addDefaultProblemState

Hi, new here, pretty new to the library.

I’m looking to adapt this code, and have managed to migrate all of it except for the stateManager.addDefaultProblemState section. From the changelog it says “Client must now decide what to do when state does not exist” but I can’t figure out what addDefaultProblemState does in the first place.

There is supposedly an example to help migration here but the link is dead.

Thanks!
Steven

Hi Steven,

Use this link instead of the dead one.

You probably will encounter a few such dead links in the future, and basically what you can do is to add “com/graphhopper” in the middle of “…java/jsprit…”.

Best regards,
He

That’s great, thanks

Sadly the 1.3.1 code doesn’t use addDefaultProblemState, so I still can’t see how to replace it.

Ooh - might’ve just figured it out:

stateManager.putProblemState(max_transport_time_state, Double.class, 0.);
//stateManager.addDefaultProblemState(max_transport_time_state, Double.class, 0.);

Are those the same?

Hi Steven,

In the changelog, under “v1.4 @ 2014-09-08”, you will find:

StateManager.addDefault… methods do not exists anymore. Client must now decide what to do when state does not exist.

And in this related post in the old mailing list, Stefan answers:

When it comes to the stateManager, there are no default states anymore. Therefore, you need to check whether you set a state or not, i.e. whether it returns null or not.

So I guess what you did worked?

Best regards,
He

Yeah, i used putProblemState at the start every time so that I knew it wasn’t null.