Skip to content

Cannot define constraint more than once #219

@schillic

Description

@schillic

I think the new implementation with Symbolics is broken because constraint can only be called once. This breaks interactive usage.

Here is the example from the README:

julia> using IntervalConstraintProgramming, Symbolics
julia> vars = @variables x, y;
julia> constraint(x^2 + 2y^2  1, vars)  # first call works
Separator(in(-1 + x^2 + 2(y^2), [0.0, ∞)_dac), vars=x, y)

Then calling constraint another time (note that you need to stop the previous run, e.g., separate commands in the REPL):

julia> constraint(x^2 + 2y^2  1, vars)
ERROR: ArgumentError: `==` is purposely not supported when the intervals are overlapping. See instead `isequal_interval`

I do not fully understand why it works the first time. It seems that some other code path is taken. I guess the reason must be that some methods are only defined later and an old definition is taken during the first run.


Simplified version

Here is an even more simplified version:

using IntervalConstraintProgramming, Symbolics, IntervalArithmetic
julia> vars = @variables x, y;
julia> ex = -1 + x^2 + 2y^2;
julia> c = interval(0, Inf);
julia> ex in c  # first call works
in(-1 + x^2 + 2(y^2), [0.0, ∞)_dac)
julia> ex in c
ERROR: ArgumentError: `==` is purposely not supported when the intervals are overlapping. See instead `isequal_interval`

Environment

(IntervalConstraintProgramming) pkg> st
Project IntervalConstraintProgramming v0.14.0
Status `~/.julia/dev/IntervalConstraintProgramming/Project.toml`
⌅ [d1acc4aa] IntervalArithmetic v0.22.36
  [43d83c95] IntervalBoxes v0.2.3 `~/.julia/dev/IntervalBoxes`
  [15111844] IntervalContractors v0.5.0
  [527681c1] ReversePropagation v0.3.0
  [90137ffa] StaticArrays v1.9.15
⌅ [0c5d862f] Symbolics v6.58.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions