Model¶

class
pymoo.model.algorithm.
Algorithm
(**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.
Methods
solve
(problem, termination[, seed, disp, …])Solve a given problem by a given evaluator.

solve
(problem, termination, seed=None, disp=False, callback=None, save_history=False, pf=None, **kwargs)¶ Solve a given problem by a given evaluator. The evaluator determines the termination condition and can either have a maximum budget, hypervolume or whatever. The problem can be any problem the algorithm is able to solve.
 Parameters
 problem: class
Problem to be solved by the algorithm
 termination: class
object that evaluates and saves the number of evaluations and determines the stopping condition
 seed: int
Random seed for this run. Before the algorithm starts this seed is set.
 dispbool
If it is true than 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.
 Returns
 resdict
A dictionary that saves all the results of the algorithm. Also, the history if save_history is true.


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
sample
(problem, pop, n_samples, **kwargs)Sample new points with problem information if necessary.

sample
(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
(pop, n_select[, n_parents])Choose from the population new individuals to be selected.

do
(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
(problem, pop, **kwargs)Mutate variables in a genetic way.

do
(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)¶ 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
(problem, pop, parents, **kwargs)This method executes the crossover on the parents.

do
(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
¶ 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
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
(**kwargs)¶ Methods
copy
get
set

class
pymoo.model.result.
Result
(opt, success, message=None)¶ The resulting object of an optimization run.