Skip to content

Commit 6b5a070

Browse files
Rewrite the package to use Symbolics and ReversePropagation (#212)
* Add source files for rewrite * Add basic examples * Add ConstraintProblem * Bump versions * Add model.jl * update Project.toml and workflow * Update rewrite branch. Working with Symbolics 5, IntervalArithmetic 0.20 * Pass nanmath=false to build_function * Fix action of separator on box * Require Julia 1.10 * Working with new versions of packages * Add basic usage and image to readme * Add boundary to plot * Fix * Replace PNG with SVG * Get tests passing with new API * Clean up by removing unneeded code and MacroTools dep * Add back missing files after name change --------- Co-authored-by: lucaferranti <[email protected]>
1 parent 739bc0a commit 6b5a070

30 files changed

+4557
-1781
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/workflows/CI.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: CI
22
on:
3-
push:
4-
branches: "master"
5-
tags: ["*"]
6-
pull_request:
7-
release:
3+
- push
4+
- pull_request
85
jobs:
96
test:
107
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
@@ -14,9 +11,7 @@ jobs:
1411
fail-fast: false
1512
matrix:
1613
version:
17-
- '1.3' # oldest Julia version that works
18-
- '1.8' # newest Julia version that works with ModelingToolkit
19-
- '1'
14+
- '1.10'
2015
- 'nightly'
2116
os:
2217
- ubuntu-latest

.github/workflows/CompatHelper.yml

-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ jobs:
1212
- name: CompatHelper.main()
1313
env:
1414
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15-
COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
1615
run: julia -e 'using CompatHelper; CompatHelper.main()'

.gitignore

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,4 @@
22
*.jl.*.cov
33
*.jl.mem
44
docs/build/
5-
6-
*.DS_Store
7-
8-
coverage/
9-
10-
.vscode
11-
12-
Manifest.toml
5+
Manifest.toml

NEWS.md

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# IntervalConstraintProgramming.jl
22

3-
# v0.11
3+
#v0.11
44
## Minimum Julia version
55
- The minimum Julia version supported is now Julia 1.1
66

7-
## Functionality's are added
7+
##Functionality's are added
88
- Contractor can be make by just function name only
99
- New type of Contractor named as `BasicContractor` can be construct which only contain fields of useful data.
1010

11-
11+
1212
# v0.10
1313
## Minimum Julia version
1414
- The minimum Julia version supported is now Julia 1.0.
@@ -17,7 +17,6 @@
1717

1818
- By the help of `ModelingToolkit.jl` we can construct contractors and separators without the use of macros.
1919

20-
2120
# v0.9
2221
## Minimum Julia version
2322
- The minimum Julia version supported is now Julia 0.7. The package is fully compatible with Julia 1.0.
@@ -30,14 +29,12 @@
3029
## Minimum Julia version
3130
- The minimum Julia version required has been bumped to 0.6; this will be the last release to support 0.6.
3231

33-
3432
# v0.7
3533

3634
## New dependency: `IntervalContractors.jl`
3735

3836
The reverse functions used for constraint propagation have been factored out into the `IntervalContractors.jl` package.
3937

40-
4138
# v0.6
4239
## Minimum Julia version
4340
- The minimum Julia version required has been bumped to 0.5
@@ -48,7 +45,6 @@ The reverse functions used for constraint propagation have been factored out int
4845
## Dependency change
4946
- The dependency on `ValidatedNumerics.jl` has been replaced by `IntervalArithmetic.jl` and `IntervalRootFinding.jl`
5047

51-
5248
# v0.5
5349
- API change: Contractors now have their dimension as a type parameter
5450
- Refactoring for type stability
@@ -57,7 +53,6 @@ The reverse functions used for constraint propagation have been factored out int
5753
- Generated code uses simpler symbols
5854
- Example notebooks have been split out into a separate repository: https://github.com/dpsanders/IntervalConstraintProgrammingNotebooks
5955

60-
6156
# v0.4
6257
- `@function f(x) = 4x` defines a function
6358
- Functions may be used inside constraints
@@ -89,7 +84,6 @@ C = @constraint (x-$a)^2 + (y-$b)^2
8984
The constraint will *not* change if the constants are changed, but may be
9085
updated (changed) by calling the same `@constraint` command again.
9186

92-
9387
# v0.2
9488
- `setinverse` now returns an object of type `Paving` [#17](https://github.com/dpsanders/IntervalConstraintProgramming.jl/pull/17)
9589

@@ -101,7 +95,7 @@ updated (changed) by calling the same `@constraint` command again.
10195
to eliminate collisions with user-defined variables [#20](https://github.com/dpsanders/IntervalConstraintProgramming.jl/pull/20)
10296

10397

104-
# v0.1.1
98+
## v0.1.1
10599
- Add `sqrtRev` reverse-mode function
106100

107101
- Add solid torus example, including 3D visualization with GLVisualize

Project.toml

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
name = "IntervalConstraintProgramming"
22
uuid = "138f1668-1576-5ad7-91b9-7425abbf3153"
3-
version = "0.13"
3+
version = "0.14.0"
44

55
[deps]
66
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
7+
IntervalBoxes = "43d83c95-ebbb-40ec-8188-24586a1458ed"
78
IntervalContractors = "15111844-de3b-5229-b4ba-526f2f385dc9"
8-
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
9-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
9+
ReversePropagation = "527681c1-8309-4d3f-8790-caf822a419ba"
10+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
11+
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1012

1113
[compat]
12-
IntervalArithmetic = "0.16, 0.17, 0.18, 0.19, 0.20"
13-
IntervalContractors = "0.4"
14-
MacroTools = "0.4, 0.5"
15-
Requires = "0.5, 1"
16-
julia = "1.3"
14+
IntervalArithmetic = "0.22.12"
15+
IntervalContractors = "0.5"
16+
ReversePropagation = "0.3"
17+
Symbolics = "5, 6"
18+
julia = "1"
19+
20+
[extras]
21+
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
22+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
23+
24+
[targets]
25+
test = ["Test", "Symbolics"]

README.md

+34-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![Build Status](https://github.com/JuliaIntervals/IntervalConstraintProgramming.jl/workflows/CI/badge.svg)](https://github.com/JuliaIntervals/IntervalConstraintProgramming.jl/actions/workflows/CI.yml)
44
[![Docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaintervals.github.io/pages/packages/intervalconstraintprogramming/)
5-
[![coverage](https://codecov.io/gh/JuliaIntervals/IntervalConstraintProgramming.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaIntervals/IntervalConstraintProgramming.jl)
65

76
This Julia package allows us to specify a set of constraints on real-valued variables,
87
given by inequalities, and
@@ -13,14 +12,44 @@ The package is based on interval arithmetic using the
1312
[`IntervalArithmetic.jl`](https://github.com/JuliaIntervals/IntervalArithmetic.jl) package (co-written by the author),
1413
in particular multi-dimensional `IntervalBox`es (i.e. Cartesian products of one-dimensional intervals).
1514

16-
## Documentation
15+
<!-- ## Documentation
1716
Documentation for the package is available [here](https://juliaintervals.github.io/pages/packages/intervalconstraintprogramming/).
1817
19-
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/).
18+
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/). -->
19+
20+
## Basic usage
21+
22+
```jl
23+
using IntervalArithmetic, IntervalArithmetic.Symbols
24+
using IntervalConstraintProgramming
25+
using IntervalBoxes
26+
using Symbolics
27+
28+
vars = @variables x, y
29+
30+
C1 = constraint(x^2 + 2y^2 1, vars)
31+
C2 = constraint(x^2 + y^2 + x * y 3, vars)
32+
C = C1 C2
33+
34+
X = IntervalBox(-5..5, 2)
35+
36+
tolerance = 0.05
37+
inner, boundary = pave(X, C, tolerance)
38+
39+
# plot the result:
40+
using Plots
41+
42+
plot(collect.(inner), aspectratio=1, lw=0, label="inner");
43+
plot!(collect.(boundary), aspectratio=1, lw=0, label="boundary")
44+
```
45+
46+
- The inner, blue, region is guaranteed to lie *inside* the constraint set.
47+
- The outer, white, region is guaranteed to lie *outside* the constraint set.
48+
- The in-between, red, region is not known at this tolerance.
49+
50+
![Inner and outer ellipse](ellipses.svg?)
2051

21-
#### ℹ️ Note on ModelingToolkit
2252

23-
ModelingToolkit can be used to conveniently define constraints, as described in the tutorial. However, that package is only compatible up to Julia version 1.9, and it needs to be installed manually and restricted to version 3. Later versions of ModelingToolkit or Julia are not compatible yet.
2453

2554

2655
## Author

REQUIRE

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
julia 1.0
2+
ModelingToolkit
3+
IntervalArithmetic 0.15
4+
IntervalRootFinding 0.4
5+
IntervalContractors 0.3
6+
MacroTools 0.4

docs/src/index.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ julia> using IntervalConstraintProgramming, IntervalArithmetic
2626
julia> S = @constraint x^2 + y^2 <= 1
2727
Separator:
2828
- variables: x, y
29-
- expression: x ^ 2 + y ^ 2 ∈ [-, 1]
29+
- expression: x ^ 2 + y ^ 2 ∈ [-Inf, 1]
3030
```
3131
It works out automatically that `x` and `y` are variables.
3232
The macro creates a `Separator` object, in this case a `ConstraintSeparator`.
@@ -73,7 +73,7 @@ julia> @variables x y
7373
julia> S = Separator(x+y<1)
7474
Separator:
7575
- variables: x, y
76-
- expression: x() + y() == [-, 1]
76+
- expression: x() + y() == [-Inf, 1]
7777

7878
julia> C = Contractor(x+y)
7979
Contractor in 2 dimensions:
@@ -91,7 +91,7 @@ julia> vars = @variables x y z
9191
julia> S = Separator(vars, x+y<1)
9292
Separator:
9393
- variables: x, y, z
94-
- expression: x() + y() == [-, 1]
94+
- expression: x() + y() == [-Inf, 1]
9595

9696
julia> C = Contractor(vars, y+z)
9797
Contractor in 3 dimensions:
@@ -120,7 +120,7 @@ f (generic function with 1 method)
120120
julia> S=Separator(vars, f)
121121
Separator:
122122
- variables: x, y
123-
- expression: x() + y() == [-, 1]
123+
- expression: x() + y() == [-Inf, 1]
124124

125125
julia> using DynamicPolynomials #using polynomial functions
126126

@@ -133,7 +133,7 @@ p (generic function with 1 method)
133133
julia> S=Separator(pvars, f)
134134
Separator:
135135
- variables: x, y
136-
- expression: x() + y() == [-, 1]
136+
- expression: x() + y() == [-Inf, 1]
137137
```
138138
#### BasicContractor
139139
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).
@@ -196,7 +196,7 @@ There are sample 3D calculations in the `examples` directory, in particular in t
196196

197197

198198
## Set operations
199-
Separators may be combined using the operators `!` (complement), `` and `` to make
199+
Separators may be combined using the operators `!` (complement), `` and `` to make
200200
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).
201201

202202
## Author

0 commit comments

Comments
 (0)