Closed mfuhr closed 10 months ago
@mmghannam any idea how hard it would be to implement mip gap in russcip ?
I think implementing MIP gap in russcip should be as simple as calling model.set_real_param("limits/gap", gap)
but set_real_param
is implemented only when the model is in the Unsolved
state and the state changes almost immediately after the scip() function creates it:
let mut model = Model::new() // state is Unsolved
.hide_output() // state is Unsolved
.include_default_plugins() // state is PluginsIncluded
.create_prob("problem") // state is ProblemCreated
.set_obj_sense(match to_solve.direction {
ObjectiveDirection::Maximisation => ObjSense::Maximize,
ObjectiveDirection::Minimisation => ObjSense::Minimize,
}); // state is ProblemCreated
A with_mip_gap
method might be able to call model.try_new()
to get the model back into the Unsolved
state so we can call set_real_param
but then we'd have to get the model back into the ProblemCreated
state before returning. I haven't investigated any farther yet.
@mmghannam what do you think? Maybe russcip could allow setting parameters in the ProblemCreated state? Or would that introduce the possibility for an inconsistent state ?
@mfuhr : anyway, I don't see an issue with with merging this PR without russcip support now, and adding it later.
@mmghannam what do you think? Maybe russcip could allow setting parameters in the ProblemCreated state? Or would that introduce the possibility for an inconsistent state ?
Setting parameters in ProblemCreated
state should be fine as far as I know. I added an issue https://github.com/scipopt/russcip/issues/105. I'm just not sure when I'll have time to work on it.
How's the latest?
@lovasoa I'd be happy to make any more changes you suggest. Thanks for the help -- I'm pretty new to Rust and to GitHub collaboration so your feedback has been very useful!
Add a
WithMipGap
trait and implement it forcoin_cbc
,highs
, andlp_solvers
. This trait mimics the trait of the same name that we recently added to the lp-solvers crate.Implementing
WithMipGap
forlpsolve
andscip
appears to be non-trivial so I haven't done those, andminilp
doesn't support integer variables.I created a macro for generating tests of the
WithMipGap
trait. This is my first experience writing a Rust macro so hopefully it's okay. It does work as intended.