Skip to content

Commit 0ddddbf

Browse files
update docs for subpackages
1 parent 5351c41 commit 0ddddbf

File tree

5 files changed

+79
-41
lines changed

5 files changed

+79
-41
lines changed

docs/src/optimization_packages/optim.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Optim.jl
1+
# [Optim.jl](@id optim)
22
[`Optim`](https://github.com/JuliaNLSolvers/Optim.jl) is Julia package implementing various algorithm to perform univariate and multivariate optimization.
33

44
## Installation: GalacticOptimJL.jl

docs/src/tutorials/intro.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,58 @@ from BlackBoxOptim.jl on the Rosenbrock equation. The simplest copy-pasteable
66
code to get started is the following:
77

88
```julia
9-
using GalacticOptim, Optim
10-
rosenbrock(x,p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
11-
x0 = zeros(2)
12-
p = [1.0,100.0]
9+
using GalacticOptim
10+
rosenbrock(x,p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
11+
x0 = zeros(2)
12+
p = [1.0,100.0]
1313

14-
prob = OptimizationProblem(rosenbrock,x0,p)
15-
sol = solve(prob,NelderMead())
14+
prob = OptimizationProblem(rosenbrock,x0,p)
1615

16+
using GalacticOptimJL
17+
sol = solve(prob,NelderMead())
1718

18-
using BlackBoxOptim
19-
prob = OptimizationProblem(rosenbrock, x0, p, lb = [-1.0,-1.0], ub = [1.0,1.0])
20-
sol = solve(prob,BBO_adaptive_de_rand_1_bin_radiuslimited())
19+
20+
using GalacticBBO
21+
prob = OptimizationProblem(rosenbrock, x0, p, lb = [-1.0,-1.0], ub = [1.0,1.0])
22+
sol = solve(prob,BBO_adaptive_de_rand_1_bin_radiuslimited())
2123
```
2224

23-
Note that Optim.jl is a core dependency of GalaticOptim.jl. However, BlackBoxOptim.jl
24-
is not and must already be installed (see the list above).
25+
Notice that GalacticOptim.jl is the core glue package that holds all of the common
26+
pieces, but to solve the equations we need to use a solver package. Here, GalcticOptimJL
27+
is for [Optim.jl](https://github.com/JuliaNLSolvers/Optim.jl) and GalacticBBO is for
28+
[BlackBoxOptim.jl](https://github.com/robertfeldt/BlackBoxOptim.jl).
2529

2630
The output of the first optimization task (with the `NelderMead()` algorithm)
2731
is given below:
2832

2933
```julia
30-
* Status: success
34+
sol = solve(prob,NelderMead())
35+
u: 2-element Vector{Float64}:
36+
0.9999634355313174
37+
0.9999315506115275
38+
```
3139

32-
* Candidate solution
33-
Final objective value: 3.525527e-09
40+
The solution from the original solver can always be obtained via `original`:
3441

35-
* Found with
36-
Algorithm: Nelder-Mead
42+
```julia
43+
julia> sol.original
44+
* Status: success
3745

38-
* Convergence measures
39-
(Σ(yᵢ-ȳ)²)/n 1.0e-08
46+
* Candidate solution
47+
Final objective value: 3.525527e-09
4048

41-
* Work counters
42-
Seconds run: 0 (vs limit Inf)
43-
Iterations: 60
44-
f(x) calls: 118
49+
* Found with
50+
Algorithm: Nelder-Mead
51+
52+
* Convergence measures
53+
(Σ(yᵢ-ȳ)²)/n 1.0e-08
54+
55+
* Work counters
56+
Seconds run: 0 (vs limit Inf)
57+
Iterations: 60
58+
f(x) calls: 117
4559
```
60+
4661
We can also explore other methods in a similar way:
4762

4863
```julia
@@ -80,6 +95,7 @@ For instance, the above optimization task produces the following output:
8095
prob = OptimizationProblem(f, x0, p, lb = [-1.0,-1.0], ub = [1.0,1.0])
8196
sol = solve(prob, Fminbox(GradientDescent()))
8297
```
98+
8399
The examples clearly demonstrate that GalacticOptim.jl provides an intuitive
84100
way of specifying optimization tasks and offers a relatively
85101
easy access to a wide range of optimization algorithms.

docs/src/tutorials/minibatch.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Minibatch examples
22

3+
!!! note
4+
5+
This example uses the GalacticOptimJL.jl package. See the [Optim.jl page](@ref optim)
6+
for details on the installation and usage.
7+
38
```julia
4-
using DiffEqFlux, GalacticOptim, OrdinaryDiffEq
9+
using DiffEqFlux, GalacticOptim, GalacticOptimJL, OrdinaryDiffEq
510

611
function newtons_cooling(du, u, p, t)
712
temp = u[1]

docs/src/tutorials/rosenbrock.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Rosenbrock function examples
22

3+
!!! note
4+
5+
This example uses many different solvers of GalacticOptim.jl. Each solver
6+
subpackage needs to be installed separate. For example, for the details on
7+
the installation and usage of GalacticOptimJL.jl package, see the
8+
[Optim.jl page](@ref optim).
9+
310
```julia
411
using GalacticOptim, Optim, ForwardDiff, Zygote, Test, Random
512

@@ -10,6 +17,11 @@ _p = [1.0, 100.0]
1017
f = OptimizationFunction(rosenbrock, GalacticOptim.AutoForwardDiff())
1118
l1 = rosenbrock(x0, _p)
1219
prob = OptimizationProblem(f, x0, _p)
20+
21+
## Optim.jl Solvers
22+
23+
using GalacticOptimJL
24+
1325
sol = solve(prob, SimulatedAnnealing())
1426
@test 10*sol.minimum < l1
1527

@@ -18,12 +30,6 @@ prob = OptimizationProblem(f, x0, _p, lb=[-1.0, -1.0], ub=[0.8, 0.8])
1830
sol = solve(prob, SAMIN())
1931
@test 10*sol.minimum < l1
2032

21-
using CMAEvolutionStrategy
22-
sol = solve(prob, CMAEvolutionStrategyOpt())
23-
@test 10*sol.minimum < l1
24-
25-
rosenbrock(x, p=nothing) = (1 - x[1])^2 + 100 * (x[2] - x[1]^2)^2
26-
2733
l1 = rosenbrock(x0)
2834
prob = OptimizationProblem(rosenbrock, x0)
2935
sol = solve(prob, NelderMead())
@@ -86,7 +92,17 @@ prob = OptimizationProblem(optprob, x0, lb=[-1.0, -1.0], ub=[0.8, 0.8])
8692
@test_broken @test_nowarn sol = solve(prob, SAMIN())
8793
@test 10*sol.minimum < l1
8894

89-
using NLopt
95+
## CMAEvolutionStrategy.jl solvers
96+
97+
using GalacticCMAEvolutionStrategy
98+
sol = solve(prob, CMAEvolutionStrategyOpt())
99+
@test 10*sol.minimum < l1
100+
101+
rosenbrock(x, p=nothing) = (1 - x[1])^2 + 100 * (x[2] - x[1]^2)^2
102+
103+
## NLopt.jl solvers
104+
105+
using GalacticNLopt
90106
prob = OptimizationProblem(optprob, x0)
91107
sol = solve(prob, Opt(:LN_BOBYQA, 2))
92108
@test 10*sol.minimum < l1
@@ -101,19 +117,15 @@ sol = solve(prob, Opt(:LD_LBFGS, 2))
101117
sol = solve(prob, Opt(:G_MLSL_LDS, 2), nstart=2, local_method = Opt(:LD_LBFGS, 2), maxiters=10000)
102118
@test 10*sol.minimum < l1
103119

104-
# using MultistartOptimization
105-
# sol = solve(prob, MultistartOptimization.TikTak(100), local_method = NLopt.LD_LBFGS)
106-
# @test 10*sol.minimum < l1
120+
## Evolutionary.jl Solvers
107121

108-
# using QuadDIRECT
109-
# sol = solve(prob, QuadDirect(); splits = ([-0.5, 0.0, 0.5],[-0.5, 0.0, 0.5]))
110-
# @test 10*sol.minimum < l1
111-
112-
using Evolutionary
122+
using GalacticEvolutionary
113123
sol = solve(prob, CMAES=40 , λ = 100),abstol=1e-15)
114124
@test 10*sol.minimum < l1
115125

116-
using BlackBoxOptim
126+
## BlackBoxOptim.jl Solvers
127+
128+
using GalacticBBO
117129
prob = GalacticOptim.OptimizationProblem(optprob, x0, lb=[-1.0, -1.0], ub=[0.8, 0.8])
118130
sol = solve(prob, BBO())
119131
@test 10*sol.minimum < l1

docs/src/tutorials/symbolic.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Symbolic Problem Building with ModelingToolkit
22

3+
!!! note
4+
5+
This example uses the GalacticOptimJL.jl package. See the [Optim.jl page](@ref optim)
6+
for details on the installation and usage.
7+
38
```julia
4-
using ModelingToolkit, GalacticOptim
9+
using ModelingToolkit, GalacticOptim, GalacticOptimJL
510

611
@variables x y
712
@parameters a b

0 commit comments

Comments
 (0)