rust-or / good_lp

Linear Programming for Rust, with a user-friendly API. This crate allows modeling LP problems, and lets you solve them with various solvers.
https://crates.io/crates/good_lp
MIT License
216 stars 35 forks source link

Suppressing Cbc command line output #30

Closed cristianpjensen closed 4 months ago

cristianpjensen commented 1 year ago

When running the solver, I get the following output to my command line:

Welcome to the CBC MILP Solver
Version: 2.10.10
Build Date: Apr 20 2023

command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is 12.5141 - 0.00 seconds
Cgl0004I processed model has 3 rows, 5 columns (5 integer (1 of which binary)) and 15 elements
Cutoff increment increased from 1e-05 to 0.0999
Cbc0012I Integer solution of 12.6 found by DiveCoefficient after 0 iterations and 0 nodes (0.00 seconds)
Cbc0001I Search completed - best objective 12.6, took 1 iterations and 0 nodes (0.00 seconds)
Cbc0035I Maximum depth 0, 1 variables fixed on reduced cost
Cuts at root node changed objective from 12.5221 to 12.6
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)

Result - Optimal solution found

Objective value:                12.60000000
Enumerated nodes:               0
Total iterations:               1
Time (CPU seconds):             0.00
Time (Wallclock seconds):       0.00

Total time (CPU seconds):       0.00   (Wallclock seconds):       0.00

However, I am also using the command line to output results of my program. Would it be possible to suppress this output to not show?

mfuhr commented 10 months ago

You should be able to suppress most or all of Cbc's output by setting the log level to 0:

let mut model = vars.maximise(objective).using(coin_cbc);
model.set_parameter("loglevel", "0");