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

Read HFVRP instances #550

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Read HFVRP instances #550

wants to merge 22 commits into from

Conversation

leonlan
Copy link
Member

@leonlan leonlan commented Mar 26, 2024

This PR adds support for reading HFVRP instances and is part of #543.

Notes:

  • It is essential that you add a test when making code changes.
    This keeps the code coverage level up, and helps ensure the changes work as intended.
  • When fixing a bug, you must add a test that would produce the bug in the master branch, and then show that it is fixed with the new code.
  • New code additions must be well formatted. Changes should pass the pre-commit workflow, which you can set up locally using pre-commit.
  • Docstring additions must render correctly, including escapes and LaTeX.

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.70%. Comparing base (02a7c03) to head (8e1058b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #550      +/-   ##
==========================================
+ Coverage   95.68%   95.70%   +0.02%     
==========================================
  Files          73       73              
  Lines        3243     3260      +17     
  Branches      888      888              
==========================================
+ Hits         3103     3120      +17     
  Misses         48       48              
  Partials       92       92              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pyvrp/read.py Outdated Show resolved Hide resolved
@leonlan leonlan marked this pull request as ready for review March 26, 2024 08:18
@leonlan
Copy link
Member Author

leonlan commented Mar 26, 2024

@N-Wouda Also check out https://github.com/PyVRP/Sandbox/pull/6 for the new instances and README. I'll bump that to PyVRP/Instances and update the submodule after review.

docs/source/dev/supported_vrplib_fields.rst Outdated Show resolved Hide resolved
docs/source/dev/supported_vrplib_fields.rst Outdated Show resolved Hide resolved
docs/source/dev/supported_vrplib_fields.rst Outdated Show resolved Hide resolved
tests/data/MoreVehiclesThanSectionData.txt Outdated Show resolved Hide resolved
tests/test_read.py Outdated Show resolved Hide resolved
@leonlan
Copy link
Member Author

leonlan commented Mar 27, 2024

I need to do a bit more testing on this, probably tomorrow. I have tried to solve all HFVRP instances with 10 second runtime, but there are some instances that don't result in feasible solutions, even for longer runtimes.


This instance is pretty annoying: even though we have an unlimited fleet, the initialization procedure uses vehicle type 0 by default. But some clients have demand that exceeds this vehicle type capacity.

❯ poetry run pyvrp HFVRP/X670-FSMF.vrp --max_runtime 100 --seed 0 --num_procs 6 --round_func exact
Details
Instance    OK  Obj.          Iters. (#)  Time (s)
----------  --  ------------  ----------  --------
X1001-FSMF   Y   105683793.0          16     10.28
X101-FSMFD   Y    34309886.0         912    10.014
 X106-FSMD   Y    14862233.0         615    10.007
   X110-HD   Y    13390527.0         752    10.007
 X115-HVRP   N           inf         731    10.008
 X120-FSMF   Y   286903060.0         218     10.06
 X125-HVRP   Y    91738535.0         491    10.011
X129-FSMFD   Y    59349184.0         285    10.019
 X134-FSMD   Y     9112301.0         576    10.013
   X139-HD   Y    12764782.0         614    10.018
 X143-FSMF   Y    39587282.0         581    10.033
 X148-HVRP   Y    73253691.0         311    10.006
X153-FSMFD   Y    26729273.0         392     10.01
   X157-HD   Y    15840920.0         318    10.025
 X162-FSMD   Y    28205268.0         608     10.02
 X167-FSMF   Y    32109154.0         414    10.004
 X172-HVRP   Y    96711271.0         387    10.013
X176-FSMFD   Y    78112981.0         373    10.016
   X181-HD   N           inf         182    10.006
 X186-FSMD   Y    30054000.0         444    10.011
 X190-FSMF   Y    19224320.0         251    10.012
 X195-FSMF   Y    83040781.0         318    10.034
   X200-HD   Y    57475675.0         257     10.02
 X204-FSMD   Y    38434092.0         400    10.019
X209-FSMFD   Y    35083366.0         308     10.04
 X214-HVRP   Y    15934261.0         291    10.005
   X219-HD   N           inf         135    10.012
 X223-HVRP   Y    75033659.0         138    10.018
X228-FSMFD   Y    49156151.0         200    10.017
 X233-FSMD   Y    14867156.0         328    10.007
 X237-FSMF   Y   456129168.0          82     10.03
X242-FSMFD   Y   528472202.0          66    10.103
 X247-HVRP   Y    47150559.0         212    10.025
 X251-FSMD   Y    26221058.0         175    10.032
 X256-FSMF   Y    53428709.0         298    10.019
   X261-HD   Y    25343986.0         225    10.022
   X266-HD   Y    70619921.0          88    10.038
 X270-FSMD   Y    57598095.0         212    10.026
 X275-HVRP   N           inf          84    10.039
 X280-FSMF   Y    71173297.0         194    10.066
X284-FSMFD   Y    32062900.0         145    10.016
 X289-HVRP   Y   123064090.0         171    10.022
   X294-HD   Y    39721752.0         230    10.013
 X298-FSMD   Y    22917325.0         194    10.021
X303-FSMFD   Y    42791517.0         239    10.018
 X308-FSMF   Y    64953953.0         153    10.016
 X313-FSMD   Y    80739410.0         123    10.058
 X317-HVRP   N           inf          55    10.074
   X322-HD   Y    37199894.0         177    10.002
X327-FSMFD   Y    36860077.0         142     10.05
 X331-FSMF   Y   756165652.0          33     10.41
 X336-FSMF   Y   223694906.0         129    10.056
 X344-FSMD   Y    30435673.0         131    10.061
 X351-HVRP   Y    53593212.0         115     10.02
   X359-HD   Y    42151766.0         100    10.009
X367-FSMFD   Y    61584467.0         125     10.01
   X376-HD   N           inf          24    10.062
 X384-FSMF   Y   137965665.0         155    10.048
 X393-HVRP   Y    70000248.0          84    10.021
X401-FSMFD   Y    92500933.0          90    10.043
 X411-FSMD   Y    15848489.0          88    10.066
 X420-FSMD   Y    67711087.0          58    10.067
 X429-HVRP   Y    87635944.0          99    10.021
 X439-FSMF   Y   515039832.0          21    10.548
X449-FSMFD   Y   124300055.0          65    10.135
   X459-HD   Y    24263674.0          80    10.059
   X469-HD   Y   218545454.0          85    10.062
 X480-FSMD   Y    62098193.0          60    10.058
 X491-FSMF   Y   139887598.0          71    10.135
X502-FSMFD   Y   920420326.0          25    10.629
 X513-HVRP   Y    42623383.0          89    10.014
   X524-HD   Y   113242674.0          56    10.069
X536-FSMFD   Y   262387157.0          77    10.158
 X548-FSMF   Y  1114776234.0           9    10.192
 X561-FSMD   Y    33195750.0          62     10.14
 X573-HVRP   Y   107445194.0          53    10.148
 X586-FSMF   Y   960804618.0          13    10.783
 X599-FSMD   Y   140683919.0          70    10.212
   X613-HD   Y    62564170.0          56     10.13
 X627-HVRP   Y   108189727.0          25    10.125
X641-FSMFD   Y   194056042.0          53    10.125
   X655-HD   N           inf          15     10.69
 X670-FSMF   N           inf          27    10.037
 X685-FSMD   Y    93823628.0          54    10.103
 X701-HVRP   N           inf           7    10.896
X716-FSMFD   Y    75580358.0          44    10.041
X733-FSMFD   Y   849465258.0           8    10.287
 X749-FSMF   Y   222501932.0          45    10.304
 X766-FSMD   Y   115930661.0          29    10.117
   X783-HD   Y    86371809.0          34    10.218
 X801-HVRP   N           inf           6    10.642
 X819-FSMD   Y   162791596.0          30    10.195
   X837-HD   Y   213310410.0          14    10.704
 X856-HVRP   N           inf           4    11.646
 X876-FSMF   Y   340451028.0          30    10.438
X895-FSMFD   Y    94797404.0          44    10.075
X916-FSMFD   Y  2024469076.0           5    10.091
 X936-FSMD   Y   130411439.0          35    10.345
   X957-HD   N           inf          17    10.303
 X979-HVRP   Y   208099335.0          17    10.093

@leonlan
Copy link
Member Author

leonlan commented Mar 28, 2024

OK, it turns out that there is at least one instance (X115-HVRP) that cannot even be feasibly solved. This is not a parsing issue, I also checked that the data of the original raw instance.

There may be more, but I don't want to do that manually. It should be very easy to check with an exact bin packing program.

I have messaged the original author of the paper Pessoa et al. (2018). Until then, this PR is on-hold.

Details about X115-HVRP

Instance: X115-HVRP.txt

These are the vehicle capacities:

... (small capacity vehicles)
131
131
131
131
131
322

These are the client demands:

0 (depot)
86
98
89
91
74
87
65
62
60
99
96
79
... (remaining clients all have small demand)

The presented 12 clients must be assigned to these vehicles with large capacities. There are more vehicles, but the capacity is too small. Summing up these values:

  • Total of vehicle capacity: 131+131+131+131+131+322 = 977
  • Total of client demand: 86+98+89+91+74+87+65+62+60+99+96+79 = 986

This can't even feasibly fit!

@leonlan
Copy link
Member Author

leonlan commented Mar 28, 2024

OK, I manually checked all other instances and turns out X115-HVRP is the only infeasible instance. That's good news; I'll just run a benchmark without this instance.


There were still some issues with the weights. I have fixed this now and am running a new benchmark.

@N-Wouda N-Wouda self-requested a review March 29, 2024 16:14
tests/test_PenaltyManager.py Outdated Show resolved Hide resolved
Copy link
Member

@N-Wouda N-Wouda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to think about the scaling issue a bit more. The increase in e.g. penalty term value and overall ballooning size of all values scares me a bit.

pyvrp/read.py Outdated Show resolved Hide resolved
tests/data/MoreVehiclesThanSectionData.txt Outdated Show resolved Hide resolved
pyvrp/read.py Outdated Show resolved Hide resolved
pyvrp/read.py Outdated Show resolved Hide resolved
pyvrp/read.py Outdated Show resolved Hide resolved
@leonlan leonlan requested a review from N-Wouda April 29, 2024 06:06
@leonlan
Copy link
Member Author

leonlan commented Apr 29, 2024

This PR is ready to be reviewed again. The open issue with HFVRP instances was how to deal with the scaling. The current solution is not to scale unit distance costs, instead we assume that the instance data is integral. Accordingly, the original HFVRP instances are modified to match this assumption.

@N-Wouda
Copy link
Member

N-Wouda commented May 23, 2024

Oh, sorry, I still need to look at this. I'll try to do so later today!

Copy link
Member

@N-Wouda N-Wouda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me, I only have one question about the rounding (and the earlier concern about the huge penalty terms up to 1 million, but that might be OK now that we have 64-bit integers).

Comment on lines +128 to +130
# Unit distance costs are not rounded: we assume here that the instance
# presents the costs in the desired precision!
unit_distance_costs = instance["vehicles_unit_distance_cost"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems a bit odd. Why would we not round these? What goes wrong if we do?

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

Successfully merging this pull request may close these issues.

None yet

2 participants