From 7b0e6c0b314c100e55dc423c54b8fca021521356 Mon Sep 17 00:00:00 2001 From: Vitor Nesello Date: Sat, 17 Nov 2018 17:07:18 +0100 Subject: [PATCH 1/2] adding possibility to set solver options for MOI constructor --- src/MOIWrapper.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/MOIWrapper.jl b/src/MOIWrapper.jl index a052f5e..b7ebde0 100644 --- a/src/MOIWrapper.jl +++ b/src/MOIWrapper.jl @@ -8,7 +8,15 @@ const CbcCI = CbcCInterface mutable struct Optimizer <: MOI.AbstractOptimizer inner::CbcModel - Optimizer() = new(CbcModel()) # Initializes with an empty model + Optimizer(::Nothing) = new(CbcModel()) # Initializes with an empty model +end + +function Optimizer(;kwargs...) + model = Optimizer(nothing) + for (name,value) in kwargs + setParameter(model.inner, string(name), string(value)) + end + return model end struct CbcModelFormat From 5d4f3f40939af1e435cd2c2ba46cde558c867808 Mon Sep 17 00:00:00 2001 From: Vitor Nesello Date: Sat, 17 Nov 2018 18:46:56 +0100 Subject: [PATCH 2/2] comments by mlubin --- src/MOIWrapper.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/MOIWrapper.jl b/src/MOIWrapper.jl index b7ebde0..6c41f1c 100644 --- a/src/MOIWrapper.jl +++ b/src/MOIWrapper.jl @@ -8,12 +8,11 @@ const CbcCI = CbcCInterface mutable struct Optimizer <: MOI.AbstractOptimizer inner::CbcModel - Optimizer(::Nothing) = new(CbcModel()) # Initializes with an empty model end -function Optimizer(;kwargs...) - model = Optimizer(nothing) - for (name,value) in kwargs +function Optimizer(;kwargs...) + model = Optimizer(CbcModel()) + for (name, value) in kwargs # Cbc ignores unknown parameters setParameter(model.inner, string(name), string(value)) end return model