Skip to content

Instantly share code, notes, and snippets.

@cocomoff
Created April 10, 2017 14:48
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 cocomoff/312d80d4ad594b7ef34dbc4e4078c9ce to your computer and use it in GitHub Desktop.
Save cocomoff/312d80d4ad594b7ef34dbc4e4078c9ce to your computer and use it in GitHub Desktop.
# example: http://www.fujilab.dnj.ynu.ac.jp/lecture/system2.pdf
using JuMP
using Clp
m = Model(solver = ClpSolver())
@variable(m, 0 <= x1 <= Inf)
@variable(m, 0 <= x2 <= Inf)
# 目的関数
@objective(m, Min, -400x1 - 300x2)
# 制約
@constraint(m, 60x1 + 40x2 <= 3800)
@constraint(m, 20x1 + 30x2 <= 2100)
@constraint(m, 20x1 + 10x2 <= 1200)
# 解を求める
ans = solve(m)
println(getobjectivevalue(m)) # -27000
println(getvalue(x)) # 30
println(getvalue(x2)) # 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment