rust-or / lp-solvers

library implementing interaction with various linear programming solvers
https://docs.rs/lp-solvers/
MIT License
17 stars 9 forks source link

Mipgap #6

Closed mfuhr closed 10 months ago

mfuhr commented 10 months ago

Add a WithMipGap trait and implement it for CBC, Cplex, GLPK, and Gurobi.

While updating the CBC command_name and with_temp_solution_file methods I also changed them to copy threads and seconds from self instead of setting those values to None. Most programmers probably expect those methods to retain set values instead of resetting them to None.

In the CBC read_specific_solution method I put buffer.split_whitespace() in a variable because the code now needs to call next() twice: once to look for "Optimal" and once to examine what follows to see if the status should be SubOptimal.

In the CBC arguments method I replaced the redundant setting of the timeout with the code to set the MIP gap.

In the Glpk arguments method I got rid of the iterator as suggested for the PR that implemented it. Since seconds and mipgap have different types I couldn't just add another tuple to the array that was being iterated over.

I don't have access to Cplex or Gurobi command line interfaces so I couldn't verify that they work, nor do I know how to recognize when a solution is suboptimal for those solvers. I relied solely on documentation to set the MIP gap arguments.

lovasoa commented 10 months ago

Great ! Maybe you could add some little tests that assert what the command arguments look like after a few with_xxx() calls ?

mfuhr commented 10 months ago

Tests added!