Skip to content

Commit a5bc13a

Browse files
authored
Merge pull request #35 from rafaelbailo/main
Improve documentation following JOSS review
2 parents 815a0ba + 3e86057 commit a5bc13a

File tree

10 files changed

+30
-11
lines changed

10 files changed

+30
-11
lines changed

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ makedocs(;
6565
prettyurls = get(ENV, "CI", "false") == "true",
6666
canonical = "https://PdIPS.github.io/ConsensusBasedX.jl",
6767
edit_link = "main",
68-
assets = String[],
68+
assets = ["assets/favicon.ico"],
6969
footer = "Copyright © 2024 [Dr Rafael Bailo](https://rafaelbailo.com/) and [Purpose-Driven Interacting Particle Systems Group](https://github.com/PdIPS). [MIT License](https://github.com/PdIPS/ConsensusBasedX.jl/blob/main/LICENSE).",
7070
),
7171
source = "parsed",

docs/src/assets/favicon.ico

33.7 KB
Binary file not shown.

docs/src/assets/logo-square.png

20.4 KB
Loading

docs/src/distribution_sampling.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ For instance, if `D = 2`, you can sample `exp(-αf)` by running:
99
out = sample(f, D = 2, extended_output=true)
1010
out.sample
1111
```
12+
The method must be run with the `extended_output=true` option in order to receive [Extended output](@ref) and access the full particle sample; without it, `sample` returns a single `Vector{Float64}` of length `D` which contains the candidate to the global minimiser of `f`, just like `minimise`.
1213

1314
!!! note
1415
You must always provide `D`.

docs/src/extended_output.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# Extended output
22

3-
By default, the `minimise` routine returns its best guess for the global minimiser of the function `f`. However, it is possible to access the extended output by passing the `extended_output = true` option.
3+
By default, the `minimise` and `sample` routines return their best guess for the global minimiser of the function `f`. However, it is possible to access the extended output by passing the `extended_output = true` option.
44

5-
The extended output is a `NamedTuple` which contains:
6-
- `minimiser`, the usual output of the `minimise`;
5+
When calling `minimise`, the extended output is a `NamedTuple` which contains:
6+
- `minimiser`, a `Vector{Float64}`, the candidate to the global minimiser of `f`;
77
- `ensemble_minimiser`, a `Vector` of the `M` minimisers computed by each ensemble. `minimiser` is equal to their mean;
8-
- `initial_particles`, the initial position of the particles, see Particle initialisationref;
9-
- `final_particles`, the final position of the particles;
8+
- `initial_particles`, the initial position of the particles, see [Particle initialisation](@ref);
9+
- `final_particles`, the final position of the particles.
10+
11+
When calling `sample`, the extended output also includes `sample`, which is an alias for `final_particles`. The final position of the particles is the distribution sample when running with `CBS_mode = :sampling`.
12+
13+
In both cases, certain low-level caches are included as well:
1014
- `method`, by default a `ConsensusBasedOptimisation` object;
1115
- `method_cache`, by default a `ConsensusBasedOptimisationCache` object;
1216
- `particle_dynamic`, by default a `ParticleDynamic` object;
13-
- `particle_dynamic_cache`, by default a `ParticleDynamicCache` object.
17+
- `particle_dynamic_cache`, by default a `ParticleDynamicCache` object.
18+
These objects are part of the [Low-level interface](@ref).

docs/src/function_minimisation.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ For instance, if `D = 2`, you can minimise `f` by running:
66
```julia
77
minimise(f, D = 2)
88
```
9-
By default, `minimise` returns a `Vector{Float64}` of length `D`.
9+
By default, `minimise` returns a `Vector{Float64}` of length `D` which contains the candidate to the global minimiser of `f`.
1010

1111
!!! note
1212
You must always provide `D`.
@@ -34,6 +34,16 @@ This is a version of the full-code example above, using `config` instead:
3434
ConsensusBasedX.jl also defines `optimise` as an alias of `minimise`.
3535

3636

37+
## Receiving extended output
38+
39+
It is possible to receive extended output from `minimise` by passing the option `extended_output = true`:
40+
```julia
41+
config = (; D = 2, extended_output = true)
42+
minimise(f, config)
43+
```
44+
For more details, see [Extended output](@ref).
45+
46+
3747
## Maximisation
3848

3949
ConsensusBasedX.jl also defines `maximise` for convenience. If you call

docs/src/parallelisation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Consensus-based optimisation is often used to tackle minimisation problems where `f(x)` is expensive to evaluate (for instance, parameter estimation in a [partial differential equation](https://en.wikipedia.org/wiki/Partial_differential_equation) model). Therefore, ConsensusBasedX.jl does not use parallelisation by default, as it assumes the implementation of `f` will be parallelised if possible.
44

5-
However, you can enable parallelisation by passing the option `parallelisation=:EnsembleParallelisation`. With this option, ConsensusBasedX.jl will run each of the `M` particle ensembles in parallel.
5+
However, you can enable parallelisation by passing the option `parallelisation=:EnsembleParallelisation`. With this option, ConsensusBasedX.jl will run each of the `M` particle ensembles in parallel, using multithreading.
66

77
!!! warning
88
Parallelisation leads to memory allocations which cannot be avoided, as there is overhead associated with distributing the tasks. If you activate parallelisation, and then run `minimise` in benchmark mode (see [Performance and benchmarking](@ref)), you will detect some allocations, and this is expected.

docs/src/performance_benchmarking.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ConsensusBasedX.jl has been developed with performance in mind. As such, it foll
44

55
In order to maintain good performance, it's important that your function `f` also follows these patterns. We recommend the [performance tips](https://docs.julialang.org/en/v1/manual/performance-tips/) section of the Julia documentation. You should benchmark `f`, paying attention to memory allocations.
66

7+
!!! tip
8+
You should use the [BenchmarkTools.jl](https://juliaci.github.io/BenchmarkTools.jl/stable/) package to benchmark `f`.
9+
710
Once you have benchmarked `f`, you might want to test its performance within ConsensusBasedX.jl. You could run
811
```julia
912
config = (; D = 2)

docs/src/stopping_criteria.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ You can apply any of these criteria by passing them as keywords to the `minimise
3333

3434
## Max time
3535

36-
`max_time::Real = Inf` determines the maximal simulation time. If the number of iterations times `Δt` surpasses this value, the minimisation stops.
36+
`max_time::Real = Inf` determines the maximal solution time (the corresponding SDE is solved from time `0` until time `max_time`). If the number of iterations times `Δt` surpasses this value, the minimisation stops.
3737

3838
{{basic_usage/max_time.jl}}

docs/src/summary_options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ See [Stopping criteria](@ref).
2929
- `energy_tolerance::Real = 1e-8` is the stopping tolerance for the value of `f`.
3030
- `max_evaluations::Real = Inf` is the maximum number of evaluations of `f`.
3131
- `max_iterations::Real = 1000` is the maximum number of iterations.
32-
- `max_time::Real = Inf` is the maximal simulation time.
32+
- `max_time::Real = Inf` is the maximal solution time (the corresponding SDE is solved from time `0` until time `max_time`).
3333

3434
## Advanced options
3535

0 commit comments

Comments
 (0)