Algorithms
pymoode.algorithms
- class pymoode.algorithms.DE(pop_size=100, variant='DE/rand/1/bin', CR=0.7, F=(0.5, 1.0), gamma=0.0001, de_repair='bounce-back', survival=<pymoode.survival.replacement.ImprovementReplacement object>, **kwargs)
Bases:
DifferentialEvolutionSingle-objective Differential Evolution proposed by Storn and Price (1997).
Storn, R. & Price, K., 1997. Differential evolution-a simple and efficient heuristic for global optimization over continuous spaces. J. Glob. Optim., 11(4), pp. 341-359.
- Parameters:
- pop_sizeint, optional
Population size. Defaults to 100.
- variantstr, optional
Differential evolution strategy. Must be a string in the format: “DE/selection/n/crossover”, in which, n in an integer of number of difference vectors, and crossover is either ‘bin’ or ‘exp’. Selection variants are:
‘ranked’
‘rand’
‘best’
‘current-to-best’
‘current-to-best’
‘current-to-rand’
‘rand-to-best’
The selection strategy ‘ranked’ might be helpful to improve convergence speed without much harm to diversity. Defaults to ‘DE/rand/1/bin’.
- CRfloat, optional
Crossover parameter. Defined in the range [0, 1] To reinforce mutation, use higher values. To control convergence speed, use lower values.
- Fiterable of float or float, optional
Scale factor or mutation parameter. Defined in the range (0, 2] To reinforce exploration, use higher values; for exploitation, use lower values.
- gammafloat, optional
Jitter deviation parameter. Should be in the range (0, 2). Defaults to 1e-4.
- de_repairstr, optional
Repair of DE mutant vectors. Is either callable or one of:
‘bounce-back’
‘midway’
‘rand-init’
‘to-bounds’
If callable, has the form fun(X, Xb, xl, xu) in which X contains mutated vectors including violations, Xb contains reference vectors for repair in feasible space, xl is a 1d vector of lower bounds, and xu a 1d vector of upper bounds. Defaults to ‘bounce-back’.
- genetic_mutation, optional
Pymoo’s genetic mutation operator after crossover. Defaults to NoMutation().
- survivalSurvival, optional
Replacement survival operator. Defaults to ImprovementReplacement().
- repairRepair, optional
Pymoo’s repair operator after mutation. Defaults to NoRepair().
- class pymoode.algorithms.GDE3(pop_size=100, variant='DE/rand/1/bin', CR=0.5, F=None, gamma=0.0001, de_repair='bounce-back', survival=<pymoode.survival.rank_and_crowding.rnc.RankAndCrowding object>, **kwargs)
Bases:
MODEGDE3 is an extension of DE to multi-objective problems using a mixed type survival strategy. It is implemented in this version with the same constraint handling strategy of NSGA-II by default.
Derived algorithms GDE3-MNN and GDE3-2NN use by default survival RankAndCrowding with metrics ‘mnn’ and ‘2nn’.
For many-objective problems, try using NSDE-R, GDE3-MNN, or GDE3-2NN.
For Bi-objective problems, survival = RankAndCrowding(crowding_func=’pcd’) is very effective.
Kukkonen, S. & Lampinen, J., 2005. GDE3: The third evolution step of generalized differential evolution. 2005 IEEE congress on evolutionary computation, Volume 1, pp. 443-450.
- Parameters:
- pop_sizeint, optional
Population size. Defaults to 100.
- variantstr, optional
Differential evolution strategy. Must be a string in the format: “DE/selection/n/crossover”, in which, n in an integer of number of difference vectors, and crossover is either ‘bin’ or ‘exp’. Selection variants are:
‘ranked’
‘rand’
‘best’
‘current-to-best’
‘current-to-best’
‘current-to-rand’
‘rand-to-best’
The selection strategy ‘ranked’ might be helpful to improve convergence speed without much harm to diversity. Defaults to ‘DE/rand/1/bin’.
- CRfloat, optional
Crossover parameter. Defined in the range [0, 1] To reinforce mutation, use higher values. To control convergence speed, use lower values.
- Fiterable of float or float, optional
Scale factor or mutation parameter. Defined in the range (0, 2] To reinforce exploration, use higher values; for exploitation, use lower values.
- gammafloat, optional
Jitter deviation parameter. Should be in the range (0, 2). Defaults to 1e-4.
- de_repairstr, optional
Repair of DE mutant vectors. Is either callable or one of:
‘bounce-back’
‘midway’
‘rand-init’
‘to-bounds’
If callable, has the form fun(X, Xb, xl, xu) in which X contains mutated vectors including violations, Xb contains reference vectors for repair in feasible space, xl is a 1d vector of lower bounds, and xu a 1d vector of upper bounds. Defaults to ‘bounce-back’.
- genetic_mutation, optional
Pymoo’s genetic mutation operator after crossover. Defaults to NoMutation().
- repairRepair, optional
Pymoo’s repair operator after mutation. Defaults to NoRepair().
- survivalSurvival, optional
Pymoo’s survival strategy. Defaults to RankAndCrowding() with crowding distances (‘cd’). In GDE3, the survival strategy is applied after a one-to-one comparison between child vector and corresponding parent when both are non-dominated by the other.
- class pymoode.algorithms.NSDE(pop_size=100, variant='DE/rand/1/bin', CR=0.7, F=None, gamma=0.0001, de_repair='bounce-back', survival=<pymoode.survival.rank_and_crowding.rnc.RankAndCrowding object>, **kwargs)
Bases:
MODENSDE is an algorithm that combines that combines NSGA-II sorting and survival strategies to DE mutation and crossover.
For many-objective problems, try using NSDE-R, GDE3-MNN, or GDE3-2NN.
For Bi-objective problems, survival = RankAndCrowding(crowding_func=’pcd’) is very effective.
- Parameters:
- pop_sizeint, optional
Population size. Defaults to 100.
- samplingSampling, optional
Sampling strategy of pymoo. Defaults to LHS().
- variantstr, optional
Differential evolution strategy. Must be a string in the format: “DE/selection/n/crossover”, in which, n in an integer of number of difference vectors, and crossover is either ‘bin’ or ‘exp’. Selection variants are:
“ranked’
‘rand’
‘best’
‘current-to-best’
‘current-to-best’
‘current-to-rand’
‘rand-to-best’
The selection strategy ‘ranked’ might be helpful to improve convergence speed without much harm to diversity. Defaults to ‘DE/rand/1/bin’.
- CRfloat, optional
Crossover parameter. Defined in the range [0, 1] To reinforce mutation, use higher values. To control convergence speed, use lower values.
- Fiterable of float or float, optional
Scale factor or mutation parameter. Defined in the range (0, 2] To reinforce exploration, use higher values; for exploitation, use lower values.
- gammafloat, optional
Jitter deviation parameter. Should be in the range (0, 2). Defaults to 1e-4.
- de_repairstr, optional
Repair of DE mutant vectors. Is either callable or one of:
‘bounce-back’
‘midway’
‘rand-init’
‘to-bounds’
If callable, has the form fun(X, Xb, xl, xu) in which X contains mutated vectors including violations, Xb contains reference vectors for repair in feasible space, xl is a 1d vector of lower bounds, and xu a 1d vector of upper bounds. Defaults to ‘bounce-back’.
- genetic_mutation, optional
Pymoo’s genetic mutation operator after crossover. Defaults to NoMutation().
- repairRepair, optional
Pymoo’s repair operator after mutation. Defaults to NoRepair().
- survivalSurvival, optional
Pymoo’s survival strategy. Defaults to RankAndCrowding() with crowding distances (‘cd’). In GDE3, the survival strategy is applied after a one-to-one comparison between child vector and corresponding parent when both are non-dominated by the other.
- class pymoode.algorithms.NSDER(ref_dirs, pop_size=100, variant='DE/rand/1/bin', CR=0.7, F=None, gamma=0.0001, **kwargs)
Bases:
NSDENSDE-R is an extension of NSDE to many-objective problems (Reddy & Dulikravich, 2019) using NSGA-III survival.
Reddy and G. S. Dulikravich, “Many-objective differential evolution optimization based on reference points: NSDE-R,” Struct. Multidisc. Optim., vol. 60, pp. 1455-1473, 2019.
- Parameters:
- ref_dirsarray like
The reference directions that should be used during the optimization.
- pop_sizeint, optional
Population size. Defaults to 100.
- samplingSampling, optional
Sampling strategy of pymoo. Defaults to LHS().
- variantstr, optional
Differential evolution strategy. Must be a string in the format: “DE/selection/n/crossover”, in which, n in an integer of number of difference vectors, and crossover is either ‘bin’ or ‘exp’. Selection variants are:
“ranked’
‘rand’
‘best’
‘current-to-best’
‘current-to-best’
‘current-to-rand’
‘rand-to-best’
The selection strategy ‘ranked’ might be helpful to improve convergence speed without much harm to diversity. Defaults to ‘DE/rand/1/bin’.
- CRfloat, optional
Crossover parameter. Defined in the range [0, 1] To reinforce mutation, use higher values. To control convergence speed, use lower values.
- Fiterable of float or float, optional
Scale factor or mutation parameter. Defined in the range (0, 2] To reinforce exploration, use higher values; for exploitation, use lower values.
- gammafloat, optional
Jitter deviation parameter. Should be in the range (0, 2). Defaults to 1e-4.
- de_repairstr, optional
Repair of DE mutant vectors. Is either callable or one of:
‘bounce-back’
‘midway’
‘rand-init’
‘to-bounds’
If callable, has the form fun(X, Xb, xl, xu) in which X contains mutated vectors including violations, Xb contains reference vectors for repair in feasible space, xl is a 1d vector of lower bounds, and xu a 1d vector of upper bounds. Defaults to ‘bounce-back’.
- genetic_mutation, optional
Pymoo’s genetic mutation operator after crossover. Defaults to NoMutation().
- repairRepair, optional
Pymoo’s repair operator after mutation. Defaults to NoRepair().
- survivalSurvival, optional
Pymoo’s survival strategy. Defaults to ReferenceDirectionSurvival().
pymoode.algorithms.base
- class pymoode.algorithms.base.evolutionary.EvolutionaryAlgorithm(pop_size: int | None = None, sampling: Sampling | None = None, mating: Mating | None = None, survival: Survival | None = None, n_offsprings: int | None = None, eliminate_duplicates: bool = True, repair: Repair | None = None, advance_after_initial_infill: bool = False, **kwargs)
Base class for Evolutionary Algorithms
- Parameters:
- pop_sizeint, optional
Population size, by default None
- samplingSampling, optional
pymoo Sampling instance, by default None
- matingInfillCriterion, optional
pymoo mating operator, by default None
- survivalSurvival, optional
pymoo survival operator, by default None
- n_offspringsint, optional
Number of offspring individuals created at each generation, by default None
- eliminate_duplicatesDuplicateElimination | bool | None, optional
Eliminate duplicates in mating, by default True
- repairRepair, optional
pymoo repair operator. In the algorithm level it should be called when sampling. It is recommended that mating operators also have some repair associated with. By default None
- advance_after_initial_infillbool, optional
Either or not apply survival after initialization, by default False
- Attributes:
- n_gen
Methods
advance
ask
finalize
has_next
infill
next
result
run
setup
tell
- class pymoode.algorithms.base.genetic.GeneticAlgorithm(pop_size=None, sampling=None, selection=None, crossover=None, mutation=None, survival=None, n_offsprings=None, eliminate_duplicates=True, repair=None, **kwargs)
Base class for Genetic Algorithms. A Mating operator is instantiated using selection, crossover, mutation, repair, and eliminate_duplicates arguments.
- Parameters:
- pop_sizeint, optional
Population size, by default None
- samplingSampling, optional
pymoo Sampling instance, by default None
- selectionSelection, optional
pymoo parent selection operator, by default None
- crossoverCrossover, optional
pymoo crossover operator, by default None
- genetic_mutation, optional
pymoo mutation operator, by default None
- survivalSurvival, optional
pymoo survival operator, by default None
- n_offspringsint, optional
Number of offspring individuals created at each generation, by default None
- eliminate_duplicatesDuplicateElimination | bool | None, optional
Eliminate duplicates in mating, by default True
- repairRepair, optional
pymoo repair operator which should be passed to Mating and self. By default None
- advance_after_initial_infillbool, optional
Either or not apply survival after initialization, by default False
- Attributes:
- n_gen
Methods
advance
ask
finalize
has_next
infill
next
result
run
setup
tell