Skip to content

Instantly share code, notes, and snippets.

@jac0320
Created April 20, 2018 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jac0320/e87aa800d50d290ff0ad7deecc2b3b9e to your computer and use it in GitHub Desktop.
Save jac0320/e87aa800d50d290ff0ad7deecc2b3b9e to your computer and use it in GitHub Desktop.
using JuMP, Ipopt
m = Model(solver=IpoptSolver())
lowub = parse(ARGS[1])
highub = parse(ARGS[2])
@variable(m, x[1:8])
setlowerbound(x[1], 100)
setlowerbound(x[2], 1000)
setlowerbound(x[3], 1000)
setlowerbound(x[4], 10)
setlowerbound(x[5], 10)
setlowerbound(x[6], 10)
setlowerbound(x[7], 10)
setlowerbound(x[8], 10)
setupperbound(x[1], highub)
setupperbound(x[2], highub)
setupperbound(x[3], highub)
setupperbound(x[4], lowub)
setupperbound(x[5], lowub)
setupperbound(x[6], lowub)
setupperbound(x[7], lowub)
setupperbound(x[8], lowub)
@constraint(m, 0.0025*(x[4] + x[6]) <= 1)
@constraint(m, 0.0025*(x[5] - x[4] + x[7]) <= 1)
@constraint(m, 0.01(x[8]-x[5]) <= 1)
@NLconstraint(m, 100*x[1] - x[1]*x[6] + 833.33252*x[4] <= 83333.333)
@NLconstraint(m, x[2]*x[4] - x[2]*x[7] - 1250*x[4] + 1250*x[5] <= 0)
@NLconstraint(m, x[3]*x[5] - x[3]*x[8] - 2500*x[5] + 1250000 <= 0)
@objective(m, Min, x[1]+x[2]+x[3])
solve(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment