reinterpretcat / vrp

A Vehicle Routing Problem solver
https://reinterpretcat.github.io/vrp/
Apache License 2.0
331 stars 68 forks source link

Required break problems #81

Open nkl1996 opened 1 year ago

nkl1996 commented 1 year ago

I tested the new required break feature and its not working like i except it. Here i provide you a example where the break is made inside a service. I thought the required break would always be done between two stops while driving.

"activities": [
    {
        "jobId": "85965",
        "type": "service",
        "location": {
            "lat": 52.5414079,
            "lng": 7.8738088
        },
        "time": {
            "start": "2022-07-11T16:31:14Z",
            "end": "2022-07-12T08:31:14Z"
        }
    },
    {
        "jobId": "break",
        "type": "break",
        "time": {
            "start": "2022-07-11T17:00:00Z",
            "end": "2022-07-12T08:00:00Z"
        }
    }

]

Here is the full problem and solution:example.zip

reinterpretcat commented 1 year ago

Hi,

required break is also scheduled during activity's service time to make sure that it is respected in any case. Have you tried to use optional break with time window like 17:00-18:00 instead?

I guess you're trying to model multiple shifts with such breaks to allow vehicle to start at last job location next day. That's why you're not using multi shift feature instead.

nkl1996 commented 1 year ago

Yeah you are right i am trying to model mutitple shifts where the employee sleeps in his car so he starts at the last job next day. But i dont use optional breaks because they are never scheduled between stops. Sometimes the stops are 2-3 hours away with optional breaks the solution would be to wait at the previous stop when there is not enough time to make it.

reinterpretcat commented 1 year ago

Got it. I would say it requires a new field to be exposed on the required break definition (e.g. policy) as I want to keep an existing logic too. Internally, this field can be used as a flag to disable behavior for activity or transport costs. Need to check how difficult it will be to add. The complex part is that if break time happens during activity's service time, then it skipped and new stop won't be scheduled according to existing logic..

Alternative way is to do post processing on the client side: detect such use cases and override last activity and break scheduled times.

nkl1996 commented 1 year ago

I will check if i can post process this case on client side. Thanks.

nkl1996 commented 1 year ago

Hey i tested some more cases with the required break feature but i am getting weird breaks. Here is a example with 3 breaks i a row with overlapping times:

              "activities": [
                  {
                      "jobId": "54479",
                      "type": "service",
                      "location": {
                          "lat": 52.65101,
                          "lng": 7.6198201
                      },
                      "time": {
                          "start": "2022-07-12T09:30:31Z",
                          "end": "2022-07-12T09:45:31Z"
                      }
                  },
                  {
                      "jobId": "break",
                      "type": "break",
                      "location": {
                          "lat": 52.65101,
                          "lng": 7.6198201
                      },
                      "time": {
                          "start": "2022-07-12T09:45:31Z",
                          "end": "2022-07-12T12:00:00Z"
                      }
                  },
                  {
                      "jobId": "break",
                      "type": "break",
                      "location": {
                          "lat": 52.65101,
                          "lng": 7.6198201
                      },
                      "time": {
                          "start": "2022-07-12T12:00:00Z",
                          "end": "2022-07-13T23:30:00Z"
                      }
                  },
                  {
                      "jobId": "break",
                      "type": "break",
                      "time": {
                          "start": "2022-07-12T18:30:00Z",
                          "end": "2022-07-13T06:00:00Z"
                      }
                  }
              ]

Can you provide more details what happend here? I know sometimes the solution can have waiting times because there is no job that can be done before a break so maybe this logic is having a problem? I am mixing required and optinal breaks but that should be fine right? Here is the problem and full solution:example3994.zip

reinterpretcat commented 1 year ago

Actually, implementation assumes that breaks time windows (both, optional and required) don't intersect. I guess I need to add a validation rule to make this explicit.

nkl1996 commented 1 year ago

The break time windows of my problem dont intersect. I use optional breaks for lunch and required breaks for sleepovers. Can you check again why in the solution the breaks intersect?

reinterpretcat commented 1 year ago

It seems like a bug:

Stop with breaks has departure at 2022-07-13T12:00:00

"time": {
                        "arrival": "2022-07-12T09:30:31Z",
                        "departure": "2022-07-13T12:00:00Z"
                    },

But one of the stop activities for break has 2022-07-13T23:30:00 which is later:

                            "time": {
                                "start": "2022-07-12T12:00:00Z",
                                "end": "2022-07-13T23:30:00Z"
                            }

I would need to find a time to dig into the implementation details to find the problem.

nkl1996 commented 1 year ago

I tried to use only required breaks but still sometimes the solution is buggy.

Can you estimated when you have time to fix the issue?

                "location": {
                    "lat": 53.148326,
                    "lng": 8.2302781
                },
                "time": {
                    "arrival": "2022-08-12T08:52:33Z",
                    "departure": "2022-08-15T05:19:55Z"
                },
                "distance": 5436,
                "load": [
                    0
                ],
                "activities": [
                    {
                        "jobId": "48241",
                        "type": "service",
                        "location": {
                            "lat": 53.148326,
                            "lng": 8.2302781
                        },
                        "time": {
                            "start": "2022-08-12T08:52:33Z",
                            "end": "2022-08-15T04:51:03Z"
                        }
                    },
                    {
                        "jobId": "break",
                        "type": "break",
                        "time": {
                            "start": "2022-08-12T09:00:00Z",
                            "end": "2022-08-18T00:00:00Z"
                        }
                    },
                    {
                        "jobId": "48288",
                        "type": "service",
                        "location": {
                            "lat": 53.148326,
                            "lng": 8.2302781
                        },
                        "time": {
                            "start": "2022-08-15T04:51:03Z",
                            "end": "2022-08-15T05:19:55Z"
                        }
                    }
                ]
            },
reinterpretcat commented 1 year ago

At the moment, I don't have plans to start working on it.

kaiSchweegmann commented 1 year ago

Hey i recently started to work with required breaks and also facing the issue. Any updates on this topic?

reinterpretcat commented 1 year ago

No updates. At the moment, I'm working on some internal refactoring

leobudima commented 1 year ago

Just to add a +1 on break issues (and also in context of multi-day routes), happy to provide examples too if it helps ❤️

reinterpretcat commented 11 months ago

I started to look into this issue. If you have a smallest possible problem to reproduce, this would help

leobudima commented 11 months ago

Great news, @reinterpretcat ! I'll try to provide an example as soon as possible if it helps contribute to what others are experiencing as well!

reinterpretcat commented 11 months ago

I pushed a fix for some required breakk problems I've identified:

https://github.com/reinterpretcat/vrp/commit/ac05b25b2987d9a8fd2f5f309397b0a31452f35f

You can try them in vnext branch.