I am using the JuMP package in julia with gurobi, and I can't seem to find any information online about how to print out an optimal solution. I can get the optimal objective value, but can't seem to find info on how to get an optimal solution. I tried solution_summary, but that gave me an error
Asked
Active
Viewed 384 times
2
-
Here's the documentation https://jump.dev/JuMP.jl/stable/tutorials/getting_started/getting_started_with_JuMP/ – Oscar Dowson Mar 06 '22 at 06:10
-
What's the error? – SecretAgentMan Dec 29 '22 at 18:19
1 Answers
2
Just use value(varname)
such as:
m = Model(Gurobi.Optimizer);
@variable(m, x[1:2] >= 0)
@constraint(m, [1 2;3 4] * x .<= [10,20])
@objective(m, Max, [1,2]' * x )
optimize!(m)
and now:
julia> value.(x)
2-element Vector{Float64}:
0.0
5.0
Note that even if the model is MILP, the value
will be always Float64
so usually you end up wanting to round it in some way or other.

Przemyslaw Szufel
- 40,002
- 3
- 32
- 62