2

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

graphtheory123
  • 311
  • 1
  • 6

1 Answers1

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