Skip to content

Commit

Permalink
Modified doc for distance as a sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
fmder authored Oct 29, 2016
1 parent 2b86433 commit f5946de
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions deap/tools/constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ class DeltaPenality(object):
individual.
:param delta: Constant or array of constants returned for an invalid individual.
:param distance: A function returning the distance between the individual
and a given valid point (optional, defaults to 0).
and a given valid point. The distance function can also return a sequence
of length equal to the number of objectives to affect multi-objective
fitnesses differently (optional, defaults to 0).
:returns: A decorator for evaluation function.
This function relies on the fitness weights to add correctly the distance.
The fitness value of the ith objective is defined as
.. math::
f^\mathrm{penality}_i(\mathbf{x}) = \Delta_i - w_i d(\mathbf{x})
f^\mathrm{penality}_i(\mathbf{x}) = \Delta_i - w_i d_i(\mathbf{x})
where :math:`\mathbf{x}` is the individual, :math:`\Delta_i` is a user defined
constant and :math:`w_i` is the weight of the ith objective. :math:`\Delta`
Expand Down Expand Up @@ -71,15 +73,17 @@ class ClosestValidPenality(object):
:param alpha: Multiplication factor on the distance between the valid and
invalid individual.
:param distance: A function returning the distance between the individual
and a given valid point (optional, defaults to 0).
and a given valid point. The distance function can also return a sequence
of length equal to the number of objectives to affect multi-objective
fitnesses differently (optional, defaults to 0).
:returns: A decorator for evaluation function.
This function relies on the fitness weights to add correctly the distance.
The fitness value of the ith objective is defined as
.. math::
f^\mathrm{penality}_i(\mathbf{x}) = f_i(\operatorname{valid}(\mathbf{x})) - \\alpha w_i d(\operatorname{valid}(\mathbf{x}), \mathbf{x})
f^\mathrm{penality}_i(\mathbf{x}) = f_i(\operatorname{valid}(\mathbf{x})) - \\alpha w_i d_i(\operatorname{valid}(\mathbf{x}), \mathbf{x})
where :math:`\mathbf{x}` is the individual,
:math:`\operatorname{valid}(\mathbf{x})` is a function returning the closest
Expand Down

0 comments on commit f5946de

Please sign in to comment.