Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
--HG--
branch : dev
  • Loading branch information
marc.andre.gardner committed Jan 7, 2013
2 parents 83b59b0 + d596e72 commit e414441
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 31 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include *.txt
recursive-include examples *.py *.csv *.json
recursive-include deap *.cpp
recursive-include examples *.py *.csv *.json
recursive-include doc *
prune doc/_build
3 changes: 3 additions & 0 deletions deap/benchmarks/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ def diversity(first_front, first, last):
first.fitness.values[1] - second.fitness.values[1])
for first, second in zip(first_front[:-1], first_front[1:])]

if len(first_front) == 1:
return df + dl

dm = sum(dt)/len(dt)
di = sum(abs(d_i - dm) for d_i in dt)
delta = (df + dl + di)/(df + dl + len(dt) * dm )
Expand Down
24 changes: 13 additions & 11 deletions deap/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,17 +1630,19 @@ def assignCrowdingDist(individuals):
return

distances = [0.0] * len(individuals)
crowding = [(ind.fitness.values, i) for i, ind in enumerate(individuals)]

number_objectives = len(individuals[0].fitness.values)

for i in xrange(number_objectives):
crowding.sort(key=lambda element: element[0][i])
distances[crowding[0][1]] = float("inf")
distances[crowding[-1][1]] = float("inf")
for j in xrange(1, len(crowding) - 1):
distances[crowding[j][1]] += crowding[j + 1][0][i] - \
crowding[j - 1][0][i]
crowd = [(ind.fitness.values, i) for i, ind in enumerate(individuals)]

nobj = len(individuals[0].fitness.values)

for i in xrange(nobj):
crowd.sort(key=lambda element: element[0][i])
distances[crowd[0][1]] = float("inf")
distances[crowd[-1][1]] = float("inf")
if crowd[-1][0][i] == crowd[0][0][i]:
continue
norm = nobj * float(crowd[-1][0][i] - crowd[0][0][i])
for prev, cur, next in zip(crowd[:-2], crowd[1:-1], crowd[2:]):
distances[cur[1]] += (next[0][i] - prev[0][i]) / norm

for i, dist in enumerate(distances):
individuals[i].fitness.crowding_dist = dist
Expand Down
16 changes: 8 additions & 8 deletions doc/api/algo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ basic evolutionary computation concepts. All algorithms accept, in addition to
their arguments, an initialized :class:`~deap.tools.Statistics` object to
maintain stats of the evolution, an initialized
:class:`~deap.tools.HallOfFame` to hold the best individual(s) to appear in
the population, and/or an initialized :class:`~deap.tools.EvolutionLogger` to
log what is happening during the evolution.
the population, and a boolean `verbose` to specify wether to
log what is happening during the evolution or not.

.. autofunction:: deap.algorithms.eaSimple(population, toolbox, cxpb, mutpb, ngen[, stats, halloffame, logger])
.. autofunction:: deap.algorithms.eaSimple(population, toolbox, cxpb, mutpb, ngen[, stats, halloffame, verbose])

.. autofunction:: deap.algorithms.eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen[, stats, halloffame, logger])
.. autofunction:: deap.algorithms.eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen[, stats, halloffame, verbose])

.. autofunction:: deap.algorithms.eaMuCommaLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen[, stats, halloffame, logger])
.. autofunction:: deap.algorithms.eaMuCommaLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen[, stats, halloffame, verbose])

.. autofunction:: deap.algorithms.eaGenerateUpdate(toolbox, ngen[, stats, halloffame, logger])
.. autofunction:: deap.algorithms.eaGenerateUpdate(toolbox, ngen[, stats, halloffame, verbose])

Variations
----------
Expand All @@ -39,5 +39,5 @@ Covariance Matrix Adaptation Evolution Strategy
.. autoclass:: deap.cma.Strategy(centroid, sigma[, **kargs])
:members:

.. .. autoclass:: deap.cma.StrategyOnePlusLambda(parent, sigma[, **kargs])
.. :members:
.. autoclass:: deap.cma.StrategyOnePlusLambda(parent, sigma[, **kargs])
:members:
22 changes: 11 additions & 11 deletions doc/api/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Here is a list of the implemented operators in DEAP,
:func:`initRepeat` :func:`cxOnePoint` :func:`mutGaussian` :func:`selTournament` :func:`migRing`
:func:`initIterate` :func:`cxTwoPoints` :func:`mutShuffleIndexes` :func:`selRoulette` ..
:func:`initCycle` :func:`cxUniform` :func:`mutFlipBit` :func:`selNSGA2` ..
:func:`~deap.gp.genFull` :func:`cxPartialyMatched` :func:`mutPolynomialBounded` :func:`selSPEA2` ..
:func:`~deap.gp.genGrow` :func:`cxUniformPartialyMatched` :func:`mutUniformInt` :func:`selRandom` ..
:func:`~deap.gp.genRamped` :func:`cxOrdered` :func:`mutESLogNormal` :func:`selBest` ..
.. :func:`cxPartialyMatched` :func:`mutPolynomialBounded` :func:`selSPEA2` ..
.. :func:`cxUniformPartialyMatched` :func:`mutUniformInt` :func:`selRandom` ..
.. :func:`cxOrdered` :func:`mutESLogNormal` :func:`selBest` ..
.. :func:`cxBlend` .. :func:`selWorst` ..
.. :func:`cxESBlend` .. :func:`selTournamentDCD` ..
.. :func:`cxESTwoPoints` .. .. ..
Expand All @@ -33,14 +33,14 @@ Here is a list of the implemented operators in DEAP,

and genetic programming specific operators.

=========================================== =========================================
Crossover Mutation
=========================================== =========================================
:func:`~deap.gp.cxOnePoint` :func:`~deap.gp.mutUniform`
:func:`~deap.gp.cxOnePointLeafBiased` :func:`~deap.gp.mutNodeReplacement`
.. :func:`~deap.gp.mutEphemeral`
.. :func:`~deap.gp.mutInsert`
=========================================== =========================================
============================ =========================================== =========================================
Initialization Crossover Mutation
============================ =========================================== =========================================
:func:`~deap.gp.genFull` :func:`~deap.gp.cxOnePoint` :func:`~deap.gp.mutUniform`
:func:`~deap.gp.genGrow` :func:`~deap.gp.cxOnePointLeafBiased` :func:`~deap.gp.mutNodeReplacement`
:func:`~deap.gp.genRamped` .. :func:`~deap.gp.mutEphemeral`
.. .. :func:`~deap.gp.mutInsert`
============================ =========================================== =========================================


Initialization
Expand Down

0 comments on commit e414441

Please sign in to comment.