Skip to content

Commit

Permalink
fix #523
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Aug 11, 2015
1 parent 74f5ed4 commit 4b4c463
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/nlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ function _buildInternalModel_nlp(m::Model, traits)
MathProgBase.loadnonlinearproblem!(m.internalModel, m.numCols, numConstr, m.colLower, m.colUpper, [linrowlb;quadrowlb;nlrowlb], [linrowub;quadrowub;nlrowub], m.objSense, d)
if traits.int
if applicable(MathProgBase.setvartype!, m.internalModel, m.colCat)
MathProgBase.setvartype!(m.internalModel, m.colCat)
MathProgBase.setvartype!(m.internalModel, vartypes_without_fixed(m))
else
error("Solver does not support discrete variables")
end
Expand Down
5 changes: 3 additions & 2 deletions test/nonlinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,11 @@ MathProgBase.optimize!(m::DummyNLPModel) = nothing
MathProgBase.status(m::DummyNLPModel) = :Optimal
MathProgBase.getobjval(m::DummyNLPModel) = NaN
MathProgBase.getsolution(m::DummyNLPModel) = [1.0,1.0]
MathProgBase.setvartype!(m::DummyNLPModel,vartype) = @fact any(vartype .== :Fixed) --> false
function test_nl_mpb()
m = Model(solver=DummyNLPSolver())
@defVar(m, x)
@defVar(m, y)
@defVar(m, x == 1)
@defVar(m, y, Bin)
@setObjective(m, Min, -x+y)
@addConstraint(m, 2x+y <= 1)
@addConstraint(m, 2x+y <= 0)
Expand Down

4 comments on commit 4b4c463

@joehuchette
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize this isn't the issue here, but I think we should probably be more careful about when we pass arrays (m.colCat) rather than copies (vartypes_without_fixed(m)) through MPB.

@mlubin
Copy link
Member Author

@mlubin mlubin commented on 4b4c463 Aug 11, 2015

Choose a reason for hiding this comment

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

@joehuchette
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, the opposite approach works as well if it's documented. I'm guessing (hoping) solvers won't alter any data passed to them?

@mlubin
Copy link
Member Author

@mlubin mlubin commented on 4b4c463 Aug 11, 2015

Choose a reason for hiding this comment

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

I don't think they should.

Please sign in to comment.