Get variable's value in JuMP

Hi All,

I have solved an optimization problem using Julia (1.3.1) and JuMP (0.21.3). I can print the model and see the constraints. I also can get the objective function’s value using (objective_value(model)) . However, I cannot get the variables’ value. I have tried different commands to do so including value.(x) but I get the following error. Please let me know how I can get the variables’ value. I am using MOsek as a solver.

ERROR: LoadError: UndefVArError: x not defined

Thanks in advance!

Seems like x doesn’t exist. Perhaps your variable is named something else, or defined in a different scope. Can you post the relevant code that 1. defines the variable x, and 2. tries to get its value after optimizing?

2 Likes

Try value.(model[:x])

https://jump.dev/JuMP.jl/stable/variables/

4 Likes