Skip to content

Commit 02eaae9

Browse files
committed
Merge branch 'master' of github.com:JuliaTeachingCTU/Scientific-Programming-in-Julia
2 parents aff716e + 013f29c commit 02eaae9

File tree

5 files changed

+69
-186
lines changed

5 files changed

+69
-186
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
This repository contains all the course materials for the master course
1313
_**Scientific Programming in Julia**_ taught at the Czech Techincal University
1414
in Prague. You can find more information on the official
15-
[course website](https://juliateachingctu.github.io/Scientific-Programming-in-Julia/dev).
15+
[course website](https://juliateachingctu.github.io/Scientific-Programming-in-Julia/stable).

docs/Manifest.toml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
3030

3131
[[AxisAlgorithms]]
3232
deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"]
33-
git-tree-sha1 = "a4d07a1c313392a77042855df46c5f534076fab9"
33+
git-tree-sha1 = "66771c8d21c8ff5e3a93379480a2307ac36863f7"
3434
uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950"
35-
version = "1.0.0"
35+
version = "1.0.1"
3636

3737
[[Base64]]
3838
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -153,7 +153,7 @@ version = "2.2.3+0"
153153

154154
[[EcosystemCore]]
155155
deps = ["StatsBase"]
156-
git-tree-sha1 = "9b3a25d787bcd5974160b1c7064096b8fb37a88c"
156+
git-tree-sha1 = "946d950bc4a3e64d1697411a2dc21f78a4a7aec6"
157157
repo-rev = "main"
158158
repo-url = "https://github.com/JuliaTeachingCTU/EcosystemCore.jl.git"
159159
uuid = "3e0d8730-8ea0-4ee2-afe6-c85384c618a2"
@@ -224,9 +224,9 @@ version = "0.59.0"
224224

225225
[[GR_jll]]
226226
deps = ["Artifacts", "Bzip2_jll", "Cairo_jll", "FFMPEG_jll", "Fontconfig_jll", "GLFW_jll", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Libtiff_jll", "Pixman_jll", "Pkg", "Qt5Base_jll", "Zlib_jll", "libpng_jll"]
227-
git-tree-sha1 = "ef49a187604f865f4708c90e3f431890724e9012"
227+
git-tree-sha1 = "cafe0823979a5c9bff86224b3b8de29ea5a44b2e"
228228
uuid = "d2c73de3-f751-5644-a686-071e5b155ba9"
229-
version = "0.59.0+0"
229+
version = "0.61.0+0"
230230

231231
[[GeometryBasics]]
232232
deps = ["EarCut_jll", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
@@ -320,6 +320,11 @@ git-tree-sha1 = "61aa005707ea2cebf47c8d780da8dc9bc4e0c512"
320320
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
321321
version = "0.13.4"
322322

323+
[[IrrationalConstants]]
324+
git-tree-sha1 = "f76424439413893a832026ca355fe273e93bce94"
325+
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
326+
version = "0.1.0"
327+
323328
[[IterTools]]
324329
git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18"
325330
uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
@@ -448,6 +453,12 @@ version = "1.3.5"
448453
deps = ["Libdl"]
449454
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
450455

456+
[[LogExpFunctions]]
457+
deps = ["ChainRulesCore", "DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
458+
git-tree-sha1 = "34dc30f868e368f8a17b728a1238f3fcda43931a"
459+
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
460+
version = "0.3.3"
461+
451462
[[Logging]]
452463
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
453464

@@ -696,10 +707,10 @@ uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
696707
version = "1.0.0"
697708

698709
[[StatsBase]]
699-
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
700-
git-tree-sha1 = "8cbbc098554648c84f79a463c9ff0fd277144b6c"
710+
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
711+
git-tree-sha1 = "65fb73045d0e9aaa39ea9a29a5e7506d9ef6511f"
701712
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
702-
version = "0.33.10"
713+
version = "0.33.11"
703714

704715
[[StructArrays]]
705716
deps = ["Adapt", "DataAPI", "StaticArrays", "Tables"]
@@ -757,9 +768,9 @@ version = "1.18.0+4"
757768

758769
[[WoodburyMatrices]]
759770
deps = ["LinearAlgebra", "SparseArrays"]
760-
git-tree-sha1 = "59e2ad8fd1591ea019a5259bd012d7aee15f995c"
771+
git-tree-sha1 = "9398e8fefd83bde121d5127114bd3b6762c764a6"
761772
uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
762-
version = "0.5.3"
773+
version = "0.5.4"
763774

764775
[[XML2_jll]]
765776
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"]

docs/src/lecture_03/hw.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ using Scientific_Programming_in_Julia
88
In this homework we will add another species of plant to our simulation
99
(*poisoned mushrooms*) and practice the use of closures with callback
1010
functions.
11+
The solution of lab 3 can be found on Github for the
12+
[`World`](https://github.com/JuliaTeachingCTU/EcosystemCore.jl/blob/main/src/world.jl),
13+
[`Plant`s](https://github.com/JuliaTeachingCTU/EcosystemCore.jl/blob/main/src/plant.jl), and
14+
[`Animal`s](https://github.com/JuliaTeachingCTU/EcosystemCore.jl/blob/main/src/animal.jl).
15+
1116

1217
## Poisoned Mushrooms
1318

@@ -24,7 +29,7 @@ delicious looks but decreases the energy of the sheep by
2429
```
2530
Your new species should give you results like below
2631
```@repl hw03
27-
s = Sheep(1,2,2,1,1);
32+
s = Sheep(1,2,1,1,1);
2833
m = Mushroom(2,5);
2934
w = World([s,m])
3035
eat!(s,m,w);
@@ -34,13 +39,15 @@ w
3439
## Callbacks & Closures
3540

3641
In many scientific frameworks we have to work with functions like `simulate!`
42+
(The `solve` function in
43+
[`Optim.jl`](https://github.com/JuliaNLSolvers/Optim.jl) is a good example)
3744
```@example hw03
38-
function simulate!(w::World, iters::Int, callbacks=[])
45+
function simulate!(w::World, iters::Int, cb=()->())
3946
for _ in 1:iters
47+
# In our case this loop is trivial. In more involved simulations this
48+
# will be more complicated ;)
4049
world_step!(w)
41-
for cb in callbacks
42-
cb(w)
43-
end
50+
cb()
4451
end
4552
end
4653
nothing # hide
@@ -49,7 +56,7 @@ which allow custom functionality within a larger simulation function.
4956
For example, we might want to print out what the world looks like after
5057
every time step. This could be done by passing a lambda function `w->(@show w)`
5158
to `simulate!`.
52-
Often we want our callbacks to be executed only every $N$th step. This can be
59+
Often we want our callbacks to be executed only every `n` steps. This can be
5360
used to get less verbose logging or e.g. to write out checkpoints of your
5461
simulation.
5562
```@raw html
@@ -64,7 +71,7 @@ calls to the function `fn` that is returned by `every_nth(f,n)`.
6471
```@raw html
6572
</div></div>
6673
```
67-
You can use `every_nth` to log and save the agent count only every couple of
74+
You can use `every_nth` to log (or save) the agent count only every couple of
6875
steps of your simulation. Using `every_nth` will look like this:
6976
```@repl hw03
7077
# `@info agent_count(w)` is executed only every 5th call to logcb(w)

0 commit comments

Comments
 (0)