Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
update old JuMP syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Aug 2, 2016
1 parent 007e5d9 commit edd6625
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
JuMP 0.7
JuMP 0.13
FactCheck
28 changes: 14 additions & 14 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ using Base.Test

# JuMP version of bonminEx1_Nonlinear.osil
m = Model(solver = OsilSolver())
@defVar(m, 0 <= x0 <= 1, Bin)
@defVar(m, x1 >= 0)
@defVar(m, x2 >= 0)
@defVar(m, 0 <= x3 <= 5, Int)
@setObjective(m, Min, x0 - x1 - x2)
#@setNLObjective(m, Min, x1/x2)
@addNLConstraint(m, (x1 - 0.5)^2 + (x2 - 0.5)^2 <= 1/π)
@addConstraint(m, x0 - x1 <= 0)
@addConstraint(m, x1 + x2 + x3 <= 2)
#@addNLConstraint(m, 1 <= log(x1/x2))
@variable(m, 0 <= x0 <= 1, Bin)
@variable(m, x1 >= 0)
@variable(m, x2 >= 0)
@variable(m, 0 <= x3 <= 5, Int)
@objective(m, Min, x0 - x1 - x2)
#@NLobjective(m, Min, x1/x2)
@NLconstraint(m, (x1 - 0.5)^2 + (x2 - 0.5)^2 <= 1/π)
@constraint(m, x0 - x1 <= 0)
@constraint(m, x1 + x2 + x3 <= 2)
#@NLconstraint(m, 1 <= log(x1/x2))


#d = JuMP.JuMPNLPEvaluator(m, JuMP.prepConstrMatrix(m))
Expand All @@ -26,11 +26,11 @@ solve(m)
nvar = 10
solver=OsilSolver(solver = "couenne")
m = Model(solver=solver)
@defVar(m, -10 <= x[i=1:nvar] <= 10)
@setNLObjective(m, Min, sum{1/(1+exp(-x[i])), i=1:nvar})
@addConstraint(m, sum{x[i], i=1:nvar} <= .4*nvar)
@variable(m, -10 <= x[i=1:nvar] <= 10)
@NLobjective(m, Min, sum{1/(1+exp(-x[i])), i=1:nvar})
@constraint(m, sum{x[i], i=1:nvar} <= .4*nvar)
@test solve(m) == :Optimal
@test isapprox(getValue(x[1]),-10.0)
@test isapprox(getvalue(x[1]),-10.0)


include(Pkg.dir("JuMP","test","runtests.jl"))

0 comments on commit edd6625

Please sign in to comment.