Skip to content

Instantly share code, notes, and snippets.

@chkwon
Last active October 18, 2019 01:01
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 chkwon/2e003c0182e9c45e69db9cd210ec9872 to your computer and use it in GitHub Desktop.
Save chkwon/2e003c0182e9c45e69db9cd210ec9872 to your computer and use it in GitHub Desktop.
Shadow Price for LP problems in Julia
using JuMP, GLPK
m = Model(with_optimizer(GLPK.Optimizer))
@variable(m, x1 >= 0)
@variable(m, x2 >= 0)
@objective(m, Max, 3x1 + 5x2)
@constraint(m, c1, x1 <= 4)
@constraint(m, c2, 2x2 <= 12)
@constraint(m, c3, 3x1 + 2x2 <= 18)
optimize!(m)
@show value(x1), value(x2)
@show shadow_price(c1), shadow_price(c2), shadow_price(c3)
@show objective_value(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment