Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributes are ignored with JuMP #171

Closed
mjyshin opened this issue Jul 12, 2021 · 4 comments
Closed

Attributes are ignored with JuMP #171

mjyshin opened this issue Jul 12, 2021 · 4 comments

Comments

@mjyshin
Copy link

mjyshin commented Jul 12, 2021

I wanted to set some solver attributes using JuMP, e.g.,

model = Model(Cbc.Optimizer)
set_optimizer_attributes(model,"logLevel"=>0)

which wasn't working. Then I noticed that the Cbc wrapper in JuMP seems to be ignoring every attribute I try. For instance, even something ridiculous like set_optimizer_attributes(model,"blah"=>-π) doesn't throw an error. Is there a known solution to this? I was hoping to set verbosity and presolve off, but I'm not sure if that's even possible with Cbc and JuMP.

@odow
Copy link
Member

odow commented Jul 12, 2021

The logLevel issue is: #168. This is a bug in Cbc for LPs.

The "blah" issue is that there is no way for Julia to know the supported parameters of Cbc: #125. We just pass whatever you tell us.

Cbc should be respecting your presolve setting however.

@mjyshin
Copy link
Author

mjyshin commented Jul 13, 2021

I've tried a bunch of different combinations of "Preprocess", "preProcess", "PrepChoice", "presolve", "Presolve", "preSolve", etc. and 0, "off", "0", etc., but none seems to turn off the presolve off. Also, if the attributes are indeed passed, shouldn't "logLevel"=>0 keep Cbc from from printing to screen?

@odow
Copy link
Member

odow commented Jul 13, 2021

keep Cbc from from printing to screen

As linked about (#168), there is a bug in Cbc. It ignores the logLevel option when solving LPs:

julia> using JuMP, Cbc

julia> model = Model(Cbc.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: COIN Branch-and-Cut (Cbc)

julia> set_optimizer_attribute(model, "logLevel", 0)
0

julia> @variable(model, x >= 2)
x

julia> @objective(model, Min, x + 1)
x + 1

julia> optimize!(model)
Optimal - objective value 2
Optimal objective 2 - 0 iterations time 0.002

julia> using JuMP, Cbc

julia> model = Model(Cbc.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: COIN Branch-and-Cut (Cbc)

julia> set_optimizer_attribute(model, "logLevel", 0)
0

julia> @variable(model, x >= 2, Int)
x

julia> @objective(model, Min, x + 1)
x + 1

julia> optimize!(model)

presolve also works.

julia> using JuMP, Cbc

julia> model = Model(Cbc.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: COIN Branch-and-Cut (Cbc)

julia> set_optimizer_attribute(model, "logLevel", 2)
2

julia> set_optimizer_attribute(model, "presolve", "off")
"off"

julia> @variable(model, x >= 2, Int)
x

julia> @objective(model, Min, x + 1)
x + 1

julia> optimize!(model)
Welcome to the CBC MILP Solver 
Version: 2.10.5 
Build Date: Mar 11 2021 

command line - Cbc_C_Interface -presolve off -logLevel 2 -solve -quit (default strategy 1)
Option for presolve changed from on to off
logLevel was changed from 1 to 2
Continuous objective value is 2 - 0.00 seconds
Cgl0004I processed model has 0 rows, 0 columns (0 integer (0 of which binary)) and 0 elements
Cbc3007W No integer variables - nothing to do
Cuts at root node changed objective from 2 to -1.79769e+308
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:                2.00000000
Enumerated nodes:               0
Total iterations:               0
Time (CPU seconds):             0.00
Time (Wallclock seconds):       0.00

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

The README explains how to check what options do what: https://github.com/jump-dev/Cbc.jl#options

@odow
Copy link
Member

odow commented Aug 16, 2021

Closing as a duplicate of #125 and #168

@odow odow closed this as completed Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants