platypus.algorithms module
- class AbstractGeneticAlgorithm(problem, population_size=100, generator=<platypus.operators.RandomGenerator object>, **kwargs)
Bases:
AlgorithmAbstract class for genetic algorithms.
Generally speaking, genetic algorithms follow these steps:
Initialization, where the population is filled with random solutions.
Mating selection, where the parents for mating are selected using some preference.
Recombination, where any crossover or mutation operators are applied to produce offspring.
Survival selection, where the content of the next generation is selected.
Subclasses can implement the
initialze()anditerate()methods. However, when running an algorithm, users should simply call therun()method.The
initialize()method is called exactly once on the first call tostep()to initialize the population. The default implementation produces a random population, but can be extended to perform any other required initialization.The
iterate()method performs one iteration of the algorithm. Typically this means performing mating selection, recombination and survival selection, either for the entire population or a subset. Each invocation should produce and evaluate at least one offspring to ensure forward progress (and avoid getting stuck in an infinite loop).Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- generatorGenerator
The method for generating the initial population.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class CMAES(problem, offspring_size=100, cc=None, cs=None, damps=None, ccov=None, ccovsep=None, sigma=None, diagonal_iterations=0, indicator='crowding', initial_search_point=None, check_consistency=False, epsilons=None, **kwargs)
Bases:
AlgorithmCovariance matrix adaption evolution strategy (CMA-ES).
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class EpsMOEA(problem, epsilons, population_size=100, generator=<platypus.operators.RandomGenerator object>, selector=<platypus.operators.TournamentSelector object>, variator=None, **kwargs)
Bases:
AbstractGeneticAlgorithm
-MOEA.Uses an epsilon-dominance archive to bound the size of the archive. Additionally, mating occurs between a member of the population and a member of the archive.
See
EpsilonBoxArchivefor more details on epsilon dominance.Parameters
- problemProblem
The problem to optimize.
- epsilonslist of float
The epsilon values.
- population_sizeint
The size of the population.
- generatorGenerator
The method for generating the initial population.
- selectorSelector
The method for selecting parents for mating.
- variatorVariator, optional
The variator used during mating to produce offspring. If
None, the default variator configured inPlatypusConfigis selected.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class EpsNSGAII(problem, epsilons, population_size=100, generator=<platypus.operators.RandomGenerator object>, selector=<platypus.operators.TournamentSelector object>, variator=None, **kwargs)
Bases:
NSGAIIEpsilon-dominance NSGA-II (
-NSGA-II).Extends NSGA-II to use an epsilon-dominance archive to track the best solutions found during search. This is essentially a form of elitism for multi-objective problems.
Parameters
- problemProblem
The problem to optimize.
- epsilonslist of float
The epsilons used to configure the epsilon-dominance archive.
- population_sizeint
The size of the population.
- generatorGenerator
The method for generating the initial population.
- selectorSelector
The method for selecting parents for mating.
- variatorVariator, optional
The variator used during mating to produce offspring. If
None, the default variator configured inPlatypusConfigis selected.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class EvolutionaryStrategy(problem, population_size=100, offspring_size=100, generator=<platypus.operators.RandomGenerator object>, comparator=<platypus.core.ParetoDominance object>, variator=None, **kwargs)
Bases:
SingleObjectiveAlgorithmSingle-objective evolutionary strategy (ES).
Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- offspring_sizeint
The number of offspring to generate each iteration.
- generatorGenerator
The method for generating the initial population.
- comparatorDominance
The dominance criteria for ranking solutions.
- variatorVariator, optional
The variator used during mating to produce offspring. Must have an arity of
1. IfNone, the default mutation configured inPlatypusConfigis selected.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class GDE3(problem, population_size=100, generator=<platypus.operators.RandomGenerator object>, variator=<platypus.operators.DifferentialEvolution object>, **kwargs)
Bases:
AbstractGeneticAlgorithmGeneralized differential evolution (GDE3).
Only supporting real-valued problems, GDE3 uses differential evolution to evolve the population.
Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- generatorGenerator
The method for generating the initial population.
- variatorVariator
The variator used during mating to produce offspring. Must use the differential evolution operator.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class GeneticAlgorithm(problem, population_size=100, offspring_size=100, generator=<platypus.operators.RandomGenerator object>, selector=<platypus.operators.TournamentSelector object>, comparator=<platypus.core.ParetoDominance object>, variator=None, **kwargs)
Bases:
SingleObjectiveAlgorithmSingle-objective genetic algorithm (GA).
A genetic algorithm is a generational algorithm that evolves a population of solutions. Each iteration, some number of offspring are produced by applying the given selection and variation operators. Then, the combined population of parents and offspring are ranked according to the comparison operator and truncated.
This implementation keeps track of the fittest individual in the population, ensuring it always survives to the next generation.
Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- offspring_sizeint
The number of offspring to generate each iteration.
- generatorGenerator
The method for generating the initial population.
- selectorSelector
The method for selecting parents for mating.
- comparatorDominance
The dominance criteria for ranking solutions.
- variatorVariator, optional
The variator used during mating to produce offspring. If
None, the default variator configured inPlatypusConfigis selected.
Attributes
- fittestSolution
The fittest solution found thus far.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class IBEA(problem, population_size=100, generator=<platypus.operators.RandomGenerator object>, fitness_evaluator=<platypus.core.HypervolumeFitnessEvaluator object>, fitness_comparator=<platypus.core.AttributeDominance object>, variator=None, **kwargs)
Bases:
AbstractGeneticAlgorithmIndicator-based evolutionary algorithm (IBEA).
Uses a
FitnessEvaluatorto measure the fitness of solutions, typically based on hypervolume.Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- generatorGenerator
The method for generating the initial population.
- fitness_evaluatorFitnessEvaluator
The method for computing the fitness of solutions. Default uses hypervolume.
- fitness_comparatorDominance
The domnance criteria using the fitness value.
- variatorVariator
The variator used during mating to produce offspring. If
None, the default variator configured inPlatypusConfigis selected.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class MOEAD(problem, neighborhood_size=10, generator=<platypus.operators.RandomGenerator object>, variator=None, delta=0.8, eta=1, update_utility=None, weight_generator=<function random_weights>, scalarizing_function=<function chebyshev>, **kwargs)
Bases:
AbstractGeneticAlgorithmMultiobjective evolutionary algorithm with decomposition (MOEA/D).
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class NSGAII(problem, population_size=100, generator=<platypus.operators.RandomGenerator object>, selector=<platypus.operators.TournamentSelector object>, variator=None, archive=None, **kwargs)
Bases:
AbstractGeneticAlgorithmNon-dominated sorting genetic algorithm (NSGA-II).
Most notably, NSGA-II uses non-dominated sorting during survival selection to assign rank and crowding distance values to solutions. The next generation is filled with solutions with lower ranks. When selecting from the last rank, solutions with larger crowding distances (more diverse) are preferred.
See
nondominated_sort()for more details on non-dominated sorting.Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- generatorGenerator
The method for generating the initial population.
- selectorSelector
The method for selecting parents for mating.
- variatorVariator, optional
The variator used during mating to produce offspring. If
None, the default variator configured inPlatypusConfigis selected.- archiveArchive, optional
The archive to store the best solutions found during optimization.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class NSGAIII(problem, divisions_outer, divisions_inner=0, generator=<platypus.operators.RandomGenerator object>, selector=<platypus.operators.TournamentSelector object>, variator=None, **kwargs)
Bases:
AbstractGeneticAlgorithmNon-dominated sorting genetic algorithm with reference ponts (NSGA-III).
Replaces NSGA-II’s crowding distance-based selection with one using reference points. At a high level, the advantage of reference points is two-fold. First, they can provide a better distribution of points, especially on problems with many objectives where most solutions tend to be non-dominated. Second, the reference points can be selected to target specific regions of interest.
Parameters
- problemProblem
The problem to optimize.
- divisions_outerint
The number of divisions. When
divisions_inneris non-zero, this represents the number of outer divisions.- divisions_innerint
The number of inner divisions.
- generatorGenerator
The method for generating the initial population.
- selectorSelector
The method for selecting parents for mating.
- variatorVariator
The variator used during mating to produce offspring. Must use the differential evolution operator.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class OMOPSO(problem, epsilons, swarm_size=100, leader_size=100, generator=<platypus.operators.RandomGenerator object>, mutation_probability=0.1, mutation_perturbation=0.5, max_iterations=100, **kwargs)
Bases:
ParticleSwarmMulti-objective particle swarm optimizer (OMOPSO).
Notably, OMOPSO introduces a uniform and non-uniform mutation operator that are applied to offspring. The non-uniform operator scales itself based on the maximum number of iterations, reducing the magnitude of mutations as the run progresses.
Parameters
- problemProblem
The problem to optimize.
- epsilonslist of float
The epsilons controlling the size of the epsilon-dominance archive.
- swarm_sizeint
The size of the swarm (synonymous to a population).
- leader_sizeint
The number of leaders to track (synonymous to an archive).
- generatorGenerator
The method for generating the initial population.
- mutation_probabilityfloat
The probability of mutation.
- mutation_perturbationfloat
Controls the distribution of offspring produced by mutation.
- max_iterationsint
The maximum number of iterations you expect to run this algorithm. This controls how quickly the non-uniform mutation scales.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class PAES(problem, divisions=8, capacity=100, generator=<platypus.operators.RandomGenerator object>, variator=None, **kwargs)
Bases:
AbstractGeneticAlgorithmPareto archived evolutionary strategy (PAES).
Uses an adaptive grid archive to maintain a set of diverse solutions. See
AdaptiveGridArchivefor more details.Parameters
- problemProblem
The problem to optimize.
- divisionsint
The number of divisions used by the adaptive grid archive.
- capacityint
The maximum capacity of the adaptive grid archive.
- generatorGenerator
The method for generating the initial population.
- variatorVariator
The variator used during mating to produce offspring. If
None, the default variator configured inPlatypusConfigis selected.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class PESA2(problem, population_size=100, divisions=8, capacity=100, generator=<platypus.operators.RandomGenerator object>, variator=None, **kwargs)
Bases:
AbstractGeneticAlgorithmPareto envelope-based selection algorithm (PESA2).
Uses an adaptive grid archive to maintain a set of diverse solutions. See
AdaptiveGridArchivefor more details.Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- divisionsint
The number of divisions used by the adaptive grid archive.
- capacityint
The maximum capacity of the adaptive grid archive.
- generatorGenerator
The method for generating the initial population.
- variatorVariator
The variator used during mating to produce offspring. If
None, the default variator configured inPlatypusConfigis selected.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class ParticleSwarm(problem, swarm_size=100, leader_size=100, generator=<platypus.operators.RandomGenerator object>, mutate=None, leader_comparator=<platypus.core.AttributeDominance object>, dominance=<platypus.core.ParetoDominance object>, fitness=None, larger_preferred=True, fitness_getter=<function fitness_key>, **kwargs)
Bases:
AlgorithmAbstract class for particle swarm optimization (PSO) algorithms.
Parameters
- problemProblem
The problem to optimize.
- swarm_sizeint
The size of the swarm (synonymous to a population).
- leader_sizeint
The number of leaders to track (synonymous to an archive).
- generatorGenerator
The method for generating the initial population.
- mutateVariator
The mutation used during mating to produce offspring. Must have an arity of
1.- leader_comparatorDominance
The dominance criteria for selecting leaders.
- dominanceDominance
The dominance criteria for ranking solutions.
- fitnessCallable
Function for measuring the fitness of solutions.
- larger_preferredboolean
Indicates if larger or smaller fitness values are preferred.
- fitness_getterCallable
Function to read the fitness value assigned to solutions.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class RegionBasedSelector(archive, grid)
Bases:
SelectorRegion-based selector using density from an adaptive grid archive.
Parameters
- archiveAdaptiveGridArchive
The adaptive grid archive
- griddict
Mapping from grid indices to solutions.
- draw()
Draw a solution at random from the archive.
- select(n, population)
Selects N members from the population.
This default implementation operates “with replacement”, meaning solutions can be selected multiple times. Subclasses are allowed to modify this behavior.
Parameters
- nint
The number of solutions to select from the population.
- population: list of Solution
The population of solutions.
- select_one(population)
Selects one of two solutions drawn from the archive based on density.
- class SMPSO(problem, swarm_size=100, leader_size=100, generator=<platypus.operators.RandomGenerator object>, max_iterations=100, mutate=None, **kwargs)
Bases:
ParticleSwarmSpeed-constrained particle swarm optimizer (SMPSO).
Parameters
- problemProblem
The problem to optimize.
- swarm_sizeint
The size of the swarm (synonymous to a population).
- leader_sizeint
The number of leaders to track (synonymous to an archive).
- generatorGenerator
The method for generating the initial population.
- max_iterationsint
The maximum number of iterations you expect to run this algorithm. This controls how quickly the non-uniform mutation scales.
- mutateVariator
The mutation operator. Must have an arity of
1.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class SPEA2(problem, population_size=100, generator=<platypus.operators.RandomGenerator object>, variator=None, dominance=<platypus.core.ParetoDominance object>, k=1, **kwargs)
Bases:
AbstractGeneticAlgorithmImproved strength-based Pareto evolutionary algorithm (SPEA2).
SPEA2 uses a novel strengh-based measure of fitness, which is a combination of the number other solutions that are dominated plus a density or crowding distance measure.
Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- generatorGenerator
The method for generating the initial population.
- variatorVariator
The variator used during mating to produce offspring. Must use the differential evolution operator.
- dominanceDominance
The dominance criteria for ranking solutions.
- kint
Niching parameter specifying that crowding is based on the k-th nearest neighbor.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.
- class SingleObjectiveAlgorithm(problem, population_size=100, generator=<platypus.operators.RandomGenerator object>, **kwargs)
Bases:
AbstractGeneticAlgorithmAbstract class for single-objective optimization algorithms.
Parameters
- problemProblem
The problem to optimize.
- population_sizeint
The size of the population.
- generatorGenerator
The method for generating the initial population.
- add_extension(extension)
Adds an extension.
Extensions add functionality to an algorithm at specific points during a run. If multiple extensions are added, they are run in reverse order. That is, the last extension added is the first to run.
Parameters
- extensionExtension
The extension to add.
- remove_extension(extension)
Removes an extension.
Parameters
- extensionExtension or Type
The extension or type of extension to remove.
- run(condition, callback=None)
Runs this algorithm until the termination condition is reached.
Parameters
- conditionint or TerminationCondition
The termination condition. Providing an integer value is converted into the
MaxEvaluationscondition.- callbackCallable, optional
Callback function that is invoked after every iteration. The callback is passed this algorithm instance.