mealpy.probabilistic_based package

mealpy.probabilistic_based.CEM

class mealpy.probabilistic_based.CEM.BaseCEM(problem, epoch=10000, pop_size=100, n_best=30, alpha=0.7, **kwargs)[source]

Bases: mealpy.optimizer.Optimizer

The original version of: Cross-Entropy Method (CEM)

Links:
  1. https://github.com/clever-algorithms/CleverAlgorithms

  2. https://doi.org/10.1007/s10479-005-5724-z

Hyper-parameters should fine tuned in approximate range to get faster convergen toward the global optimum:
  • n_best (int): N selected solutions as a samples for next evolution

  • alpha (float): weight factor for means and stdevs (normal distribution)

Examples

>>> import numpy as np
>>> from mealpy.probabilistic_based.CEM import BaseCEM
>>>
>>> def fitness_function(solution):
>>>     return np.sum(solution**2)
>>>
>>> problem_dict1 = {
>>>     "fit_func": fitness_function,
>>>     "lb": [-10, -15, -4, -2, -8],
>>>     "ub": [10, 15, 12, 8, 20],
>>>     "minmax": "min",
>>>     "verbose": True,
>>> }
>>>
>>> epoch = 1000
>>> pop_size = 50
>>> n_best = 30
>>> alpha = 0.7
>>> model = BaseCEM(problem_dict1, epoch, pop_size, n_best, alpha)
>>> best_position, best_fitness = model.solve()
>>> print(f"Solution: {best_position}, Fitness: {best_fitness}")

References

[1] De Boer, P.T., Kroese, D.P., Mannor, S. and Rubinstein, R.Y., 2005. A tutorial on the cross-entropy method. Annals of operations research, 134(1), pp.19-67.

evolve(epoch)[source]

The main operations (equations) of algorithm. Inherit from Optimizer class

Parameters

epoch (int) – The current iteration