Skip to content

Commit 1394ec4

Browse files
Update metaheuristics.md
MOO docs update.
1 parent 79a297b commit 1394ec4

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

docs/src/optimization_packages/metaheuristics.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,54 @@ sol = solve(prob, ECA(), use_initial = true, maxiters = 100000, maxtime = 1000.0
7070
### With Constraint Equations
7171

7272
While `Metaheuristics.jl` supports such constraints, `Optimization.jl` currently does not relay these constraints.
73+
74+
75+
## Multi-objective optimization
76+
The zdt1 functions can be optimized using the `Metaheuristics.jl` as follows:
77+
78+
```@example MOO-Evolutionary
79+
using Optimization, OptimizationEvolutionary
80+
function zdt1(x)
81+
f1 = x[1]
82+
g = 1 + 9 * mean(x[2:end])
83+
h = 1 - sqrt(f1 / g)
84+
f2 = g * h
85+
# In this example, we have no constraints
86+
gx = [0.0] # Inequality constraints (not used)
87+
hx = [0.0] # Equality constraints (not used)
88+
return [f1, f2], gx, hx
89+
end
90+
multi_obj_fun = MultiObjectiveOptimizationFunction((x, p) -> zdt1(x))
91+
92+
# Define the problem bounds
93+
lower_bounds = [0.0, 0.0, 0.0]
94+
upper_bounds = [1.0, 1.0, 1.0]
95+
96+
# Define the initial guess
97+
initial_guess = [0.5, 0.5, 0.5]
98+
99+
# Create the optimization problem
100+
prob = OptimizationProblem(multi_obj_fun, initial_guess; lb = lower_bounds, ub = upper_bounds)
101+
102+
nobjectives = 2
103+
npartitions = 100
104+
105+
# reference points (Das and Dennis's method)
106+
weights = gen_ref_dirs(nobjectives, npartitions)
107+
108+
# Choose the algorithm as required.
109+
alg1 = NSGA2()
110+
alg2 = NSGA3()
111+
alg3 = SPEA2()
112+
alg4 = CCMO(NSGA2(N=100, p_m=0.001))
113+
alg5 = MOEAD_DE(weights, options=Options(debug=false, iterations = 250))
114+
alg6 = SMS_EMOA()
115+
116+
# Solve the problem
117+
sol1 = solve(prob, alg1; maxiters = 100, use_initial = true)
118+
sol2 = solve(prob, alg2; maxiters = 100, use_initial = true)
119+
sol3 = solve(prob, alg3; maxiters = 100, use_initial = true)
120+
sol4 = solve(prob, alg4)
121+
sol5 = solve(prob, alg5; maxiters = 100, use_initial = true)
122+
sol6 = solve(prob, alg6; maxiters = 100, use_initial = true)
123+
```

0 commit comments

Comments
 (0)