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

Ignore threads parameter on Windows #192

Merged
merged 3 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,24 @@ function MOI.set(
if !MOI.supports(model, param)
throw(MOI.UnsupportedAttribute(param))
end
name = string(param.name)
model.params[name] = value
if !(model.silent && name == "logLevel")
Cbc_setParameter(model, name, value)
model.params[param.name] = value
if param.name == "threads" && Sys.iswindows()
@warn(
"Ignoring threads parameter due to known bugs in Cbc.jl. Read " *
"https://github.com/jump-dev/Cbc.jl/issues/186 for more details.",
)
return
end
if !(model.silent && param.name == "logLevel")
Cbc_setParameter(model, param.name, value)
end
return
end

function MOI.get(model::Optimizer, param::MOI.RawOptimizerAttribute)
# TODO: This gives a poor error message if the name of the parameter is
# invalid.
return model.params[string(param.name)]
return model.params[param.name]
end

MOI.supports(::Optimizer, ::MOI.Silent) = true
Expand Down Expand Up @@ -155,7 +161,7 @@ function MOI.empty!(model::Optimizer)
model.termination_status = Cint(-1)
model.solve_time = 0.0
for (name, value) in model.params
Cbc_setParameter(model, name, value)
MOI.set(model, MOI.RawOptimizerAttribute(name), value)
end
if model.silent
Cbc_setParameter(model, "logLevel", "0")
Expand Down
5 changes: 0 additions & 5 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ Test solving a model with the threads parameter set.
See issues #112 and #186.
"""
function test_threads()
if Sys.iswindows()
# This test is broken on Windows with a weird error.
@test_broken 1 == 2
return
end
model = MOI.Utilities.CachingOptimizer(
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
MOI.instantiate(Cbc.Optimizer; with_bridge_type = Float64),
Expand Down