Model

class pymoo.core.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.

Parameters
problemProblem

Problem to be solved by the algorithm

termination: :class:`~pymoo.core.termination.Termination`

Object that tells the algorithm when to terminate.

seedint

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.

pfnumpy.array

The Pareto-front for the given problem. If provided performance metrics are printed during execution.

return_least_infeasiblebool

Whether the algorithm should return the least infeasible solution, if no solution was found.

evaluatorEvaluator

The evaluator which can be used to make modifications before calling the evaluate function of a problem.

Methods

advance

ask

finalize

has_next

infill

next

result

run

setup

tell

class pymoo.core.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(problem, n_samples[, pop])

Sample new points with problem information if necessary.

do(problem, n_samples, pop=Population([], dtype=object), **kwargs)

Sample new points with problem information if necessary.

Parameters
problemProblem

The problem to which points should be sampled. (lower and upper bounds, discrete, binary, …)

n_samplesint

Number of samples

popPopulation

The sampling results are stored in a population. The template of the population can be changed. If ‘none’ simply a numpy array is returned.

Returns
Xnumpy.array

Samples points in a two dimensional array

class pymoo.core.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
popPopulation

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
Inumpy.array

Indices of selected individuals.

class pymoo.core.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
XpPopulation

The mutated population.

class pymoo.core.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(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.core.survival.Survival(filter_infeasible=True)

Methods

do

class pymoo.core.termination.Termination

Base class for the implementation of a termination criterion for an algorithm.

Methods

do_continue(algorithm)

Whenever the algorithm objects wants to know whether it should continue or not it simply asks the termination criterion for it.

has_terminated(algorithm)

Instead of asking if the algorithm should continue it can also ask if it has terminated.

do_continue(algorithm)

Whenever the algorithm objects wants to know whether it should continue or not it simply asks the termination criterion for it.

Parameters
algorithmclass

The algorithm object that is asking if it has terminated or not.

Returns
do_continuebool

Whether the algorithm has terminated or not.

has_terminated(algorithm)

Instead of asking if the algorithm should continue it can also ask if it has terminated. (just negates the continue method.)

class pymoo.core.indicator.Indicator(**kwargs)

Methods

do

class pymoo.core.population.Population(n_individuals=0)

Methods

copy([order])

Return a copy of the array.

collect

create

get

has

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 C-order, ‘F’ means F-order, ‘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, and this function always passes sub-classes through.)

See also

numpy.copy

Similar function with different default behavior

numpy.copyto

Notes

This function is the preferred method for creating an array copy. The function numpy.copy() is similar, but it defaults to using order ‘K’, and will not pass sub-classes through by default.

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.core.individual.Individual(X=None, F=None, G=None, dF=None, dG=None, ddF=None, ddG=None, CV=None, feasible=None, **kwargs)

Methods

copy

get

has

set

set_by_dict

class pymoo.core.result.Result

The resulting object of an optimization run.