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

adding possibility to set solver options for MOI constructor #81

Closed
wants to merge 2 commits into from
Closed

adding possibility to set solver options for MOI constructor #81

wants to merge 2 commits into from

Conversation

vitornesello
Copy link
Contributor

@vitornesello vitornesello commented Nov 17, 2018

Answering issue #79

Copy link
Member

@mlubin mlubin left a 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.

@@ -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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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


function Optimizer(;kwargs...)
model = Optimizer(nothing)
for (name,value) in kwargs
Copy link
Member

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))
Copy link
Member

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?

Copy link
Contributor Author

@vitornesello vitornesello Nov 17, 2018

Choose a reason for hiding this comment

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

Cbc ignores unknown names

Copy link
Member

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?

@vitornesello
Copy link
Contributor Author

I am struggling to add the tests. Using cachingoptimizer to setup the model causes MOI to eventually call the MOI.empty(::MOI.Optimizer) function, which erases all the parameters.

@mlubin
Copy link
Member

mlubin commented Nov 17, 2018

The implementation of MOI.empty! isn't supposed to erase the parameters.

http://www.juliaopt.org/MathOptInterface.jl/dev/apireference/#MathOptInterface.empty!

Empty the model, that is, remove all variables, constraints and model attributes but not optimizer attributes.

Solver-specific parameters should be handled like optimizer attributes.

@vitornesello
Copy link
Contributor Author

Ok, I will re-implement the function empty

@mlubin
Copy link
Member

mlubin commented Feb 1, 2019

Bump. This would be nice to have ready for the 0.19 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants