jeremyomer / KidneyExchange.jl

MIT License
4 stars 2 forks source link

File format descriptions seem off #16

Closed WPettersson closed 7 months ago

WPettersson commented 8 months ago

I'm trying to test KidneyExchange.jl on some instances I have that are not from PrefLib. I read https://jeremyomer.github.io/KidneyExchange.jl/dev/functions/#KidneyExchange.read_kep_file-Tuple%7BAbstractString,%20AbstractString%7D to understand the file formats (which agrees with what I would expect from PrefLib), but then reading https://github.com/jeremyomer/KidneyExchange.jl/blob/a7ccc09a86b83d98ef0fed572a6f9c00395c10a3/src/instance/io_kep_file.jl#L74 would imply the first line of the WMD file should have number of vertices and edges separated by a comma. This doesn't agree with the earlier documentation. Indeed, checking https://github.com/jeremyomer/KidneyExchange.jl/blob/master/data/tests_chains/MD-00001-00000015.wmd shows me that the wmd files in this repository seem to have a slightly different format (no comment lines, first line shows number of vertices and edges, followed by names of vertices, then list of edges).

Afterwards, I just tried running an actual PrefLib instance, and received the following

julia> KidneyExchange.solve_with_BP("/home/wpette/00036-00000001", 3, 3)

********************************************************************************
 Solve /home/wpette/00036-00000001 with (K,L) = (3,3) using branch-and-price
 - master model uses PIEF = false 
 - time limit is 600.0 seconds
********************************************************************************

----------------------------------------------------------
 Parse the input file
----------------------------------------------------------

ERROR: ArgumentError: invalid base 10 digit '#' in "# FILE NAME: 00036-00000001.wmd"
Stacktrace:
  [1] tryparse_internal(::Type{Int64}, s::SubString{String}, startpos::Int64, endpos::Int64, base_::Int64, raise::Bool)
    @ Base ./parse.jl:143
  [2] parse(::Type{Int64}, s::SubString{String}; base::Nothing)
    @ Base ./parse.jl:254
  [3] parse
    @ ./parse.jl:253 [inlined]
  [4] read_kep_file(wmd_file::String, dat_file::String)
    @ KidneyExchange ~/.julia/packages/KidneyExchange/rCSqf/src/instance/io_kep_file.jl:77
  [5] KidneyExchange.Instance(filename::String, K::Int64, L::Int64)
    @ KidneyExchange ~/.julia/packages/KidneyExchange/rCSqf/src/instance/instance.jl:52
  [6] macro expansion
    @ ~/.julia/packages/TimerOutputs/RsWnF/src/TimerOutput.jl:237 [inlined]
  [7] solve_with_BP(filename::String, K::Int64, L::Int64, bp_params::BP_params, timer::TimerOutput, time_limit::Float64)
    @ KidneyExchange ~/.julia/packages/KidneyExchange/rCSqf/src/branch&price/branch_and_price.jl:39
  [8] solve_with_BP (repeats 2 times)
    @ ~/.julia/packages/KidneyExchange/rCSqf/src/branch&price/branch_and_price.jl:29 [inlined]
  [9] solve_with_BP(filename::String, K::Int64, L::Int64)
    @ KidneyExchange ~/.julia/packages/KidneyExchange/rCSqf/src/branch&price/branch_and_price.jl:29
 [10] top-level scope
    @ REPL[15]:1

Is there a particular trick to reading instances from .wmd/.dat files? The stack trace would seem to imply the correct function is called but I'm not sure.

pnavaro commented 8 months ago

Hi William,

I made a fix in 16-file-format-descriptions-seem-off branch . Could you tell me if it works. I have to check with @jeremyomer how to merge this in the master branch because for now, it breaks the original behaviour.

PS: I'm one of the maintainer but I did not develop this package.

WPettersson commented 8 months ago

Sorry for the delay, but yes, that change does work for me, thank you :)

WPettersson commented 8 months ago

Sorry, but I noticed another potential issue. You are pulling the name of the dat file from the wmd file, but if the path to the wmd file is something like path/to/instance.wmd then the wmd file will probably just reference instance.dat but without the path.

Or in other words, if the wmd and dat file are both not in the current directory, then the .dat file won't be opened correctly.

I tested this with

julia KEPTestBPPICEF.jl data/preflib/00036-00000001 3 2

where the current working directory is the base of this git repo, and I have downloaded the relevant preflib instance to data/preflib

pnavaro commented 8 months ago

You are absolutely right about the related files .dat, I have to prepend the path. As mentioned in README, the files must be in data directory but you don't have to put it in the path.
It is not obvious though.

julia KEPTestBPPICEF.jl preflib/00036-00000001 3 2