Skip to content

Commit 4ae764b

Browse files
JacobAdamsenJacob Hilmar Adamsen
and
Jacob Hilmar Adamsen
authored
Optimisation tutorial updates (#44)
* Optimisation tutorial updates * Updated intro image --------- Co-authored-by: Jacob Hilmar Adamsen <[email protected]>
1 parent 05e1f37 commit 4ae764b

23 files changed

+37
-36
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Loading
Binary file not shown.
Loading

Parameter_studies_and_optimization/intro.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ behavior of the model. Some examples of applications are:
3131
%
3232

3333

34-
```{figure} _static/intro/image1.gif
34+
```{figure} _static/intro/image1.png
3535
:alt: Metabolic efficiency example
36-
:class: bg-primary
3736
:align: center
37+
:width: 80%
3838
39-
Parameter study: Metabolic efficiency of a bicycle as a function of seat height and seat horizontal position.
39+
Parameter study: Metabolism of a bicycle rider as a function of seat height and seat horizontal position.
4040
```
4141

4242

Parameter_studies_and_optimization/lesson1.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ reasonably fast computer it should take a minute or less to do the 25
279279
analyses after which the computations stop.
280280

281281
:::{note}
282-
If you turn off the model view by clicking the ![TurnOnOff.png](_static/Defining_a_parameter/TurnOnOffModel.png) button, the computation should speed up.
282+
If you turn off the model view by clicking the
283+
![TurnOnOff.png](_static/Defining_a_parameter/TurnOnOffModel.png)
284+
button, the computation should speed up.
283285

284286
Congratulations! You have completed your first parameter study. Let us
285287
investigate the result.
@@ -334,21 +336,23 @@ you go back to the AnyChart View and study the new surface:
334336
:alt: AnyChart 3 view
335337
:class: bg-primary
336338
:align: center
339+
:width: 80%
337340
```
338341

339342
The surface is now completely dominated by the one combination, which is
340343
difficult for the model to do. You can still see the surface shape if
341344
you change the scale of the value axis. This and all other settings are
342-
available if you click
343-
the ![chartsettings.png](_static/Defining_a_parameter/chartsettings.png)
344-
button in the toolbar. Doing so will produce a window with a tree view
345+
available if you open the Property Window
346+
![chartsettings.png](_static/Defining_a_parameter/chartsettings.png)
347+
in the toolbar. Doing so will produce a window with a tree view
345348
in which you can select `ValueAxis`->\`\`Max\`\` and `ValueAxis`->\`\`Min\`\`. Try setting Max to 0.30 and Min to 0.15 and you
346349
should obtain the following:
347350

348351
```{image} _static/Defining_a_parameter/anychart4.png
349352
:alt: AnyChart 4 view
350353
:class: bg-primary
351354
:align: center
355+
:width: 80%
352356
```
353357

354358
What this study reveals is that in terms of muscle activity to drive the

Parameter_studies_and_optimization/lesson2.md

+26-29
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ solves the problem.
6868
:alt: Metabolic efficiency example
6969
:class: bg-primary
7070
:align: center
71-
:scale: 80%
71+
:width: 80%
7272
```
7373

7474
The two pictures above both show the result of a parameter study. The
@@ -144,16 +144,16 @@ model view:
144144

145145
## Running the Optimization Study
146146

147-
Select `Main.OptStudy.Optimization` from the operation dropdown, click the Run button,
148-
and ensure the model view is open. The model starts
149-
cycling and after a few rounds you will notice the saddle position changing,
150-
but not in a systematic grid like in the parameters study. What you will see
151-
is gradual changes back and forth in different directions until the changes
152-
wear off and the position converges.
147+
Select `Main.OptStudy.Optimization` from the operation dropdown, click the Run
148+
button, and ensure the model view is open. The model starts cycling and after a
149+
few rounds you will notice the saddle position changing, but not in a systematic
150+
grid like in the parameters study. What you will see is gradual changes back and
151+
forth in different directions until the changes wear off and the position
152+
converges.
153153

154154
Every time you see the left-most number changing in the Output window it is
155155
an indication that the optimizer has picked a new optimization direction to try.
156-
You should see the number increasing in slow steps up to 4 before the process
156+
You should see the number increasing in slow steps up to 6 before the process
157157
stops and the system announces that it is finished. Please notice that the
158158
changes of saddle position in the last several steps is very minute, which is
159159
typical for optimization: the first steps bring large changes and large
@@ -171,10 +171,10 @@ with the Metabolism parameter study open? It should look like this:
171171

172172
If not, please run the ParamStudy again and plot the surface. When you
173173
have this surface ready, please open another Chart window by clicking
174-
`View`->\`\`Charts\`\`->\`\`Chart2\`\`.  In the new window, please expand the tree
175-
down to Main.OptStudy.Output.Metab. Then click the Val variable
174+
`View`->`Charts`->`Chart2`.  In the new window, please expand the tree
175+
down to `Main.OptStudy.Output.Metab`. Then click the `Val` variable
176176
under Metab. This produces a simple 2-D graph showing the development of
177-
the metabolism over the 4 iterations:
177+
the metabolism over the 6 iterations:
178178

179179
```{image} _static/Optimization_studies/metabcon2.png
180180
:alt: Chart Opttudy 1
@@ -197,7 +197,6 @@ The optimal solution in the Model View looks like this:
197197

198198
```{image} _static/Optimization_studies/bikeopt2.png
199199
:alt: Final Model view
200-
:class: bg-primary
201200
:align: center
202201
```
203202

@@ -211,12 +210,13 @@ An interesting way to investigate the convergence is to plot it in the
211210
variable/objective space rather than over the iterations. This is what
212211
we need the window with the parameter study surface for. At the top of
213212
this window you will find panels listing series and data to be plotted.
214-
Please right-click in the series window and select "New":
213+
Please right-click in the series window and select "Add":
215214

216215
```{image} _static/Optimization_studies/newseries.png
217216
:alt: Chart New Series
218217
:class: bg-primary
219218
:align: center
219+
:width: 65%
220220
```
221221

222222
This will give you a blank "Series 1". When you highlight it by clicking
@@ -225,23 +225,18 @@ right-hand pane is empty. We are going to fill in the `SaddleHeight` and
225225
`SaddlePos` variables from the OptStudy as Abscissa and Abscissa2,
226226
respectively.  This is done by selecting Abscissa and Abscissa2 in turn
227227
and then expanding the `OptStudy` branch until the `SaddleHeight.Val` and
228-
`SaddlePos.Val`, respectively, can be selected:
229-
230-
```{image} _static/Optimization_studies/selectheight.png
231-
:alt: Chart select height
232-
:class: bg-primary
233-
:align: center
234-
```
228+
`SaddlePos.Val`, respectively, can be selected.
235229

236230
Finally, in the `Value` field select `OptStudy.Metab.Val` and look carefully
237231
at the plot. You will see that an additional polyline has been added. It
238232
originates approximately at the middle of the surface and shows the path
239233
the optimization process has taken through the design space to the
240-
minimum point. You can change the color of the line by clicking the second
241-
leftmost button (![chartsettings.png](_static/Optimization_studies/chartsettings.png)) in the toolbar directly over the graphics
242-
pane. This gives you access to all the settings and lets you control the
243-
appearance of graphs in detail. Under Chart->Series->Series1->Lines the following
244-
parameters is set: `RGB = {1,0,0}`, i.e. red, and `Thickness = 4`.
234+
minimum point. You can change the color of the line by clicking the Property
235+
Window button (![chartsettings.png](_static/Optimization_studies/chartsettings.png))
236+
in the toolbar directly over the graphics pane. This gives you access to all the
237+
settings and lets you control the appearance of graphs in detail. Under
238+
Chart->Series->Series1->Lines the following parameters is set: `RGB = {1,0,0}`,
239+
i.e. red, and `Thickness = 4`.
245240

246241
```{image} _static/Optimization_studies/optpath2.png
247242
:alt: Chart OptPath
@@ -251,7 +246,7 @@ parameters is set: `RGB = {1,0,0}`, i.e. red, and `Thickness = 4`.
251246

252247
## Caveat when Running Optimization Studies
253248

254-
This plot illustrates the convergence history in the "landscape" of the
249+
The above plot illustrates the convergence history in the "landscape" of the
255250
objective function. Here we can see the reasons for the convergence
256251
being as it is. Actually, the optimum value lies in a relatively flat
257252
region and therefore the exact mathematical location of the optimum may
@@ -329,7 +324,7 @@ optimization problem stated in the beginning of this lesson, we have
329324
only less-than-or-equal-to constraints, but there is only a minus sign
330325
in difference of making a greater-than-or-equal-to into a
331326
less-than-or-equal-to constraint. You can put this minus sign manually
332-
or you can use Type = `GreaterThanZero`, which is equivalent. Notice that
327+
or you can use `Type = GreaterThanZero`, which is equivalent. Notice that
333328
equality constraints are in principle also a possibility, but currently
334329
the optimization solvers in AnyBody do not handle this type of
335330
constraints. Moreover, it is most often possible to handle equality
@@ -354,15 +349,17 @@ convergence picture:
354349
:alt: Metab value vs Steps
355350
:class: bg-primary
356351
:align: center
352+
:width: 75%
357353
```
358354

359-
If you alo re-run the parameter study, you can get this picture of the
355+
If you also re-run the parameter study, you can get this picture of the
360356
convergence:
361357

362358
```{image} _static/Optimization_studies/optpath2_constrained.png
363359
:alt: opt Study constrained
364360
:class: bg-primary
365361
:align: center
362+
:width: 60%
366363
```
367364

368365
We see that the result is indeed a compromise since the objective
@@ -378,6 +375,7 @@ looks like:
378375
:alt: SeatDist vs Steps
379376
:class: bg-primary
380377
:align: center
378+
:width: 70%
381379
```
382380

383381
where it is obvious how the optimizer hits the constraint, bounces off,
@@ -393,7 +391,6 @@ picture below:
393391

394392
```{image} _static/Optimization_studies/BikeOpt2_constrained.png
395393
:alt: Final model view 2
396-
:class: bg-primary
397394
:align: center
398395
```
399396

0 commit comments

Comments
 (0)