Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Violation on optional break window #129

Open
ilibar-zpt opened this issue Sep 15, 2023 · 3 comments
Open

Violation on optional break window #129

ilibar-zpt opened this issue Sep 15, 2023 · 3 comments

Comments

@ilibar-zpt
Copy link

Version: 1.22.1

problem.json

{"objectives": [[{"type": "minimize-unassigned","breaks": 999}],[{"type": "minimize-cost"}]],"plan": {"jobs": [{"id": "job1","pickups":[{"places": [{"location": {"lat": 52.5316,"lng": 13.3884},"duration": 100.0,"times": [["2019-07-04T10:00:00Z","2019-07-04T12:00:00Z"]]}],"demand": [1]}],"deliveries": [{"places": [{"location": {"lat": 52.52599,"lng": 13.45413},"duration": 300.0,"times": [["2019-07-04T11:00:00Z","2019-07-04T13:00:00Z"]]}],"demand": [1]}]},{"id": "job2","pickups":[{"places": [{"location": {"lat": 52.5316,"lng": 13.3884},"duration": 40.0,"times": [["2019-07-04T10:00:00Z","2019-07-04T12:00:00Z"]]}],"demand": [1]}],"deliveries": [{"places": [{"location": {"lat": 52.5225,"lng": 13.4095},"duration": 240.0,"times": [["2019-07-04T12:00:00Z","2019-07-04T14:00:00Z"]]}],"demand": [1]}]},{"id": "job3","pickups":[{"places": [{"location": {"lat": 52.5316,"lng": 13.3884},"duration": 100.0,"times": [["2019-07-04T10:00:00Z","2019-07-04T12:00:00Z"]]}],"demand": [1]}],"deliveries": [{"places": [{"location": {"lat": 52.5165,"lng": 13.3808},"duration": 300.0,"times": [["2019-07-04T13:00:00Z","2019-07-04T15:00:00Z"]]}],"demand": [1]}]}]},"fleet": {"vehicles": [{"typeId": "vehicle","vehicleIds": ["vehicle_1"],"profile": {"matrix": "normal_car"},"costs": {"fixed": 22.0,"distance": 0.0002,"time": 0.004806},"shifts": [{"start": {"earliest": "2019-07-04T09:00:00Z","location": {"lat": 52.5316,"lng": 13.3884}},"end": {"latest": "2019-07-04T18:00:00Z","location": {"lat": 52.5316,"lng": 13.3884}},"breaks": [{"time": [3600,4000],"places": [{"duration": 1800.0}]}]}],"capacity": [10]}],"profiles": [{"name": "normal_car"}]}}

Command:
vrp-cli solve pragmatic problem.json --out-result result.json --log --max-time 15 --min-cv sample,10000,0.05,true --parallelism 1,1

result.json

{"statistic":{"cost":47.445932,"distance":11357,"duration":4822,"times":{"driving":1137,"serving":1080,"waiting":805,"break":1800,"commuting":0,"parking":0}},"tours":[{"vehicleId":"vehicle_1","typeId":"vehicle","shiftIndex":0,"stops":[{"location":{"lat":52.5316,"lng":13.3884},"time":{"arrival":"2019-07-04T09:00:00Z","departure":"2019-07-04T12:01:40Z"},"distance":0,"load":[3],"activities":[{"jobId":"departure","type":"departure","time":{"start":"2019-07-04T09:00:00Z","end":"2019-07-04T11:57:40Z"}},{"jobId":"job3","type":"pickup","location":{"lat":52.5316,"lng":13.3884},"time":{"start":"2019-07-04T11:57:40Z","end":"2019-07-04T11:59:20Z"}},{"jobId":"job2","type":"pickup","location":{"lat":52.5316,"lng":13.3884},"time":{"start":"2019-07-04T11:59:20Z","end":"2019-07-04T12:00:00Z"}},{"jobId":"job1","type":"pickup","location":{"lat":52.5316,"lng":13.3884},"time":{"start":"2019-07-04T12:00:00Z","end":"2019-07-04T12:01:40Z"}}]},{"location":{"lat":52.52599,"lng":13.45413},"time":{"arrival":"2019-07-04T12:09:10Z","departure":"2019-07-04T12:14:10Z"},"distance":4495,"load":[2],"activities":[{"jobId":"job1","type":"delivery"}]},{"location":{"lat":52.5225,"lng":13.4095},"time":{"arrival":"2019-07-04T12:19:15Z","departure":"2019-07-04T13:06:40Z"},"distance":7543,"load":[1],"activities":[{"jobId":"job2","type":"delivery","location":{"lat":52.5225,"lng":13.4095},"time":{"start":"2019-07-04T12:19:15Z","end":"2019-07-04T12:23:15Z"}},{"jobId":"break","type":"break","location":{"lat":52.5225,"lng":13.4095},"time":{"start":"2019-07-04T12:36:40Z","end":"2019-07-04T13:06:40Z"}}]},{"location":{"lat":52.5165,"lng":13.3808},"time":{"arrival":"2019-07-04T13:10:06Z","departure":"2019-07-04T13:15:06Z"},"distance":9599,"load":[0],"activities":[{"jobId":"job3","type":"delivery"}]},{"location":{"lat":52.5316,"lng":13.3884},"time":{"arrival":"2019-07-04T13:18:02Z","departure":"2019-07-04T13:18:02Z"},"distance":11357,"load":[0],"activities":[{"jobId":"arrival","type":"arrival"}]}],"statistic":{"cost":47.445932,"distance":11357,"duration":4822,"times":{"driving":1137,"serving":1080,"waiting":805,"break":1800,"commuting":0,"parking":0}}}]}

Expected:
Break is scheduled between [3600,4000] seconds after departure.

Actual:
Break is scheduled 2340 seconds after departure (2019-07-04T12:36:40Z - 2019-07-04T11:57:40Z)

@reinterpretcat
Copy link
Owner

Thanks! Seems related to usage of offset break and departure time optimization. I've changed validation rule to address this. Essentially, you need to disable departure time optimization for that vehicle by setting shift.start.latest = shift.start.earliest if time offset on break is used

@ilibar-zpt
Copy link
Author

Thanks for quick responses!
Is there a way to get breaks to work with time windows relative to departure and/or previous break end, and have it working with departure time optimization?

The reason for that is an irl regulation where drivers have to make a break after maximum 4hrs of driving for minimum 30mins, so next break depends on when last has ended

@reinterpretcat
Copy link
Owner

Hi, at the moment, there is no workaround as this is a limitation due to implementation.

reinterpretcat added a commit that referenced this issue Dec 22, 2023
This release combines many changes, but essentials are:
- internal route state api simplification
- increased performance
- several experimental features
- bug fixes

* original job place index in activity place to simplify activity-job
 place matching
* `experimental`: a new type of location in pragmatic format to model
 zero distance/duration from it to any other location.
  This could be useful to model optional vehicle start location.
* allow user to pass alternative objectives in goal context to guide
 the search
* `experimental`: a new `fast-service` objective function to serve jobs
 as soon as possible

* experimental `dispatch` feature

* apply code style refactoring
* improve selection sampling search
* update dependencies
* improve a bit documentation
* refactor route state
* do not use hashmaps to store activity states

* double reload assignment when initial solution is used (#126)
* unexpected total_order behavior in dynamic heuristic (#128)
* improve validation rule for break with time offset  (#129)
* fix issue with skills (#133)
* do not cluster jobs if they are defined in relations (#141)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants