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

MethodError: no method matching isless(::Int64, ::QuadExpr) / isless(::VariableRef, ::QuadExpr) #3581

Closed
LebedevRI opened this issue Nov 22, 2023 · 1 comment · Fixed by #3584
Labels
Type: Error Messages Can be fixed with better error message

Comments

@LebedevRI
Copy link
Contributor

using JuMP, SCIP

model = Model(SCIP.Optimizer)

@variable(model, a)
@variable(model, b)
@variable(model, c)

@variable(model, d)
@variable(model, e)

@constraint(model, (a*b >= c) => {d == e})

print(model)
MethodError: no method matching isless(::VariableRef, ::QuadExpr)

Closest candidates are:
  isless(::Any, ::Missing)
   @ Base missing.jl:88
  isless(::Missing, ::Any)
   @ Base missing.jl:87


Stacktrace:
 [1] <(x::VariableRef, y::QuadExpr)
   @ Base ./operators.jl:343
 [2] <=(x::VariableRef, y::QuadExpr)
   @ Base ./operators.jl:392
 [3] >=(x::QuadExpr, y::VariableRef)
   @ Base ./operators.jl:416
 [4] macro expansion
   @ ~/.julia/packages/JuMP/D44Aq/src/macros.jl:1345 [inlined]
 [5] top-level scope
   @ In[30]:12
using JuMP, SCIP

model = Model(SCIP.Optimizer)

@variable(model, a)
@variable(model, b)

@variable(model, d)
@variable(model, e)

@constraint(model, (a*b >= 42) => {d == e})

print(model)
MethodError: no method matching isless(::Int64, ::QuadExpr)

Closest candidates are:
  isless(::Integer, ::ForwardDiff.Dual{Ty}) where Ty
   @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:145
  isless(::Real, ::AbstractFloat)
   @ Base operators.jl:178
  isless(::Real, ::ForwardDiff.Dual{Ty}) where Ty
   @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:145
  ...


Stacktrace:
 [1] <(x::Int64, y::QuadExpr)
   @ Base ./operators.jl:343
 [2] <=(x::Int64, y::QuadExpr)
   @ Base ./operators.jl:392
 [3] >=(x::QuadExpr, y::Int64)
   @ Base ./operators.jl:416
 [4] macro expansion
   @ ~/.julia/packages/JuMP/D44Aq/src/macros.jl:1345 [inlined]
 [5] top-level scope
   @ In[33]:11

If i launder a*b >= c through an expression, #3580 happens.

@odow
Copy link
Member

odow commented Nov 22, 2023

You cannot use inequalities in the left-hand side of an indicator constraint. It just be a single binary variable:
https://jump.dev/JuMP.jl/stable/manual/constraints/#Indicator-constraints

We should add a better error message for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Error Messages Can be fixed with better error message
Development

Successfully merging a pull request may close this issue.

2 participants