Get results from CBC solver for optimization

I would like to know how to access the results (constraints value, variable value) from the model created using Cbc and Jump model in Julia

You can find all information on accessing solutions (objective values, variable values, etc.)
here.

For example, for a JuMP model with name model, variables x, and constraint c:
Objective value can be accessed as objective_value(model). [See here]
Variable values can be accessed as value.(x). [See here]
Constraint value at the solution can be accessed as value(c).

2 Likes

Thank you for the quick support. As I can extract the variable value from the model, but the same is not working for constraints
tried this command

value.(model[:con_ineflow_lower])

getting like this “” no method matching value(::Vector{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.GreaterThan{Float64}}, ScalarShape}})“”

It is working fine for me:
If we take the following example:

using JuMP
using Gurobi

model = Model()
set_optimizer(model, Gurobi.Optimizer)

#Define variables
@variable(model, x>=0)
@variable(model, y>=0)

#Define Constraints
@constraint(model, c1, 3x+2y<=66)
@constraint(model, c2, 9x+4y<=180)
@constraint(model, c3, 2x+10y<=200)

#Define Objective
@objective(model, Max, 90x+75y)

optimize!(model)

Now, to extract values:

objective_value(model)  #returns 2250.0
value(x) # returns 10.0
value(y) #returns 18.0
value(c1) #returns 66.0 
value(c2) #returns 162.0 
value(c3) #returns 200.0 

This link helps explain what makes it easier for others to help you out. Maybe you want to share an MWE(minimal working example) which would make it easier for others to debug.

Also, update your JuMP version if you are using an old version.

Thanks and I am able to get the results for most constraints except 1 and I will crosscheck again if there is some errors in the constraints

Thanks again!