Skip to content

Instantly share code, notes, and snippets.

@odow
Last active September 22, 2015 00:20
Show Gist options
  • Save odow/32bb5cde5c94f60d4886 to your computer and use it in GitHub Desktop.
Save odow/32bb5cde5c94f60d4886 to your computer and use it in GitHub Desktop.
using AmplNLWriter
using JuMP
function foo(want_to_work)
a, b= 1, 0.8
m = Model(solver=IpoptNLSolver(Dict{ASCIIString, Any}("print_level"=>1)))
@defVar(m, 0 <= x <= 1)
@defVar(m, 0 <= y <= 1)
if want_to_work
@addConstraint(m, x <= a * y * b)
else
@addNLConstraint(m, x <= a * y * b)
end
@setNLObjective(m, Max, x)
solve(m)
@show getValue(x)
@show a * getValue(y) * b
@assert getValue(x) <= a * getValue(y) * b + 1e-5
end
println("This should work")
foo(true)
println("This should fail")
foo(false)
println("But neither did")
g3 1 1 0
2 1 1 1 0 0
0 0
0 0
0 0 0
0 0 0 0
0 0 0 0 0
2 1
0 0
0 0 0 0 0
C0
n0
O0 1
n0
d1
0 0
x2
0 0.0
1 0.0
r
1 -0.0
b
0 0.0 1.0
0 0.0 1.0
k1
1
J0 2
0 1.0
1 -0.8
G0 1
0 1.0
g3 1 1 0
2 1 1 1 0 0
0 0
0 0
0 0 0
0 0 0 0
0 0 0 0 0
2 1
0 0
0 0 0 0 0
C0
n0
O0 1
n0
d1
0 0
x2
0 0.0
1 0.0
r
1 0.0
b
0 0.0 1.0
0 0.0 1.0
k1
1
J0 2
0 1.0
1 -1.0
G0 1
0 1.0
@odow
Copy link
Author

odow commented Sep 22, 2015

The diff is:

  • line 21 (sign of zero. Not sure if it matters)
  • line 29. Wrong value. (-1.0 instead of -0.8)

@odow
Copy link
Author

odow commented Sep 22, 2015

Also, Ipopt.jl passes both tests

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