# How to achieve the control on job sequence?

I looking the to implementation new features in route engine.
Which is towards on women safety. So the problem is I do have five services to drop the employee and
In the slot where women in the vehicle which would drop first.
@jie31best @Balage1551 @aj1310 @karussell @stefan

Well, as some other posts (look at this) in the forum describes, hard constrains only fullfilled in insertation phase, therefore the ruin strategy has to be altered to enforce them. Stefan could give you help how to do this.

I can only give you a hack, a workaround: unsing marker capacity dimensions. Let’s say, your vehicle has 5 seats. You define 5 dimensions: one for each seat and give them the maximal capacity value of 5. For all seats where a woman travels, set the initial capacity to the maximum (5), for all seats where man sits, left it 0. For all service jobs, set the capacity requirement as follows: if you serve a woman, set the capacity change for the seat you serve -5 and 0 to each others. If you serve a man, set 1 for each slots.

As a concrete exampe: let’s say, there are 2 women on seat 2 and 3. Then the initial capacity: 0 - 5 - 5 - 0 - 0 (maximum for each dimension is 5)
If we serve the second job first:
Original: 0 - 5 - 5 - 0 - 0
Require: 0 - (-5) - 0 - 0 - 0
Result: 0 - 0 - 5 - 0 - 0
Its ok.

Now try to serve the fourth seat:
Original: 0 - 0 - 5 - 0 - 0
Require: 1 - 1 - 1 - 1 - 1
Result: not ok!

You can see, that the third seat is overloaded, so this job can’t be served.

If you serve the third seat (the other women), the capacity of the vehicle sets to all zeros, therefore the men can be served.

This looks like a hack, but the technics to use capacity dimensions to control job availability could help to solve several ordering problems where hard constraints are hard to implement.

1 Like

Sir @Balage1551 I did not get it.
Thank you very much helping me but your hack I did not get.
Looking this example similar to my use case but did not get it still.

1. Why it two paths to deliver apple?
2. How he get the priority to pickups and delivers the apple over the banana?

The topic of custom ruin strategy has been a solution proposed for many posts, but sincerely I still don’t grasp it. As far as I’ve searched there is no documentation or examples to understand such solution or any of the more advanced stuff. What I’ve been able to find is a description of what the ruin and recreate strategy is.

1 Like

if you are expecting a single route with job sequence as 2341, I think your constraint looks good, but you need to set fleet size as finite and change the capacity of the vehicle type to at least 4.

1 Like

he was saying that, for some constraints, the ruin phase might break them - for example, if I have a constraint saying deliveries A and B must be in the same route and there must be at least one job activity between them, then it is possible that the ruin phase do not ruin deliveries A and B but ruin all the job activities between them, and thus break the constraint (if no job activity is inserted between A and B in the recreate phase) and return an invalid solution.

but I don’t think your constraint (high priority job must be served first) belongs to that category.

1 Like

Thank you for clearing doubt.

@stefan recently added a ruin strategy (stringRuin) to box.Jsprit, maybe you can take a look at how he did it?

1 Like

not working in what sense? is the returned solution not fulfilling the constraint (a higher priority job is served later than a lower priority one)? or are there unassigned jobs?

a higher priority job is served later than a lower priority one

It serves 2 and 5 service but according to the priority and hard constraint it should be 4 and 3

Sir @jie31best have you got the problem?

travel time between 4 and 3 is?

No no this is service id.

yeah i mean travel time between service4 and service3?

all the service have time window are same (50,55)

Sir @jie31best Distance v/s priority?

right, if you are using the default travel cost (i.e., Euclidean), travel time between service4 and service3 is larger than 5, so it is not possible to serve both of the two.

on the other hand, travel time between service2 and service5 is 5, so it is possible to serve both of them. service2 has higher priority than service5, so the solution is good, i suppose?

if you change service4 location to (40, 5), then you will get depot -> service4 -> service3 -> depot route

Yes, sir.

If I increase the time window of 4th service then it should not still serve

but service 3 has the highest priority and if to reach 4 has large cost then it should only serve 3.
Is it possible?