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
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion src/MOIWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

end

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)

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?

end
return model
end

struct CbcModelFormat
Expand Down