Skip to content

Commit

Permalink
Update evolutionary.md
Browse files Browse the repository at this point in the history
MOO docs update.
  • Loading branch information
ParasPuneetSingh authored Sep 20, 2024
1 parent 2646d29 commit 79a297b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/src/optimization_packages/evolutionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,23 @@ f = OptimizationFunction(rosenbrock)
prob = Optimization.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
sol = solve(prob, Evolutionary.CMAES(μ = 40, λ = 100))
```

## Multi-objective optimization
The Rosenbrock and Ackley functions can be optimized using the `Evolutionary.NSGA2()` as follows:

```@example MOO-Evolutionary
using Optimization, OptimizationEvolutionary
function func(x, p=nothing)::Vector{Float64}
f1 = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2 # Rosenbrock function
f2 = -20.0 * exp(-0.2 * sqrt(0.5 * (x[1]^2 + x[2]^2))) - exp(0.5 * (cos(2π * x[1]) + cos(2π * x[2]))) + exp(1) + 20.0 # Ackley function
return [f1, f2]
end
initial_guess = [1.0, 1.0]
function gradient_multi_objective(x, p=nothing)
ForwardDiff.jacobian(func, x)
end
obj_func = MultiObjectiveOptimizationFunction(func, jac=gradient_multi_objective)
algorithm = OptimizationEvolutionary.NSGA2()
problem = OptimizationProblem(obj_func, initial_guess)
result = solve(problem, algorithm)
```

0 comments on commit 79a297b

Please sign in to comment.