Ordered dependency between jobs

Hi,

This is probably a simple question, I’m trying to loosely force job A to be before job B, there can be other jobs between them, I found examples where job A and B are adjacent, but for my case, this case isn’t mandatory. I tried to use a HardActivityConstraint and check if route already serves job A :

@Override
    public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
        Job jobA = .....;

        if (newAct.getName() == "job B") {
            if (!iFacts.getRoute().getTourActivities().servesJob(jobA))
                return ConstraintsStatus.NOT_FULFILLED;
        }
        return ConstraintsStatus.FULFILLED;
    }

But the solution still gives B before A.

I also tried :

        @Override
    public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
        VehicleRoute routeA = stateManager.getProblemState(keyJobA, VehicleRoute.class);
        if (newAct.getName() == "job B") {
            if (!iFacts.getRoute().equals(routeA)) {
                return ConstraintsStatus.NOT_FULFILLED;
            }
        }
        return ConstraintsStatus.FULFILLED;
    }

but still didn’t work.

I saw the post of Stefan, but I’m not sure I understand :

  1. in-sequence: here you need to define a hard constraint at activity level, and you require activity states that gives you - at each activity in the route - the information whether jobA/B has already been inserted