martinbiel / StochasticPrograms.jl

Julia package for formulating and analyzing stochastic recourse models.
MIT License
75 stars 25 forks source link

Shadow price of named constraint #38

Closed simontherien closed 2 years ago

simontherien commented 2 years ago

Hello, I am trying to retrieve the shadow price for a first stage constraint @constraint(slpr_bp, cap, x_1 + x_2 <= 4 - η_hat) as such but I get the error UndefVarError: cap not defined when calling shadow_price(cap, 1) JuMP method (1 for first stage). Is this expected? How do I explicitly reference a named constraint of a certain stage? Thanks!

martinbiel commented 2 years ago

You need to acquire a SPConstraintRef of the desired constraint first. The easiest for a named constraint is through cap = sp[1,:cap], where sp is your stochastic program instance and 1 is the stage. Relevant docs are here.