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

Rewrite the package to use Symbolics and ReversePropagation #212

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
3 changes: 1 addition & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.5'
- '^1.6.0-0'
- '1.10'
- 'nightly'
os:
- ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.jl.cov
*.jl.*.cov
*.jl.mem
docs/build/
docs/build/
Manifest.toml
28 changes: 15 additions & 13 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
name = "IntervalConstraintProgramming"
uuid = "138f1668-1576-5ad7-91b9-7425abbf3153"
version = "0.12.2"

[compat]
IntervalArithmetic = "0.16, 0.17"
IntervalContractors = "0.4"
IntervalRootFinding = "0.5"
MacroTools = "0.4, 0.5"
ModelingToolkit = "3"
julia = "1.3, 1.4"
version = "0.14.0"

[deps]
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
IntervalBoxes = "43d83c95-ebbb-40ec-8188-24586a1458ed"
IntervalContractors = "15111844-de3b-5229-b4ba-526f2f385dc9"
IntervalRootFinding = "d2bf35a9-74e0-55ec-b149-d360ff49b807"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
ReversePropagation = "527681c1-8309-4d3f-8790-caf822a419ba"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

[compat]
IntervalArithmetic = "0.22.12"
IntervalContractors = "0.5"
MacroTools = "0.4, 0.5"
ReversePropagation = "0.3"
Symbolics = "5, 6"
julia = "1"

[extras]
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "ModelingToolkit"]
test = ["Test", "Symbolics"]
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,44 @@ The package is based on interval arithmetic using the
[`IntervalArithmetic.jl`](https://github.com/JuliaIntervals/IntervalArithmetic.jl) package (co-written by the author),
in particular multi-dimensional `IntervalBox`es (i.e. Cartesian products of one-dimensional intervals).

## Documentation
<!-- ## Documentation
Documentation for the package is available [here](https://juliaintervals.github.io/pages/packages/intervalconstraintprogramming/).

The best way to learn how to use the package is to look at the tutorial, available in the organisation webpage [here](https://juliaintervals.github.io/pages/tutorials/tutorialConstraintProgramming/).
The best way to learn how to use the package is to look at the tutorial, available in the organisation webpage [here](https://juliaintervals.github.io/pages/tutorials/tutorialConstraintProgramming/). -->

## Basic usage

```jl
using IntervalArithmetic, IntervalArithmetic.Symbols
using IntervalConstraintProgramming
using IntervalBoxes
using Symbolics

vars = @variables x, y

C1 = constraint(x^2 + 2y^2 ≥ 1, vars)
C2 = constraint(x^2 + y^2 + x * y ≤ 3, vars)
C = C1 ⊓ C2

X = IntervalBox(-5..5, 2)

tolerance = 0.05
inner, boundary = pave(X, C, tolerance)

# plot the result:
using Plots

plot(collect.(inner), aspectratio=1, lw=0, label="inner");
plot!(collect.(boundary), aspectratio=1, lw=0, label="boundary")
```

- The inner, blue, region is guaranteed to lie *inside* the constraint set.
- The outer, white, region is guaranteed to lie *outside* the constraint set.
- The in-between, red, region is not known at this tolerance.

![Inner and outer ellipse](ellipses.svg?)




## Author
Expand Down
12 changes: 6 additions & 6 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ julia> using IntervalConstraintProgramming, IntervalArithmetic
julia> S = @constraint x^2 + y^2 <= 1
Separator:
- variables: x, y
- expression: x ^ 2 + y ^ 2 ∈ [-, 1]
- expression: x ^ 2 + y ^ 2 ∈ [-Inf, 1]
```
It works out automatically that `x` and `y` are variables.
The macro creates a `Separator` object, in this case a `ConstraintSeparator`.
Expand Down Expand Up @@ -73,7 +73,7 @@ julia> @variables x y
julia> S = Separator(x+y<1)
Separator:
- variables: x, y
- expression: x() + y() == [-, 1]
- expression: x() + y() == [-Inf, 1]

julia> C = Contractor(x+y)
Contractor in 2 dimensions:
Expand All @@ -91,7 +91,7 @@ julia> vars = @variables x y z
julia> S = Separator(vars, x+y<1)
Separator:
- variables: x, y, z
- expression: x() + y() == [-, 1]
- expression: x() + y() == [-Inf, 1]

julia> C = Contractor(vars, y+z)
Contractor in 3 dimensions:
Expand Down Expand Up @@ -120,7 +120,7 @@ f (generic function with 1 method)
julia> S=Separator(vars, f)
Separator:
- variables: x, y
- expression: x() + y() == [-, 1]
- expression: x() + y() == [-Inf, 1]

julia> using DynamicPolynomials #using polynomial functions

Expand All @@ -133,7 +133,7 @@ p (generic function with 1 method)
julia> S=Separator(pvars, f)
Separator:
- variables: x, y
- expression: x() + y() == [-, 1]
- expression: x() + y() == [-Inf, 1]
```
#### BasicContractor
Objects of type `Contractor` have four fields (variables, forward, backward and expression), among them data of two fields (forward, backward) are useful (i.e forward and backward functions) for further usage of that object, thats why it is preferred to use an object of type `BasicContractor` in place of `Contractor` which only contain these two fields for less usage of memory by unloading all the extra stuff.(Note: Like object of `Contractor` type,`BasicContractor`'s object will also have all the properties which are discussed above).
Expand Down Expand Up @@ -196,7 +196,7 @@ There are sample 3D calculations in the `examples` directory, in particular in t


## Set operations
Separators may be combined using the operators `!` (complement), `` and `` to make
Separators may be combined using the operators `!` (complement), `` and `` to make
more complicated sets; see the [notebook](https://github.com/JuliaIntervals/IntervalConstraintProgrammingNotebooks/blob/master/Basic%20examples%20of%20separators.ipynb) for several examples. Further examples can be found in the repository [IntervalConstraintProgrammingNotebooks](https://github.com/JuliaIntervals/IntervalConstraintProgrammingNotebooks).

## Author
Expand Down
Loading
Loading