I would like to have the following model:
There would be service1 that i would like to split into two services:
service1_1 has a time window from 8 to 9 a.m. and a servicetime of 32h ( a two day service that requires 16h and 16h overnight time)
service1_2 has a timewindow from 9,01 a.m to 12 a.m. and a service time of 48h ( a two day service that requires 16h and two 16h overnight times so 32h)
So now i would like to plan service1_1 XOR service1_2
Do you have a idea how i could effect this?
Or: If you have a idea how i can make the servicetime depending on the time the service is choosen it would also help me
If I understand correctly, you are trying to disallow two jobs to be both served? If so, what you can try is:
- define a state updater to record what jobs have already been inserted;
- define a hard route constraint such that, if job A is already inserted, then job B cannot be inserted to any route (and vice versa).
Note that it is possible that neither of them are served.
I made it another way. I created with a random variable the service A, or the Service B
I have made some work with jsprit and some changes at my code. Now my solution that I had above isn´t actual anymore, I have a more complex problem then above and I hope you can help me find a solution.
My problems work like follows:
There are 2 services, A and A_q. They are on the same location and represent the same service and both should be checked through the recreate process.
So first of all I would like to have, that the service A is checked first for insertion. If not than the first. I don´t want to have that case that the A_o service is used and the service A was also fine.
Next would be the blacklisting of the other service. @jie31best has made some advice for a state updater. Could you give me more hints how I could define something like that or is there any example to make something like this?
My last feature I need is, if some condition is fulfilled (some distance between the home for example) there is a service that HAS TO BE MADE of the Vehicle. Like service A is used -> service Q has to be made before, put it in the insertion like ->
Tour 1 (Normal one from Jsprit:) Depot -> Service A -> …
Tour 2 (I need) : Depot -> Service Q -> Service A -> …
The use of the service Q will make the solution worst than the solution without it, this may be a problem for the solver.
Do you have an idea how I could realize this features?
Thank you for the help
In best insertion, the jobs are evaluated in sequence. For half of the time, they are sorted based on priority, and for the other half of time, the sequence is random.
In regret insertion, the jobs are not evaluated in sequence. Instead, a regret score is calculated for all the jobs, and the ones with higher score are inserted first. In the scorer, you can see that the score is also related with job priority.
Therefore, I think, if you set high priority for service A, it might help, but not guaranteed.
In the state updater which implements StateUpdater and ActivityVisitor, you need to maintain a HashSet of job ids as follows:
In the begin method, load the HashSet by stateManager.getProblemState(…), and if it is null, initialize it to an empty HashSet;
In the visit method, add the job id of the activity to the HashSet;
In the finish method, update the state with the HashSet by stateManager.putProblemState(…).
Then, in the hard route constraint, if the new job insertionContext.getJob() is job A (or B), then load the HashSet by stateManager.getProblemState(…) and check if the id of job B (or A) is in it: if yes, return false; otherwise, return true.
There are quite a few state updaters in the state package and you can take a look.
This sounds similar to driver break. You can take a look at how it is implemented in jsprit.
In such cases, you should account for this in your objective function and, for example, penalyze solutions that do not contain Q at this specific position (or award those where Q is inserted “correctly”).
Thank you for your answers. I will let you know if I have new questions.
I have overthink the ideas I posted last and I think this fits not so good to my problem. After a lot of thinking, I have new Ideas for makeing my problem realyzable. It should be not so hard to make it, with JSprit.
My idea is to cut a service into small pieces. It would be Service A = [A_1, A_2, A_3, …]
So in the end, the tour of a vehicle could look like that: Depot -> …
It is relevant for me that the services are made in row. With the normal definition of JSprit this will not work, because it would be that there is a service B = [B_1, …] with the same location then A and then it would make no difference to put Depot ->A_1 -> B_1 -> A_2 -> A_3 …
So, I need to sort the service before the insertion is made by my conditions. how could I do it?
I just have overlooked a bit and found the scorer and the function and I thought this could help. There do I have some questions about.
The scorer and the scoringfunction are working from unassigned job to the next unassigned job. The problem that I have with this is, that the score is depending on the choosen route and vehicle. If the vehicle has in his route service A_2, then the others of A_X will have a high score. I have in the scorer the Insertiondata, so I have the vehicle but I don´t have the route.
It would be also interesting for me to have for the scoring the infomation about all the unassigned jobs that are tried to insert. Do I have much A_X services, that can´t be made with this vehicle anymore because of not much time, then the score sould be lower and the services B_X, that could be less can fit.