Model¶

class
pymoo.model.algorithm.
Algorithm
(callback=None, **kwargs)¶ This class represents the abstract class for any algorithm to be implemented. Most importantly it provides the solve method that is used to optimize a given problem.
The solve method provides a wrapper function which does validate the input.
 Parameters
 problem: class
Problem to be solved by the algorithm
 termination: class
Object that tells the algorithm when to terminate.
 seed: int
Random seed to be used. Same seed is supposed to return the same result. If set to None, a random seed is chosen randomly and stored in the result object to ensure reproducibility.
 verbosebool
If true information during the algorithm execution are displayed
 callbackfunc
A callback function can be passed that is executed every generation. The parameters for the function are the algorithm itself, the number of evaluations so far and the current population.
 def callback(algorithm):
pass
 save_historybool
If true, a current snapshot of each generation is saved.
 pfnp.array
The Paretofront for the given problem. If provided performance metrics are printed during execution.
 evaluatorclass
The evaluator which can be used to make modifications before calling the evaluate function of a problem.
Methods
finalize
initialize
next
solve

class
pymoo.model.sampling.
Sampling
¶ This abstract class represents any sampling strategy that can be used to create an initial population or an initial search point.
Methods
do
(self, problem, pop, n_samples, \*\*kwargs)Sample new points with problem information if necessary.

do
(self, problem, pop, n_samples, **kwargs)¶ Sample new points with problem information if necessary.
 Parameters
 problem: class
The problem to which points should be sampled. (lower and upper bounds, discrete, binary, …)
 n_samples: int
Number of samples
 kwargs: class
Any additional data that might be necessary. e.g. constants of the algorithm, …
 Returns
 Xnp.array
Samples points in a two dimensional array


class
pymoo.model.selection.
Selection
¶ This class is used to select parents for the mating or other evolutionary operators. Several strategies can be used to increase the selection pressure.
Methods
do
(self, pop, n_select[, n_parents])Choose from the population new individuals to be selected.

do
(self, pop, n_select, n_parents=2, **kwargs)¶ Choose from the population new individuals to be selected.
 Parameters
 popclass
The population which should be selected from. Some criteria from the design or objective space might be used for the selection. Therefore, only the number of individual might be not enough.
 n_selectint
Number of individuals to select.
 n_parentsint
Number of parents needed to create an offspring.
 Returns
 np.array
Indices of selected individuals.


class
pymoo.model.mutation.
Mutation
¶ Methods
do
(self, problem, pop, \*\*kwargs)Mutate variables in a genetic way.

do
(self, problem, pop, **kwargs)¶ Mutate variables in a genetic way.
 Parameters
 problemclass
The problem instance  specific information such as variable bounds might be needed.
 popPopulation
A population object
 Returns
 YPopulation
The mutated population.


class
pymoo.model.crossover.
Crossover
(n_parents, n_offsprings, prob=0.9)¶ The crossover combines parents to offsprings. Some crossover are problem specific and use additional information. This class must be inherited from to provide a crossover method to an algorithm.
Methods
do
(self, problem, pop, parents, \*\*kwargs)This method executes the crossover on the parents.

do
(self, problem, pop, parents, **kwargs)¶ This method executes the crossover on the parents. This class wraps the implementation of the class that implements the crossover.
 Parameters
 problem: class
The problem to be solved. Provides information such as lower and upper bounds or feasibility conditions for custom crossovers.
 popPopulation
The population as an object
 parents: numpy.array
The select parents of the population for the crossover
 kwargsdict
Any additional data that might be necessary to perform the crossover. E.g. constants of an algorithm.
 Returns
 offspringsPopulation
The off as a matrix. n_children rows and the number of columns is equal to the variable length of the problem.


class
pymoo.model.survival.
Survival
(filter_infeasible)¶ The survival process is implemented inheriting from this class, which selects from a population only specific individuals to survive.
Methods
do

class
pymoo.model.termination.
Termination
¶ Methods
do_continue
has_finished

class
pymoo.model.indicator.
Indicator
(pf=None, ref_point=None, normalize=False, bounds=None)¶ Methods
calc

class
pymoo.model.population.
Population
(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)¶ Methods
copy
([order])Return a copy of the array.
collect
create
get
merge
new
set

copy
(order='C')¶ Return a copy of the array.
 Parameters
 order{‘C’, ‘F’, ‘A’, ‘K’}, optional
Controls the memory layout of the copy. ‘C’ means Corder, ‘F’ means Forder, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible. (Note that this function and
numpy.copy()
are very similar, but have different default values for their order= arguments.)
See also
Examples
>>> x = np.array([[1,2,3],[4,5,6]], order='F')
>>> y = x.copy()
>>> x.fill(0)
>>> x array([[0, 0, 0], [0, 0, 0]])
>>> y array([[1, 2, 3], [4, 5, 6]])
>>> y.flags['C_CONTIGUOUS'] True


class
pymoo.model.individual.
Individual
(X=None, F=None, CV=None, G=None, feasible=None, **kwargs)¶ Methods
copy
get
set

class
pymoo.model.result.
Result
¶ The resulting object of an optimization run.