-
Notifications
You must be signed in to change notification settings - Fork 35
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
adding possibility to set solver options for MOI constructor #81
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test. For example, setting seconds=0
results in the time limit being hit.
src/MOIWrapper.jl
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the ::Nothing
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To differentiate the default constructor to the one with kwargs.. I took CPLEX.jl example. Apparently I cannot define a default constructor that takes kwargs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then tests fail for julia 0.6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove the inner constructor?
Then it should be valid to call Optimizer(CbcModel())
from the outer constructor that takes keyword arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. I did it
src/MOIWrapper.jl
Outdated
|
||
function Optimizer(;kwargs...) | ||
model = Optimizer(nothing) | ||
for (name,value) in kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting nit: (name, value)
function Optimizer(;kwargs...) | ||
model = Optimizer(nothing) | ||
for (name,value) in kwargs | ||
setParameter(model.inner, string(name), string(value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if an invalid option name is passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cbc ignores unknown names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment here about that?
I am struggling to add the tests. Using cachingoptimizer to setup the model causes MOI to eventually call the |
The implementation of http://www.juliaopt.org/MathOptInterface.jl/dev/apireference/#MathOptInterface.empty!
Solver-specific parameters should be handled like optimizer attributes. |
Ok, I will re-implement the function |
Bump. This would be nice to have ready for the 0.19 release. |
Answering issue #79