:py:mod:`desdeo_emo.population.Population`
==========================================

.. py:module:: desdeo_emo.population.Population


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   desdeo_emo.population.Population.BasePopulation
   desdeo_emo.population.Population.Population




.. py:class:: BasePopulation(problem: desdeo_problem.MOProblem, pop_size: int, pop_params: Dict = None)

   Bases: :py:obj:`abc.ABC`

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

   .. py:method:: ideal_objective_vector() -> numpy.ndarray
      :property:


   .. py:method:: ideal_fitness_val() -> numpy.ndarray
      :property:


   .. py:method:: add(offsprings: Union[List, numpy.ndarray]) -> List
      :abstractmethod:

      Evaluate and add offspring to the population.

      :param offsprings: List or array of individuals to be evaluated and added to the population.
      :type offsprings: Union[List, np.ndarray]

      :returns: Indices of the evaluated individuals
      :rtype: List


   .. py:method:: keep(indices: List)
      :abstractmethod:

      Save the population members given by the list of indices for the next
          generation. Delete the rest.

      :param indices:
                      List of indices of the population members to be kept for the next
                          generation.
      :type indices: List


   .. py:method:: delete(indices: List)
      :abstractmethod:

      Delete the population members given by the list of indices for the next
          generation. Keep the rest.

      :param indices: List of indices of the population members to be deleted.
      :type indices: List


   .. py:method:: mate(mating_individuals: List = None, params: Dict = None) -> Union[List, numpy.ndarray]
      :abstractmethod:

      Perform crossover and mutation over the population members.

      :param mating_individuals:
                                 List of individuals taking part in recombination. By default None, which
                                     recombinated all individuals in random order.
      :type mating_individuals: List, optional
      :param params: Parameters for the mutation or crossover operator, by default None.
      :type params: Dict, optional

      :returns: The offspring population
      :rtype: Union[List, np.ndarray]



.. py:class:: Population(problem: desdeo_problem.MOProblem, pop_size: int, pop_params: Dict = None, use_surrogates: bool = False)

   Bases: :py:obj:`BasePopulation`

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

   .. py:method:: add(offsprings: Union[List, numpy.ndarray], use_surrogates: bool = False)

      Evaluate and add offspring to the population.

      :param offsprings: List or array of individuals to be evaluated and added to the population.
      :type offsprings: Union[List, np.ndarray]
      :param use_surrogates: If true, use surrogate models rather than true function evaluations.
      :type use_surrogates: bool
      :param use_surrogates: If true, use surrogate models rather than true function evaluations.
      :type use_surrogates: bool

      :returns: Results of evaluation.
      :rtype: Results


   .. py:method:: keep(indices: List)

      Save the population members given by the list of indices for the next
          generation. Delete the rest.

      :param indices:
                      List of indices of the population members to be kept for the next
                          generation.
      :type indices: List


   .. py:method:: delete(indices: List)

      Delete the population members given by the list of indices for the next
          generation. Keep the rest.

      :param indices: List of indices of the population members to be deleted.
      :type indices: List


   .. py:method:: mate(mating_individuals: List = None) -> Union[List, numpy.ndarray]

      Perform crossover and mutation over the population members.

      :param mating_individuals:
                                 List of individuals taking part in recombination. By default None, which
                                     recombinated all individuals in random order.
      :type mating_individuals: List, optional
      :param params: Parameters for the mutation or crossover operator, by default None.
      :type params: Dict, optional

      :returns: The offspring population
      :rtype: Union[List, np.ndarray]


   .. py:method:: update_ideal()


   .. py:method:: 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.

      :param indices: List of indices of the population members to be replaced.
      :type indices: List
      :param individual: Decision variables of the individual that will replace the positions given in the list.
      :type individual: np.ndarray
      :param evaluation: Result of the evaluation of the objective function, constraints, etc. obtained using the evaluate method.
      :type evaluation: tuple


   .. py: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.

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


   .. py:method:: reevaluate_fitness()


   .. py:method:: non_dominated_fitness()


   .. py:method:: non_dominated_objectives()



