Created
April 10, 2017 14:48
-
-
Save cocomoff/312d80d4ad594b7ef34dbc4e4078c9ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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