Skip to content

Commit

Permalink
fixed variables were broken for nonlinear solvers that did not suppor…
Browse files Browse the repository at this point in the history
…t MINLP
  • Loading branch information
joehuchette committed Jan 28, 2015
1 parent e694871 commit fb52dd8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/nlp.jl
Expand Up @@ -463,14 +463,16 @@ function solvenlp(m::Model; suppress_warnings=false)
error("Unrecognized quadratic constraint sense $(c.sense)")
end
end

#print("LB: ");show([linrowlb,nlrowlb]);println()
#print("UB: ");show([linrowub,nlrowub]);println()

m.internalModel = MathProgBase.model(m.solver)

const nl_cont = [:Cont, :Fixed]

MathProgBase.loadnonlinearproblem!(m.internalModel, m.numCols, numConstr, m.colLower, m.colUpper, [linrowlb,quadrowlb,nlrowlb], [linrowub,quadrowub,nlrowub], m.objSense, d)
if any(x->x!=:Cont, m.colCat)
if !all(x->(x in nl_cont), m.colCat)
if applicable(MathProgBase.setvartype!, m.internalModel, m.colCat)
MathProgBase.setvartype!(m.internalModel, m.colCat)
else
Expand Down
14 changes: 14 additions & 0 deletions test/nonlinear.jl
Expand Up @@ -60,6 +60,20 @@ context("With solver $(typeof(nlp_solver))") do
[1.000000, 4.742999, 3.821150, 1.379408], 1e-5)
end; end; end

facts("[nonlinear] Accepting fixed variables") do
for nlp_solver in convex_nlp_solvers
context("With solver $(typeof(nlp_solver))") do
m = Model(solver=nlp_solver)
@defVar(m, x == 0)
@defVar(m, y 0)
@setObjective(m, Min, y)
@addNLConstraint(m, y x^2)
for α in 1:4
setValue(x, α)
solve(m)
@fact getValue(y) => roughly^2, 1e-6)
end
end; end; end

facts("[nonlinear] Test QP solve through NL pathway") do
for nlp_solver in convex_nlp_solvers
Expand Down

0 comments on commit fb52dd8

Please sign in to comment.