JuliaIntervals / IntervalConstraintProgramming.jl

Calculate rigorously the feasible region for a set of real-valued inequalities with Julia
Other
63 stars 16 forks source link

Document function macro #168

Closed mforets closed 3 years ago

mforets commented 4 years ago

We could add an example in https://juliaintervals.github.io/IntervalConstraintProgramming.jl/latest/

Example:

using IntervalConstraintProgramming, IntervalArithmetic, Plots

dom = IntervalBox(-2 .. 2, -2 .. 2)
@function gg(x, y) = (x^4 + y^4 - 1) * (x^2 + y^2 - 2) + x^5 * y
C = @constraint gg(x, y) <= 0
p = pave(C, dom, 0.01)

plot(p.inner, lw=1, ratio=1, lab="f(x, y) ≤ 0", title="")
plot!(p.boundary, lw=1, ratio=1, lab="boundary")

Screenshot from 2020-09-11 14-41-28

dpsanders commented 4 years ago

These days I would tend to do that using ModelingToolkit and a standard Julia function instead:

using IntervalConstraintProgramming, IntervalArithmetic, ModelingToolkit, Plots

dom = IntervalBox(-2..2, -2..2)

gg(x, y) = (x^4 + y^4 - 1) * (x^2 + y^2 - 2) + x^5 * y

vars = @variables x, y

C = Separator(vars, gg(x, y) < 0)
p = pave(C, dom, 0.05)

plot(p.inner, lw=0, ratio=1, lab="f(x, y) ≤ 0", title="")
plot!(p.boundary, lw=0, ratio=1, lab="boundary")
lucaferranti commented 3 years ago

We have an example about ModelingToolkit with ICP.jl in the webpage now: https://juliaintervals.github.io/pages/tutorials/tutorialConstraintProgramming/#constraint_programming_with_modelingtoolkit

mforets commented 3 years ago

=> this issue can be closed i suppose.