Sometimes no objective_bound info from an LP solve, by Gurobi

WalterMadelim
Thu, 15 Jan 2026 14:44:03 +0000
Optimization (Mathematical)

I solved an LP by Gurobi using

Non-default parameters:
Method  6
Crossover  0
PDHGGPU  1

And here’s the result

julia> model
A JuMP Model
├ mode: DIRECT
├ solver: Gurobi
├ objective_sense: MIN_SENSE
│ └ objective_function_type: JuMP.AffExpr
├ num_variables: 51762757
├ num_constraints: 130897631
│ ├ JuMP.VariableRef in MOI.GreaterThan{Float64}: 51759445
│ ├ JuMP.AffExpr in MOI.GreaterThan{Float64}: 13570000
│ ├ JuMP.VariableRef in MOI.LessThan{Float64}: 24619445
│ ├ JuMP.AffExpr in MOI.LessThan{Float64}: 40715428
│ └ JuMP.AffExpr in MOI.EqualTo{Float64}: 233313
└ Names registered in the model: none

julia> JuMP.solution_summary(model)
solution_summary(; result = 1, verbose = false)
├ solver_name          : Gurobi
├ Termination
│ ├ termination_status : OPTIMAL
│ ├ result_count       : 1
│ └ raw_status         : Model was solved to optimality (subject to tolerances), and an optimal solution is available.
├ Solution (result = 1)
│ ├ primal_status        : FEASIBLE_POINT
│ ├ dual_status          : FEASIBLE_POINT
│ ├ objective_value      : 6.70482e+02
│ └ dual_objective_value : 6.70480e+02
└ Work counters
  ├ solve_time (sec)   : 3.85499e+03
  ├ simplex_iterations : 0
  ├ barrier_iterations : 0
  └ node_count         : 0

I fail to query the objective_bound. Why?

julia> JuMP.objective_bound(model)
ERROR: MathOptInterface.GetAttributeNotAllowed{MathOptInterface.ObjectiveBound}:

## Cause

Getting attribute MathOptInterface.ObjectiveBound() cannot be performed

## Fixing this error

An `MOI.NotAllowedError` error occurs when you have tried to do something that
is not implemented by the solver.

The most common way to fix this error is to wrap the optimizer in a
`MOI.Utilities.CachingOptimizer`.

For example, if you are using `JuMP.Model` or `JuMP.set_optimizer`, do:

model = JuMP.Model(optimizer; with_cache_type = Float64)
model = JuMP.GenericModel{T}(optimizer; with_cache_type = T)
JuMP.set_optimizer(model, optimizer; with_cache_type = Float64)

Similarly, if you are using `MOI.instantiate`, do:

model = MOI.instantiate(optimizer; with_cache_type = Float64)


Stacktrace:
 [1] get(model::Gurobi.Optimizer, attr::MathOptInterface.ObjectiveBound)
   @ Gurobi ~/.julia/packages/Gurobi/Wo3Rk/src/MOI_wrapper/MOI_wrapper.jl:3344
 [2] _moi_get_result(model::Gurobi.Optimizer, args::MathOptInterface.ObjectiveBound)
   @ JuMP ~/.julia/packages/JuMP/N7h14/src/optimizer_interface.jl:1190
 [3] get(model::JuMP.Model, attr::MathOptInterface.ObjectiveBound)
   @ JuMP ~/.julia/packages/JuMP/N7h14/src/optimizer_interface.jl:1219
 [4] objective_bound(model::JuMP.Model)
   @ JuMP ~/.julia/packages/JuMP/N7h14/src/objective.jl:78
 [5] top-level scope
   @ REPL[35]:1

14 posts - 2 participants