Job disjunction constraints?

I have a couple of services which are disjunctive, as in, you should do at most one of x, y, z, and if you don’t do any of them, you get a penalty.

in ORTOOLS this is achieved using:

routing.AddDisjunction([x, y, z], penalty_for_not_taking_any_ride, 1)

What is the best way to do the same in jsprit?

Unfortunately there no straightforward way to do this.

You will have to build a stateId which tracks global states. In your case your global stateid will track list of services in unassigned routes. You will update this on every jobInsertion and after every ruin.

Now build a RouteHardConstraint ensuring that only 1 of all the disjunction job is inserted.

@ihadanny you can refer to below code: