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

MOI.Interval with pi error #2576

Closed
johnaoga opened this issue Nov 2, 2024 · 1 comment · Fixed by #2577
Closed

MOI.Interval with pi error #2576

johnaoga opened this issue Nov 2, 2024 · 1 comment · Fixed by #2577

Comments

@johnaoga
Copy link

johnaoga commented Nov 2, 2024

Hello,

I'm working with MOI.Interval and pi and got into the following error that is of course easy to solve on my side using 0+pi or 1*pi or any other operation. But I'm reporting it here anyway.

The error

ERROR: MethodError: no method matching MathOptInterface.Interval(::Float64, ::Irrational{:π})
The type `MathOptInterface.Interval` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  MathOptInterface.Interval(::T, ::T) where T<:Real
   @ MathOptInterface ~/.julia/packages/MathOptInterface/1fRdT/src/sets.jl:285
  MathOptInterface.Interval(::MathOptInterface.GreaterThan{<:AbstractFloat})
   @ MathOptInterface ~/.julia/packages/MathOptInterface/1fRdT/src/sets.jl:320
  MathOptInterface.Interval(::MathOptInterface.LessThan{<:AbstractFloat})
   @ MathOptInterface ~/.julia/packages/MathOptInterface/1fRdT/src/sets.jl:321
  ...

Way to reproduce it

using JuMP
using HiGHS

model = Model(HiGHS.Optimizer)

@variable(model, x >= 0)
@variable(model, y >= 0)

@constraint(model, x + y in MOI.Interval(-pi, pi))

optimize!(model)
println(value(x))

The error is on the @constraint.

@odow
Copy link
Member

odow commented Nov 3, 2024

Thanks for reporting! This will be fixed in the next release.

As a temporary measure, you can fix with:

@constraint(model, x + y in MOI.Interval{Float64}(-pi, pi))

or even better

@constraint(model, -pi <= x + y <= pi)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants