martinbiel / StochasticPrograms.jl

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

How to access the optimal values of the second stage variables #37

Closed Lessvn closed 2 years ago

Lessvn commented 2 years ago

Hello, I am trying to run the farmer.jl example. The model works find and the optimal solution is found. However when I enter JuMP.value.(w) following command to get the values of the second stage variables w, it says UndefVarError: w not defined. Could you please let me know if I am missing something here? Thanks!

martinbiel commented 2 years ago

You need to first access the recourse decision using for example w = sp[2,:w] (2 for stage 2 and :w for the relevant variable). Because the value is scenario dependent, you need to specify the scenario: JuMP.value(w,1) (for the optimal value in the first scenario). This is explained further in the documentation.

Consider discourse for further usage questions as the answers will be more easily accessible for others :slightly_smiling_face: