# Standard Cross-Entropy Method (SCEM)¶

class pypop7.optimizers.cem.scem.SCEM(problem, options)

Standard Cross-Entropy Method (SCEM).

Note

SCEM uses the fixed smoothing strategy to update the mean and std of Gaussian search (mutation/sampling) distribution in an online fashion.

Parameters:
• problem (dict) –

problem arguments with the following common settings (keys):
• ’fitness_function’ - objective function to be minimized (func),

• ’ndim_problem’ - number of dimensionality (int),

• ’upper_boundary’ - upper boundary of search range (array_like),

• ’lower_boundary’ - lower boundary of search range (array_like).

• options (dict) –

optimizer options with the following common settings (keys):
• ’max_function_evaluations’ - maximum of function evaluations (int, default: np.Inf),

• ’max_runtime’ - maximal runtime to be allowed (float, default: np.Inf),

• ’seed_rng’ - seed for random number generation needed to be explicitly set (int);

and with the following particular settings (keys):
• ’sigma’ - initial global step-size, aka mutation strength (float),

• ’mean’ - initial (starting) point, aka mean of Gaussian search distribution (array_like),

• if not given, it will draw a random sample from the uniform distribution whose search range is bounded by problem[‘lower_boundary’] and problem[‘upper_boundary’].

• ’n_individuals’ - offspring population size (int, default: 1000),

• ’n_parents’ - parent population size (int, default: 200),

• ’alpha’ - smoothing factor (float, default: 0.8).

Examples

Use the optimizer to minimize the well-known test function Rosenbrock:

``` 1>>> import numpy
2>>> from pypop7.benchmarks.base_functions import rosenbrock  # function to be minimized
3>>> from pypop7.optimizers.cem.scem import SCEM
4>>> problem = {'fitness_function': rosenbrock,  # define problem arguments
5...            'ndim_problem': 100,
6...            'lower_boundary': -5*numpy.ones((100,)),
7...            'upper_boundary': 5*numpy.ones((100,))}
8>>> options = {'max_function_evaluations': 1000000,  # set optimizer options
9...            'seed_rng': 2022,
10...            'sigma': 0.3}  # the global step-size may need to be tuned for better performance
11>>> scem = SCEM(problem, options)  # initialize the optimizer class
12>>> results = scem.optimize()  # run the optimization process
13>>> # return the number of function evaluations and best-so-far fitness
14>>> print(f"SCEM: {results['n_function_evaluations']}, {results['best_so_far_y']}")
15SCEM: 1000000, 45712.10913791263
```

For its correctness checking of coding, refer to this code-based repeatability report for more details.

alpha

smoothing factor.

Type:

float

mean

initial (starting) point, aka mean of Gaussian search distribution.

Type:

array_like

n_individuals

number of offspring, aka offspring population size.

Type:

int

n_parents

number of parents, aka parental population size.

Type:

int

sigma

initial global step-size, aka mutation strength.

Type:

float

References

Kroese, D.P., Porotsky, S. and Rubinstein, R.Y., 2006. The cross-entropy method for continuous multi-extremal optimization. Methodology and Computing in Applied Probability, 8(3), pp.383-407. https://link.springer.com/article/10.1007/s11009-006-9753-0 (See [Appendix B Main CE Program] for the official Matlab code.)

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. https://link.springer.com/article/10.1007/s10479-005-5724-z