Closed Rahix closed 2 years ago
I think a good solution would be to depend on the almost universal log crate, and set the cbc verbosity based on the standard rust log level. What do you think ?
I think exposing parameters is a good idea: there is log, bit also solver tunning available.
The log crate has a complicated syntax, and levels that doesn't really match with coin.
We don't want people changing the solver parameters, and for instance removing variables from under our feet, do we ?
How is the log crate syntax complicated?
I would prefer having direct access to the parameter here. I feel like wiring this up to log
is be not a good idea:
log
provides a mechanism for libraries and applications to write log messages and an implementation of a filtering mechanism to only show some of those messages. Especially, behind log
you'll always need a backend which actually takes care of logging the generated messages somewhere and initializing the filters. CBC doesn't care about all this and just writes its messages to stdout directly. So it wouldn't really tie into the log
ecosystem at all. The only "connection" which could be made is by asking log
of the (default!) log-level and setting something similar in CBC.log
don't really map to the verbosity levels from CBC well, I think. So it would be confusing for downstream users to understand what log-level from log
corresponds to which setting from CBC.In the end I think this wouldn't gain us much and just make the original task I wanted to accomplish more complicated. I think what I wanted to do is what most people will care about: silencing CBC to keep the console free for actually interesting messages.
We don't want people changing the solver parameters, and for instance removing variables from under our feet, do we ?
That's why I would suggest making the access to the CBC model "unsafe":
unsafe fn as_inner_mut(&mut self) -> &mut Model {
// ...
}
This way people can't possibly destroy invariants assumed by good_lp
without unsafe code.
In parallel to adding the above (which is probably useful beyond this issue alone), for logging in particular, maybe adding another method specifically to set the verbosity might be a good idea? It would certainly help people searching through good_lp
documentation for terms like "log" or "verbosity" to find what they need... For example:
fn set_solver_verbosity(&mut self, v: &str) {
// ...
}
You can also add a fn set_parameter(key: &str, value: &str)
without any invariant breaking.
I would like to add that we are experiencing the same problems in the highs solver. Any way of changing the verbosity would be extremely appreciated. I think being able to set the options on the models themselves would be extremely useful.
Hi,
I was wondering how I can set the verbosity level of coin_cbc through this crate. I found https://github.com/KardinalAI/coin_cbc/issues/3 which looks to be what I want. I also saw that I can get an
&Model
fromCoinCbcProblem::as_inner()
. The problem is thatModel::set_parameter()
requires an&mut
reference while I can only obtain an immutable one.Is there a different solution which I missed? If not, maybe a second method could be added to
CoinCbcProblem
for getting a mutable reference? If this could prove hazardous for upkeeping internal invariants, making this methodunsafe
would seem like a good compromise to me.