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

Better plotting in docs #169

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[deps]
DisplayAs = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
IntervalOptimisation = "c7c68f13-a4a2-5b9a-b424-07d005f8d9d2"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[compat]
DisplayAs = "0.1"
Documenter = "1"
IntervalArithmetic = "=0.20.9" # new versions require updates and are incompatible with dependencies
IntervalOptimisation = "0.4"
Expand Down
30 changes: 13 additions & 17 deletions docs/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ As you can see, the result is much tighter now, while still being rigorous! The

```@example tutorial
using Plots
plot(xlabel="x", ylabel="f(x)", legendfontsize=12, tickfontsize=12,
xguidefont=font(15, "Times"), yguidefont=font(15, "Times"))
plot!(IntervalBox(D, R), label="natural enclosure")
plot!(IntervalBox(D, Rbb), label="branch and bound", alpha=1)
plot!(f, -10, 10, lw=2, c=:black, label="f")
savefig("tutorial-2d.png"); nothing # hide
fig = plot(xlabel="x", ylabel="f(x)", legendfontsize=12, tickfontsize=12,
xguidefont=font(15, "Times"), yguidefont=font(15, "Times"))
plot!(fig, IntervalBox(D, R), label="natural enclosure")
plot!(fig, IntervalBox(D, Rbb), label="branch and bound", alpha=1)
plot!(fig, f, -10, 10, lw=2, c=:black, label="f")
import DisplayAs #hide
DisplayAs.Text(DisplayAs.PNG(fig)) #hide
```

![](tutorial-2d.png)

### Tuning parameters

Some solvers have parameters that can be tuned. For example, looking at the [`BranchAndBoundEnclosure`](@ref) documentation, we can see that it has two parameters, `tol` and `maxdepth`.
Expand Down Expand Up @@ -153,16 +152,13 @@ using IntervalArithmetic

x = y = -5:0.1:5
f(x, y) = h([x, y])
plot(legend=:none, size=(800, 800), xlabel="x", ylabel="y", zlabel="h(x,y)",
tickfontsize=18, guidefont=font(22, "Times"), zticks=[-2, 0, 2])
surface!(x, y, [inf(Rh) for _ in x, _ in y], α=0.4)
surface!(x, y, f.(x', y), zlims=(-4, 4))
surface!(x, y, [sup(Rh) for _ in x, _ in y], α=0.4)
savefig("tutorial-3d.png"); nothing # hide
fig = plot(legend=:none, size=(800, 800), xlabel="x", ylabel="y", zlabel="h(x,y)",
tickfontsize=18, guidefont=font(22, "Times"), zticks=[-2, 0, 2])
surface!(fig, x, y, [inf(Rh) for _ in x, _ in y], α=0.4)
surface!(fig, x, y, f.(x', y), zlims=(-4, 4))
surface!(fig, x, y, [sup(Rh) for _ in x, _ in y], α=0.4)
DisplayAs.Text(DisplayAs.PNG(fig)) #hide
```

![](tutorial-3d.png)

## Adding a new enclosure algorithm

To add a new enclosure algorithm, or *solver*, just add a corresponding struct (let us call it `MyEnclosure`) and extend the method `enclose`, as the following code snippet demonstrates.
Expand Down
Loading