Skip to content

Commit 47dd4db

Browse files
committed
Updated README
1 parent d32d6c9 commit 47dd4db

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,43 @@
11
# SourceCodeMcCormick.jl
2-
Experimental Approach to McCormick Relaxation Source-Code Transformation in Differential Inequalities
2+
Experimental Approach to McCormick Relaxation Source-Code Transformation for Differential Inequalities
33

4-
Mainly exists to avoid need for method overloading and use of structures which are not sufficiently generically typed to when computing relaxations via differential inequality.
4+
The purpose of this package is to transform a `ModelingToolkit` ODE system with factorable equations into a new `ModelingToolkit` ODE system with interval or McCormick relaxations applied. E.g.:
55

6-
Main Features:
7-
- Transform factorable function `y = f(x<:Real)` into `y = f(xcv<:Real, xcc<:Real, xL<:Real, xU<:Real)` outputs the tuple `(ycv, ycc, yL, yU)` instead and computes the convex relaxation (ycv), concave relaxation (ycc), lower bound (yL), and upper bound of `f(x)` with `xL < xc < x < xcc < xU`.
8-
- Transform the factorable function `f!(y::Vector{<:Real}, x::Vector{<:Real})` which maps `x` to `y` similarly.
9-
- Transform a list of equations from Modeling toolkit `eqn` that are a parametric ODEs with defined by rhs function `f!(dy,y,p,t)` to a list of equations in Modeling toolkit `eqn_new` similarly.
6+
```
7+
using SourceCodeMcCormick, ModelingToolkit
8+
@parameters p[1:2] t
9+
@variables x[1:2](t)
10+
D = Differential(t)
11+
12+
tspan = (0.0, 35.0)
13+
x0 = [1.0; 0.0]
14+
x_dict = Dict(x[i] .=> x0[i] for i in 1:2)
15+
p_start = [0.020; 0.025]
16+
p_dict = Dict(p[i] .=> p_start[i] for i in 1:2)
17+
18+
eqns = [D(x[1]) ~ p[1]+x[1],
19+
D(x[2]) ~ p[2]+x[2]]
20+
21+
@named syst = ODESystem(eqns, t, x, p, defaults=merge(x_dict, p_dict))
22+
new_syst = apply_transform(McCormickIntervalTransform(), syst)
23+
```
24+
25+
This takes the original ODE system (`syst`) with equations:
26+
```
27+
Differential(t)(x[1](t)) ~ x[1](t) + p[1]
28+
Differential(t)(x[2](t)) ~ x[2](t) + p[2]
29+
```
30+
31+
and generates a new ODE system (`new_syst') with equations:
32+
```
33+
Differential(t)(x_1_lo(t)) ~ p_1_lo + x_1_lo(t)
34+
Differential(t)(x_1_hi(t)) ~ p_1_hi + x_1_hi(t)
35+
Differential(t)(x_1_cv(t)) ~ p_1_cv + x_1_cv(t)
36+
Differential(t)(x_1_cc(t)) ~ p_1_cc + x_1_cc(t)
37+
Differential(t)(x_2_lo(t)) ~ p_2_lo + x_2_lo(t)
38+
Differential(t)(x_2_hi(t)) ~ p_2_hi + x_2_hi(t)
39+
Differential(t)(x_2_cv(t)) ~ p_2_cv + x_2_cv(t)
40+
Differential(t)(x_2_cc(t)) ~ p_2_cc + x_2_cc(t)
41+
```
42+
43+
where `x_lo < x_cv < x < x_cc < x_hi`. This new system of ODEs is generated using GPU-compatible language--i.e., any decision points in the form of the resulting equation based on some terms being positive or negative are handled by IfElse.ifelse statements and/or min/max evaluations. By using only these types of expressions, multiple trajectories of the resulting ODE system can be solved simultaneously on a GPU, such as by using `DiffEqGPU` in the SciML ecosystem.

0 commit comments

Comments
 (0)