Skip to content

Instantly share code, notes, and snippets.

@odow
Created September 23, 2015 23:18
Show Gist options
  • Save odow/66998c7aab1137e196f7 to your computer and use it in GitHub Desktop.
Save odow/66998c7aab1137e196f7 to your computer and use it in GitHub Desktop.
.nl min function
# uncomment lines 9, 79 in nl_params.jl
using JuMP, AmplNLWriter
m = Model(solver=IpoptNLSolver())
@defVar(m, -1 <= x <= 1)
@setNLObjective(m, Max, min( x, -x, 0.5x-0.25 ))
solve(m)
@show getObjectiveValue(m) # should be -0.1666666666
@show getValue(x) # should be 0.1666666666
g3 1 1 0
1 0 1 0 0 0
0 1
0 0
0 1 0
0 0 0 0
0 0 0 0 0
0 1
0 0
0 0 0 0 0
O0 1
o11
3
v0
o16
v0
o1
o2
n0.5
v0
n0.25
x1
0 0.0
b
0 -1.0 1.0
G0 1
0 0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment