Skip to content

Commit

Permalink
Ignore threads parameter on Windows (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Mar 3, 2022
1 parent 1381e57 commit e76d4b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
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. 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

2 comments on commit e76d4b6

@odow
Copy link
Member Author

@odow odow commented on e76d4b6 Mar 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/55853

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" e76d4b67d650ef3ec6c04c5f5b533a88691cbc1c
git push origin v1.0.0

Please sign in to comment.