Skip to content

Improve error messages of various errors - #3036

Merged
odow merged 4 commits into
masterfrom
od/errors
Jul 30, 2026
Merged

Improve error messages of various errors#3036
odow merged 4 commits into
masterfrom
od/errors

Conversation

@odow

@odow odow commented Jul 29, 2026

Copy link
Copy Markdown
Member

I might break out the UnsupportedConstraint into a separate PR, but I'll see the damage here first.

@odow

odow commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

Motivated by jump-dev/Dualization.jl#232

julia> using LinearAlgebra

julia> using Hypatia

julia> using Dualization

julia> using JuMP

julia> function test_dual()
           model = Model()
           @variable(model, M[1:2, 1:2], Symmetric)
           @constraint(model, [1, M[1, 1], sqrt(2) * M[1, 2], M[2, 2]] in Hypatia.EpiNormSpectralTriCone{Float64,Float64}(1 + 3))
           @objective(model, Max, real(tr(M)))
           #set_optimizer(model, Hypatia.Optimizer)
           set_optimizer(model, Dualization.dual_optimizer(Hypatia.Optimizer))
           optimize!(model)
           return value(M)
       end
test_dual (generic function with 1 method)

julia> test_dual()
ERROR: UnsupportedConstraint{
    MathOptInterface.VectorAffineFunction{Float64},
    EpiNormSpectralTriCone{Float64, Float64},
}

This constraint type is not supported by the solver.

To fix this error you must choose a different solver.

## More information

Bridges are enabled, but there are none that can rewrite the constraint into a form supported by the solver.

The model that we were unable to add the constraint to is:

MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{DualOptimizer{Float64, MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{Hypatia.Optimizer{Float64}, MOIU.UniversalFallback{MOIU.Model{Float64}}}}}, MOIU.UniversalFallback{MOIU.Model{Float64}}}}
├ Variable bridges: none
├ Constraint bridges: none
├ Objective bridges: none
└ model: MOIU.CachingOptimizer
  ├ state: EMPTY_OPTIMIZER
  ├ mode: AUTOMATIC
  ├ model_cache: MOIU.UniversalFallback{MOIU.Model{Float64}}
  │ ├ ObjectiveSense: MAX_SENSE
  │ ├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64}
  │ ├ NumberOfVariables: 3
  │ └ NumberOfConstraints: 0
  └ optimizer: DualOptimizer{Float64, MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{Hypatia.Optimizer{Float64}, MOIU.UniversalFallback{MOIU.Model{Float64}}}}}
    ├ ObjectiveSense: unknown
    ├ ObjectiveFunctionType: unknown
    ├ NumberOfVariables: unknown
    └ NumberOfConstraints: unknown

Stacktrace:

@odow

odow commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

cc @araujoms

Comment on lines +554 to +558
constraint into a form supported by the solver.

The model that we were unable to add the constraint to is:

$(sprint(show, model))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constraint into a form supported by the solver.
The model that we were unable to add the constraint to is:
$(sprint(show, model))
constraint into a form supported by the solver $(sprint(show, MOI.get(model, MOI.SolverName())))

I'd just print the solver name instead of the whole model, since the solver is what makes the constraint unsupported.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this isn't print(model), but it's show(model). Which is the high level summary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which still has a lot of irrelevant information.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SolverName drops a lot of relevant information.

julia> MOI.get(b, MOI.SolverName())
"Dual model with Hypatia attached"

It looks through the bridging layer and the cache.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is the result, it's exactly the information I wanted to have, which is why I suggested it.

It's just a suggestion, feel free to ignore it.

├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64}
├ NumberOfVariables: 1
└ NumberOfConstraints: 0
"""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@araujoms here you go

@odow

odow commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

@odow

This comment was marked as outdated.

@blegat blegat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvements

@odow
odow merged commit 9e842ea into master Jul 30, 2026
159 of 170 checks passed
@odow
odow deleted the od/errors branch July 30, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants