forked from thieu1995/mealpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_large_scale_optimization.py
More file actions
31 lines (24 loc) · 1.09 KB
/
run_large_scale_optimization.py
File metadata and controls
31 lines (24 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# Created by "Thieu" at 15:22, 31/10/2023 ----------%
# Email: nguyenthieu2102@gmail.com %
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%
"""
### Large-Scale Optimization
MEALPY is designed to handle optimization problems with a high number of dimensions.
Here's an example demonstrating how to set up and run an optimization for a large-scale problem.
"""
from mealpy import FloatVar, SHADE
import numpy as np
def objective_function(solution):
return np.sum(solution**2)
problem = {
"obj_func": objective_function,
"bounds": FloatVar(lb=(-1000., )*10000, ub=(1000.,)*10000), # 10000 dimensions
"minmax": "min",
"log_to": "console",
}
## Run the algorithm
optimizer = SHADE.OriginalSHADE(epoch=10000, pop_size=100)
g_best = optimizer.solve(problem)
print(f"Best solution: {g_best.solution}, Best fitness: {g_best.target.fitness}")