Open
Description
If DynamicPolynomials
library is used together with e.g. ApproxFun
, there is an error if the package IntervalSets
is used and the following is executed with v
being of type PolyVar
:
_in(v, I::TypedEndpointsInterval{:closed,:closed}) = leftendpoint(I) ≤ v ≤ rightendpoint(I)
_in(v, I::TypedEndpointsInterval{:open,:open}) = leftendpoint(I) < v < rightendpoint(I)
_in(v, I::TypedEndpointsInterval{:closed,:open}) = leftendpoint(I) ≤ v < rightendpoint(I)
_in(v, I::TypedEndpointsInterval{:open,:closed}) = leftendpoint(I) < v ≤ rightendpoint(I)
The error is because Base.isless
is not defined for PolyVar
Code example producing the error:
using SumOfSquares
using DynamicPolynomials
using DynamicPolynomials: PolyVar
using ApproxFun
using SCS
using IntervalSets
## use it for something:
@polyvar x
model = SOSModel(SCS.Optimizer)
@variable(model, a[1:10])
p = Fun(Chebyshev(), a)
p(x) # this throws for example the error
One can manually overwrite those functions for the desired type, e.g.
using DynamicPolynomials: PolyVar
using IntervalSets
## define these functions as a trick:
IntervalSets.in(v::PolyVar, I::IntervalSets.TypedEndpointsInterval{:closed,:closed}) = true
IntervalSets.in(v::PolyVar, I::IntervalSets.TypedEndpointsInterval{:open,:open}) = true
IntervalSets.in(v::PolyVar, I::IntervalSets.TypedEndpointsInterval{:closed,:open}) = true
IntervalSets.in(v::PolyVar, I::IntervalSets.TypedEndpointsInterval{:open,:closed}) = true
Is it possible to overwrite the IntervalSets.in
in order to get better compatibility between the polynomial packages?
Or has this to be done in MultivariatePolynomials.jl
instead of here?
Metadata
Metadata
Assignees
Labels
No labels