If you do not want to assign a particular vehicle with a tag, you need to implement a core.problem.constraint.HardRouteStateLevelConstraint which is basically this method
public boolean fulfilled(JobInsertionContext insertionContext)
Make sure that insertionContext.getJob() [which is the job to be inserted] can be inserted into insertionContext.getRoute(). At this point you need to know two things:
the associated shipments of insertionContext.getJob(), i.e. shipments that need to be in same route as insertionContext.getJob()
whether one of these associated jobs has already been assigned to a route and if so whether this route is the same as insertionContext.getRoute()
For latter information you need to define states that provides you with a job-route assignment. I would define a problemState and its according updater like this:
The easiest way do make sure that shipments are in the same route is to tag these shipment with a skill
but then you need to tag a particular vehicle as well:
And make sure you make the algorithm consider skills/these tags (see https://github.com/jsprit/jsprit/blob/master/WHATS_NEW.md - you need to use 1.3.2-SNAPSHOT).
If you do not want to assign a particular vehicle with a tag, you need to implement a core.problem.constraint.HardRouteStateLevelConstraint which is basically this method
Make sure that insertionContext.getJob() [which is the job to be inserted] can be inserted into insertionContext.getRoute(). At this point you need to know two things:
For latter information you need to define states that provides you with a job-route assignment. I would define a problemState and its according updater like this:
Add your state updater and your constraint to your State/ConstraintManager and you are done.