desdeo_emo.population

This module provides classes and methods which implement populations in an EA.

Submodules

Package Contents

Classes

Population

Helper class that provides a standard way to create an ABC using

SurrogatePopulation

Functions

create_new_individuals(design, problem[, pop_size])

Create new individuals to the population.

desdeo_emo.population.create_new_individuals(design, problem, pop_size=None)[source]

Create new individuals to the population.

The individuals can be created randomly, by LHS design, or can be passed by the user.

Design does not apply in case of EvoNN and EvoDN2 problem, where neural networks are created as individuals.

Parameters:
  • design (str, optional) – Describe the method of creation of new individuals. “RandomDesign” creates individuals randomly. “LHSDesign” creates individuals using Latin hypercube sampling. “EvoNN” creates Artificial Neural Networks as individuals. “EvoDN2” creates Deep Neural Networks.

  • problem (baseProblem) – An object of the class Problem

  • pop_size (int, optional) – Number of individuals in the population. If none, some default population size based on number of objectives is chosen.

Returns:

individuals – A list of individuals.

Return type:

list

class desdeo_emo.population.Population(problem: desdeo_problem.MOProblem, pop_size: int, pop_params: Dict = None, use_surrogates: bool = False)[source]

Bases: BasePopulation

Helper class that provides a standard way to create an ABC using inheritance.

add(offsprings: List | numpy.ndarray, use_surrogates: bool = False)

Evaluate and add offspring to the population.

Parameters:
  • offsprings (Union[List, np.ndarray]) – List or array of individuals to be evaluated and added to the population.

  • use_surrogates (bool) – If true, use surrogate models rather than true function evaluations.

  • use_surrogates – If true, use surrogate models rather than true function evaluations.

Returns:

Results of evaluation.

Return type:

Results

keep(indices: List)
Save the population members given by the list of indices for the next

generation. Delete the rest.

Parameters:

indices (List) –

List of indices of the population members to be kept for the next

generation.

delete(indices: List)
Delete the population members given by the list of indices for the next

generation. Keep the rest.

Parameters:

indices (List) – List of indices of the population members to be deleted.

mate(mating_individuals: List = None) List | numpy.ndarray

Perform crossover and mutation over the population members.

Parameters:
  • mating_individuals (List, optional) –

    List of individuals taking part in recombination. By default None, which

    recombinated all individuals in random order.

  • params (Dict, optional) – Parameters for the mutation or crossover operator, by default None.

Returns:

The offspring population

Return type:

Union[List, np.ndarray]

update_ideal()
replace(indices: List, individual: numpy.ndarray, evaluation: tuple)
Replace the population members given by the list of indices by the given individual and its evaluation.

Keep the rest of the population unchanged.

Parameters:
  • indices (List) – List of indices of the population members to be replaced.

  • individual (np.ndarray) – Decision variables of the individual that will replace the positions given in the list.

  • evaluation (tuple) – Result of the evaluation of the objective function, constraints, etc. obtained using the evaluate method.

repair(individual)

Repair the variables of an individual which are not in the boundary defined by the problem :param individual: Decision variables of the individual.

Return type:

The new decision vector with the variables in the boundary defined by the problem

reevaluate_fitness()
non_dominated_fitness()
non_dominated_objectives()
class desdeo_emo.population.SurrogatePopulation(problem, pop_size: int, initial_pop, xover, mutation, recombination)

Bases: desdeo_emo.population.Population.Population, desdeo_emo.population.Population.BasePopulation

Helper class that provides a standard way to create an ABC using inheritance.