Skip to content

Commit 0afc163

Browse files
authored
Merge pull request #1914 from ValentinKaisermayer/patch-3
Show plots in docs
2 parents e186248 + 2c8cafe commit 0afc163

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/src/tutorials/optimization.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ using Plots
2424
x = -2:0.01:2
2525
y = -1:0.01:3
2626
contour(x, y, (x,y) -> (1 - x)^2 + 100 * (y - x^2)^2, fill=true, color=:viridis, ratio=:equal, xlims=(-2, 2))
27+
savefig("obj_fun.png"); nothing # hide
2728
```
2829

30+
![plot of the Rosenbrock function](obj_fun.png)
31+
2932
### Explanation
3033
Every optimization problem consists of a set of _optimization variables_. In this case we create two variables. Additionally we assign _box constraints_ for each of them. In the next step we create two parameters for the problem with `@parameters`. While it is not needed to do this it makes it easier to `remake` the problem later with different values for the parameters. The _objective function_ is specified as well and finally everything is used to construct an `OptimizationSystem`.
3134

@@ -74,8 +77,11 @@ x = -2:0.01:2
7477
y = -1:0.01:3
7578
contour(x, y, (x,y) -> (1 - x)^2 + 100 * (y - x^2)^2, fill=true, color=:viridis, ratio=:equal, xlims=(-2, 2))
7679
contour!(x, y, (x, y) -> x^2 + y^2, levels=[1], color=:lightblue, line=4)
80+
savefig("obj_fun_c.png"); nothing # hide
7781
```
7882

83+
![plot of the Rosenbrock function with constraint](obj_fun_c.png)
84+
7985
### Explanation
8086
Equality and inequality constraints can be added to the `OptimizationSystem`. An equality constraint can be specified via and `Equation`, e.g., `x^2 + y^2 ~ 1`. While inequality constraints via an `Inequality`, e.g., `x^2 + y^2 ≲ 1`. The syntax is here `\lesssim` and `\gtrsim`.
8187

0 commit comments

Comments
 (0)