Animorphic Ensemble Optimization (AEO)¶
A module for Animorphic Ensemble Optimization. A hybrid island model with different evolutionary populations evolved in islands.
Original paper: in progress
What can you use?¶
Multi processing: ✔️
Discrete spaces: ✔️
Continuous spaces: ✔️
Mixed Discrete/Continuous spaces: ✔️
Parameters¶
-
class
neorl.hybrid.aeo.AEO(bounds, fit, optimizers, gen_per_cycle, mode='min', seed=None, **kwargs)[source]¶ Animorphoc Ensemble Optimizer
- Parameters
bounds – (dict) input parameter type and lower/upper bounds in dictionary form. Example:
bounds={'x1': ['int', 1, 4], 'x2': ['float', 0.1, 0.8], 'x3': ['float', 2.2, 6.2]}fit – (function) the fitness function
optimizers – (list) list of optimizer instances to be included in the ensemble
gen_per_cycle – (int) number of generations performed in evolution phase per cycle
mode – (str) problem type, either “min” for minimization problem or “max” for maximization
seed – (int) random seed for sampling
-
evolute(Ncyc, npop0=None, x0=None, pop0=None, stop_criteria=None, verbose=False)[source]¶ This function evolutes the AEO algorithm for a number of cycles. Either (
npop0) or (x0andpop0) are required.- Parameters
Ncyc – (int) number of cycles to evolute
pop0 – (list of ints) number of individuals in starting population for each optimizer
x0 – (list of lists) initial positions of individuals in problem space
pop0 – (list of ints) population assignments for
x0, integer corresponding to assigned population ordered according to self.optimizestop_criteria – (None or callable) function which returns condition if evolution should continue, can be used to stop evolution at certain number of function evaluations
- Returns
(tuple) (best individual, best fitness, xarray.Dataset of various algorithm parameters)
Example¶
import matplotlib.pyplot as plt
from neorl import AEO
from neorl import DE
from neorl import ES
from neorl import GWO
from neorl import PSO
from neorl import WOA
from neorl import MFO
from neorl import SSA
from neorl import JAYA
#define the fitness function
def FIT(individual):
"""Sphere test objective function.
F(x) = sum_{i=1}^d x_i^2
d=1,2,3,...
Range: [-100,100]
Minima: 0
"""
y = sum(x**2 for x in individual)
return y
#Setup the parameter space (d=5)
nx=5
BOUNDS={}
for i in range(1,nx+1):
BOUNDS['x'+str(i)]=['float', -100, 100]
#Define algorithms to be used in enembles
# parameters not directly describing population size
# are carried into the AEO algorithm. See de2 for an
# example of this.
es = ES(mode='min', fit=FIT, bounds=BOUNDS)
gwo = GWO(mode='min', fit=FIT, bounds=BOUNDS)
woa = WOA(mode='min', fit=FIT, bounds=BOUNDS)
mfo = MFO(mode='min', fit=FIT, bounds=BOUNDS)
ssa = SSA(mode='min', fit=FIT, bounds=BOUNDS)
de1 = DE(mode='min', fit=FIT, bounds=BOUNDS)
de2 = DE(mode='min', fit=FIT, bounds=BOUNDS, F=0.5, CR=0.5)
pso = PSO(mode='min', fit=FIT, bounds=BOUNDS)
jaya=JAYA(mode='min', fit=FIT, bounds=BOUNDS)
ensemble = [es, gwo, woa, mfo, ssa, de1, de2, pso, jaya]
#initialize an intance of aeo
aeo = AEO(mode='min', fit=FIT, bounds=BOUNDS, optimizers=ensemble,
gen_per_cycle=2)
#perform evolution
best_x, best_y, log = aeo.evolute(15)
print('Best x')
print(best_x)
print('Best y')
print(best_y)
plt.figure()
for p in log.coords['pop']:
plt.plot(log.coords['cycle'], log['nmembers'].sel({'pop' : p}),
label = p.values)
plt.xlabel("Cycle")
plt.ylabel("Number of Members")
plt.legend()
plt.show()
Notes¶
Only valid in
mode='min'.AEO supports
ES,GWO,WOA,MFO,SSA,DE,PSOandJAYA.Algorithm objects must be defined prior to their inclusion in
AEO(see example)Parameters such as
FinDEormuinESare carried intoAEOafter initialization of these algorithms.Population size parameters such as
nwolvesinGWOare used to determine the starting populations but are changed as the algorithm progresses.fit,boundsandmodeshould be consistent across algorithms passed intoAEO.The total number of function evaluation changes depending on the algorithms in the ensemble and the distribution of members.
Information on the returned log can be found in the code for the
AEOclass.Extra options around the migration process can be accessed through the
kwargsparamter.