Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message of unsupported constraints #2680

Closed
odow opened this issue Sep 2, 2021 · 1 comment · Fixed by #2685
Closed

Improve error message of unsupported constraints #2680

odow opened this issue Sep 2, 2021 · 1 comment · Fixed by #2685
Labels
good first issue This issue is recommended for new users, it does not require a thorough understanding of the package Status: Help Wanted Help is welcome on this issue Type: Error Messages Can be fixed with better error message

Comments

@odow
Copy link
Member

odow commented Sep 2, 2021

The error message below is not friendly or helpful for new users. (It came up on Discourse, and it is one of the more frequent questions we get asked.)

Perhaps something like:

`MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are
not supported by this solver.

If you expected the solver to support your problem, you may have an error in
your formulation. Otherwise, consider using a different solver.

The list of available solvers, along with the problem types they support, is
available at https://jump.dev/JuMP.jl/stable/installation/#Supported-solvers.

For advanced users, you can view the attempts we made at bridging this
constraint by calling
`JuMP.debug(model, MOI.ScalarQuadraticFunction{Float64}, MOI.EqualTo{Float64})`.

Current error messsage

julia> using JuMP, Cbc

julia> m = Model(Cbc.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: COIN Branch-and-Cut (Cbc)

julia> @variable(m, x1)
x1

julia> @variable(m, x2)
x2

julia> @constraint(m, constraint1, x1 * x2 == 1)
ERROR: `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are not supported and cannot be bridged into supported constrained variables and constraints. See details below:
 [1] constrained variables in `MOI.RotatedSecondOrderCone` are not supported because:
   Cannot use `MOIB.Variable.RSOCtoSOCBridge{Float64}` because:
   [2] constrained variables in `MOI.SecondOrderCone` are not supported
   Cannot use `MOIB.Variable.RSOCtoPSDBridge{Float64}` because:
   [5] constrained variables in `MOI.PositiveSemidefiniteConeTriangle` are not supported
   Cannot add free variables and then constrain them because:
   (9) `MOI.VectorOfVariables`-in-`MOI.RotatedSecondOrderCone` constraints are not supported
 [2] constrained variables in `MOI.SecondOrderCone` are not supported because:
   Cannot use `MOIB.Variable.SOCtoRSOCBridge{Float64}` because:
   [1] constrained variables in `MOI.RotatedSecondOrderCone` are not supported
   Cannot add free variables and then constrain them because:
   (11) `MOI.VectorOfVariables`-in-`MOI.SecondOrderCone` constraints are not supported
 [5] constrained variables in `MOI.PositiveSemidefiniteConeTriangle` are not supported because no added bridge supports bridging it.
   Cannot add free variables and then constrain them because:
   (18) `MOI.VectorOfVariables`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported
 (1) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are not supported because:
   Cannot use `MOIB.Constraint.VectorizeBridge{Float64, MOI.VectorQuadraticFunction{Float64}, MOI.Zeros, MOI.ScalarQuadraticFunction{Float64}}` because:
   (2) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Zeros` constraints are not supported
   Cannot use `MOIB.Constraint.SplitIntervalBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.EqualTo{Float64}, MOI.GreaterThan{Float64}, MOI.LessThan{Float64}}` because:
   (7) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.GreaterThan{Float64}` constraints are not supported
   (5) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.LessThan{Float64}` constraints are not supported
 (2) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Zeros` constraints are not supported because:
   Cannot use `MOIB.Constraint.ScalarizeBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.EqualTo{Float64}}` because:
   (1) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.SplitIntervalBridge{Float64, MOI.VectorQuadraticFunction{Float64}, MOI.Zeros, MOI.Nonnegatives, MOI.Nonpositives}` because:
   (3) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Nonnegatives` constraints are not supported
   (4) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Nonpositives` constraints are not supported
 (3) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Nonnegatives` constraints are not supported because:
   Cannot use `MOIB.Constraint.NonnegToNonposBridge{Float64, MOI.VectorQuadraticFunction{Float64}, MOI.VectorQuadraticFunction{Float64}}` because:
   (4) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Nonpositives` constraints are not supported
   Cannot use `MOIB.Constraint.ScalarizeBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.GreaterThan{Float64}}` because:
   (7) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.GreaterThan{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.VectorSlackBridge{Float64, MOI.VectorQuadraticFunction{Float64}, MOI.Nonnegatives}` because:
   (2) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Zeros` constraints are not supported
 (4) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Nonpositives` constraints are not supported because:
   Cannot use `MOIB.Constraint.NonposToNonnegBridge{Float64, MOI.VectorQuadraticFunction{Float64}, MOI.VectorQuadraticFunction{Float64}}` because:
   (3) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Nonnegatives` constraints are not supported
   Cannot use `MOIB.Constraint.ScalarizeBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.LessThan{Float64}}` because:
   (5) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.LessThan{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.VectorSlackBridge{Float64, MOI.VectorQuadraticFunction{Float64}, MOI.Nonpositives}` because:
   (2) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Zeros` constraints are not supported
 (5) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.LessThan{Float64}` constraints are not supported because:
   Cannot use `MOIB.Constraint.LessToIntervalBridge{Float64, MOI.ScalarQuadraticFunction{Float64}}` because:
   (6) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.Interval{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.LessToGreaterBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.ScalarQuadraticFunction{Float64}}` because:
   (7) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.GreaterThan{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.VectorizeBridge{Float64, MOI.VectorQuadraticFunction{Float64}, MOI.Nonpositives, MOI.ScalarQuadraticFunction{Float64}}` because:
   (4) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Nonpositives` constraints are not supported
   Cannot use `MOIB.Constraint.ScalarSlackBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.LessThan{Float64}}` because:
   (1) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.QuadtoSOCBridge{Float64}` because:
   (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported
 (6) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.Interval{Float64}` constraints are not supported because:
   Cannot use `MOIB.Constraint.ScalarSlackBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.Interval{Float64}}` because:
   (1) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.SplitIntervalBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.Interval{Float64}, MOI.GreaterThan{Float64}, MOI.LessThan{Float64}}` because:
   (7) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.GreaterThan{Float64}` constraints are not supported
   (5) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.LessThan{Float64}` constraints are not supported
 (7) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.GreaterThan{Float64}` constraints are not supported because:
   Cannot use `MOIB.Constraint.GreaterToIntervalBridge{Float64, MOI.ScalarQuadraticFunction{Float64}}` because:
   (6) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.Interval{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.GreaterToLessBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.ScalarQuadraticFunction{Float64}}` because:
   (5) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.LessThan{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.VectorizeBridge{Float64, MOI.VectorQuadraticFunction{Float64}, MOI.Nonnegatives, MOI.ScalarQuadraticFunction{Float64}}` because:
   (3) `MOI.VectorQuadraticFunction{Float64}`-in-`MOI.Nonnegatives` constraints are not supported
   Cannot use `MOIB.Constraint.ScalarSlackBridge{Float64, MOI.ScalarQuadraticFunction{Float64}, MOI.GreaterThan{Float64}}` because:
   (1) `MOI.ScalarQuadraticFunction{Float64}`-in-`MOI.EqualTo{Float64}` constraints are not supported
   Cannot use `MOIB.Constraint.QuadtoSOCBridge{Float64}` because:
   (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported
 (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported because:
   Cannot use `MOIB.Constraint.VectorSlackBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.RotatedSecondOrderCone}` because:
   [1] constrained variables in `MOI.RotatedSecondOrderCone` are not supported
   Cannot use `MOIB.Constraint.RSOCBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.VectorAffineFunction{Float64}}` because:
   (10) `MOI.VectorAffineFunction{Float64}`-in-`MOI.SecondOrderCone` constraints are not supported
   Cannot use `MOIB.Constraint.RSOCtoPSDBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.VectorAffineFunction{Float64}}` because:
   (17) `MOI.VectorAffineFunction{Float64}`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported
 (9) `MOI.VectorOfVariables`-in-`MOI.RotatedSecondOrderCone` constraints are not supported because:
   Cannot use `MOIB.Constraint.VectorFunctionizeBridge{Float64, MOI.RotatedSecondOrderCone}` because:
   (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported
   Cannot use `MOIB.Constraint.RSOCBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.VectorOfVariables}` because:
   (10) `MOI.VectorAffineFunction{Float64}`-in-`MOI.SecondOrderCone` constraints are not supported
   Cannot use `MOIB.Constraint.RSOCtoPSDBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.VectorOfVariables}` because:
   (17) `MOI.VectorAffineFunction{Float64}`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported
 (10) `MOI.VectorAffineFunction{Float64}`-in-`MOI.SecondOrderCone` constraints are not supported because:
   Cannot use `MOIB.Constraint.VectorSlackBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.SecondOrderCone}` because:
   [2] constrained variables in `MOI.SecondOrderCone` are not supported
   Cannot use `MOIB.Constraint.SOCRBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.VectorAffineFunction{Float64}}` because:
   (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported
 (11) `MOI.VectorOfVariables`-in-`MOI.SecondOrderCone` constraints are not supported because:
   Cannot use `MOIB.Constraint.VectorFunctionizeBridge{Float64, MOI.SecondOrderCone}` because:
   (10) `MOI.VectorAffineFunction{Float64}`-in-`MOI.SecondOrderCone` constraints are not supported
   Cannot use `MOIB.Constraint.SOCRBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.VectorOfVariables}` because:
   (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.RotatedSecondOrderCone` constraints are not supported
 (17) `MOI.VectorAffineFunction{Float64}`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported because:
   Cannot use `MOIB.Constraint.VectorSlackBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.PositiveSemidefiniteConeTriangle}` because:
   [5] constrained variables in `MOI.PositiveSemidefiniteConeTriangle` are not supported
 (18) `MOI.VectorOfVariables`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported because:
   Cannot use `MOIB.Constraint.VectorFunctionizeBridge{Float64, MOI.PositiveSemidefiniteConeTriangle}` because:
   (17) `MOI.VectorAffineFunction{Float64}`-in-`MOI.PositiveSemidefiniteConeTriangle` constraints are not supported

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] moi_add_constraint(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}}, f::MathOptInterface.ScalarQuadraticFunction{Float64}, s::MathOptInterface.EqualTo{Float64})
   @ JuMP ~/.julia/packages/JuMP/b3hGi/src/constraints.jl:524
 [3] add_constraint(model::Model, con::ScalarConstraint{QuadExpr, MathOptInterface.EqualTo{Float64}}, name::String)
   @ JuMP ~/.julia/packages/JuMP/b3hGi/src/constraints.jl:559
 [4] macro expansion
   @ ~/.julia/packages/JuMP/b3hGi/src/macros.jl:677 [inlined]
 [5] top-level scope
   @ REPL[7]:1
@odow odow added Type: Error Messages Can be fixed with better error message Status: Help Wanted Help is welcome on this issue good first issue This issue is recommended for new users, it does not require a thorough understanding of the package labels Sep 2, 2021
@blegat
Copy link
Member

blegat commented Sep 3, 2021

Yes, I think your suggested error message is better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This issue is recommended for new users, it does not require a thorough understanding of the package Status: Help Wanted Help is welcome on this issue Type: Error Messages Can be fixed with better error message
Development

Successfully merging a pull request may close this issue.

2 participants