evograd-diff 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evograd/__init__.py +67 -0
- evograd/algorithms/__init__.py +138 -0
- evograd/algorithms/cmaes.py +1365 -0
- evograd/algorithms/de.py +895 -0
- evograd/algorithms/ga.py +532 -0
- evograd/algorithms/pso.py +648 -0
- evograd/algorithms/shade.py +1165 -0
- evograd/benchmarks/functions/__init__.py +229 -0
- evograd/benchmarks/functions/base.py +217 -0
- evograd/benchmarks/functions/cec2017/__init__.py +250 -0
- evograd/benchmarks/functions/cec2017/basic.py +413 -0
- evograd/benchmarks/functions/cec2017/composition.py +580 -0
- evograd/benchmarks/functions/cec2017/data.pkl +0 -0
- evograd/benchmarks/functions/cec2017/data.py +350 -0
- evograd/benchmarks/functions/cec2017/hybrid.py +406 -0
- evograd/benchmarks/functions/cec2017/simple.py +326 -0
- evograd/benchmarks/functions/classical.py +649 -0
- evograd/benchmarks/functions/smoothed_funnel.py +476 -0
- evograd/benchmarks/functions/transforms.py +463 -0
- evograd/benchmarks/run_benchmark_functions.py +1208 -0
- evograd/core/__init__.py +73 -0
- evograd/core/algorithm.py +778 -0
- evograd/core/maximize.py +269 -0
- evograd/core/minimize.py +740 -0
- evograd/core/problem.py +444 -0
- evograd/core/result.py +571 -0
- evograd/core/termination.py +602 -0
- evograd/operators/__init__.py +178 -0
- evograd/operators/crossover.py +1117 -0
- evograd/operators/mutation.py +1098 -0
- evograd/operators/relaxations.py +175 -0
- evograd/operators/repair.py +601 -0
- evograd/operators/sampling.py +577 -0
- evograd/operators/selection.py +981 -0
- evograd/operators/survival.py +1000 -0
- evograd/tests/__init__.py +11 -0
- evograd/tests/run_all.py +78 -0
- evograd/tests/test_core.py +528 -0
- evograd/tests/test_ga.py +572 -0
- evograd/tests/test_operators.py +662 -0
- evograd/tests/test_per_individual.py +326 -0
- evograd/tests/test_utils.py +328 -0
- evograd/utils/__init__.py +97 -0
- evograd/utils/callbacks.py +926 -0
- evograd/utils/device.py +502 -0
- evograd/utils/duplicates.py +421 -0
- evograd_diff-0.1.0.dist-info/METADATA +439 -0
- evograd_diff-0.1.0.dist-info/RECORD +50 -0
- evograd_diff-0.1.0.dist-info/WHEEL +4 -0
- evograd_diff-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""
|
|
2
|
+
EvoGrad operators module.
|
|
3
|
+
|
|
4
|
+
This module provides the building blocks for evolutionary algorithms:
|
|
5
|
+
|
|
6
|
+
Sampling (population initialisation):
|
|
7
|
+
- UniformSampling: Uniform random sampling
|
|
8
|
+
- LatinHypercubeSampling: Better space coverage
|
|
9
|
+
- NormalSampling: Gaussian around center
|
|
10
|
+
- LogUniformSampling: Log-scale sampling
|
|
11
|
+
- HaltonSampling: Quasi-random low-discrepancy
|
|
12
|
+
|
|
13
|
+
Selection (parent selection):
|
|
14
|
+
- TournamentSelection: Tournament-based selection
|
|
15
|
+
- RouletteSelection: Fitness-proportionate selection
|
|
16
|
+
- RankSelection: Rank-based selection
|
|
17
|
+
- RandomSelection: Uniform random selection
|
|
18
|
+
- TruncationSelection: Select from top fraction (samples within elite set)
|
|
19
|
+
- TopKSelection: Deterministic top-k WITHOUT replacement
|
|
20
|
+
- StochasticUniversalSampling: Evenly-spaced roulette
|
|
21
|
+
|
|
22
|
+
Crossover (recombination):
|
|
23
|
+
- SBXCrossover: Simulated Binary Crossover (GA)
|
|
24
|
+
- BlendCrossover: BLX-alpha crossover (GA)
|
|
25
|
+
- BinomialCrossover: DE-style binomial crossover
|
|
26
|
+
- ExponentialCrossover: DE-style exponential crossover
|
|
27
|
+
- UniformCrossover: Simple uniform crossover
|
|
28
|
+
- ArithmeticCrossover: Weighted average of parents
|
|
29
|
+
- NPointCrossover: N-point crossover
|
|
30
|
+
|
|
31
|
+
Mutation:
|
|
32
|
+
- PolynomialMutation: Bounded polynomial mutation (GA)
|
|
33
|
+
- GaussianMutation: Gaussian/normal perturbation
|
|
34
|
+
- UniformMutation: Uniform random reset
|
|
35
|
+
- NonUniformMutation: Decreasing perturbation over time
|
|
36
|
+
- BoundaryMutation: Reset to boundary values
|
|
37
|
+
- NoMutation: Identity (no mutation)
|
|
38
|
+
- CombinedMutation: Chain multiple mutations
|
|
39
|
+
|
|
40
|
+
Repair (bounds handling):
|
|
41
|
+
- ClipRepair: Clamp to bounds
|
|
42
|
+
- ReflectRepair: Bounce off boundaries
|
|
43
|
+
- WrapRepair: Periodic wrapping
|
|
44
|
+
- RandomRepair: Reset violating genes
|
|
45
|
+
- BoundsRepair: Configurable repair method
|
|
46
|
+
- SoftClipRepair: Smooth differentiable clip
|
|
47
|
+
- PenaltyRepair: Compute penalty instead of repair
|
|
48
|
+
- NoRepair: Identity (no repair)
|
|
49
|
+
|
|
50
|
+
Survival (generational replacement):
|
|
51
|
+
- MergeSurvival: (μ+λ) Select from parents + offspring
|
|
52
|
+
- CommaSurvival: (μ,λ) Select only from offspring
|
|
53
|
+
- ReplaceWorstSurvival: Steady-state replacement
|
|
54
|
+
- FitnessSurvival: Simple fitness-based truncation
|
|
55
|
+
- AgeSurvival: Age-based with fitness tie-breaking
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
from evograd.operators.sampling import (
|
|
59
|
+
Sampling,
|
|
60
|
+
UniformSampling,
|
|
61
|
+
LatinHypercubeSampling,
|
|
62
|
+
NormalSampling,
|
|
63
|
+
LogUniformSampling,
|
|
64
|
+
HaltonSampling,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
from evograd.operators.selection import (
|
|
68
|
+
Selection,
|
|
69
|
+
TournamentSelection,
|
|
70
|
+
RouletteSelection,
|
|
71
|
+
RankSelection,
|
|
72
|
+
RandomSelection,
|
|
73
|
+
TopKSelection,
|
|
74
|
+
TopKSelection,
|
|
75
|
+
TruncationSelection,
|
|
76
|
+
StochasticUniversalSampling,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
from evograd.operators.crossover import (
|
|
80
|
+
Crossover,
|
|
81
|
+
SBXCrossover,
|
|
82
|
+
BlendCrossover,
|
|
83
|
+
BinomialCrossover,
|
|
84
|
+
ExponentialCrossover,
|
|
85
|
+
UniformCrossover,
|
|
86
|
+
ArithmeticCrossover,
|
|
87
|
+
NPointCrossover,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
from evograd.operators.mutation import (
|
|
91
|
+
Mutation,
|
|
92
|
+
PolynomialMutation,
|
|
93
|
+
GaussianMutation,
|
|
94
|
+
UniformMutation,
|
|
95
|
+
NonUniformMutation,
|
|
96
|
+
BoundaryMutation,
|
|
97
|
+
NoMutation,
|
|
98
|
+
CombinedMutation,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
from evograd.operators.repair import (
|
|
102
|
+
Repair,
|
|
103
|
+
ClipRepair,
|
|
104
|
+
ReflectRepair,
|
|
105
|
+
WrapRepair,
|
|
106
|
+
RandomRepair,
|
|
107
|
+
BoundsRepair,
|
|
108
|
+
SoftClipRepair,
|
|
109
|
+
PenaltyRepair,
|
|
110
|
+
NoRepair,
|
|
111
|
+
RepairMethod,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
from evograd.operators.survival import (
|
|
115
|
+
Survival,
|
|
116
|
+
MergeSurvival,
|
|
117
|
+
CommaSurvival,
|
|
118
|
+
ReplaceWorstSurvival,
|
|
119
|
+
FitnessSurvival,
|
|
120
|
+
AgeSurvival,
|
|
121
|
+
get_survival,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
__all__ = [
|
|
125
|
+
# Sampling
|
|
126
|
+
"Sampling",
|
|
127
|
+
"UniformSampling",
|
|
128
|
+
"LatinHypercubeSampling",
|
|
129
|
+
"NormalSampling",
|
|
130
|
+
"LogUniformSampling",
|
|
131
|
+
"HaltonSampling",
|
|
132
|
+
# Selection
|
|
133
|
+
"Selection",
|
|
134
|
+
"TournamentSelection",
|
|
135
|
+
"RouletteSelection",
|
|
136
|
+
"RankSelection",
|
|
137
|
+
"RandomSelection",
|
|
138
|
+
"TopKSelection",
|
|
139
|
+
"TruncationSelection",
|
|
140
|
+
"StochasticUniversalSampling",
|
|
141
|
+
# Crossover
|
|
142
|
+
"Crossover",
|
|
143
|
+
"SBXCrossover",
|
|
144
|
+
"BlendCrossover",
|
|
145
|
+
"BinomialCrossover",
|
|
146
|
+
"ExponentialCrossover",
|
|
147
|
+
"UniformCrossover",
|
|
148
|
+
"ArithmeticCrossover",
|
|
149
|
+
"NPointCrossover",
|
|
150
|
+
# Mutation
|
|
151
|
+
"Mutation",
|
|
152
|
+
"PolynomialMutation",
|
|
153
|
+
"GaussianMutation",
|
|
154
|
+
"UniformMutation",
|
|
155
|
+
"NonUniformMutation",
|
|
156
|
+
"BoundaryMutation",
|
|
157
|
+
"NoMutation",
|
|
158
|
+
"CombinedMutation",
|
|
159
|
+
# Repair
|
|
160
|
+
"Repair",
|
|
161
|
+
"ClipRepair",
|
|
162
|
+
"ReflectRepair",
|
|
163
|
+
"WrapRepair",
|
|
164
|
+
"RandomRepair",
|
|
165
|
+
"BoundsRepair",
|
|
166
|
+
"SoftClipRepair",
|
|
167
|
+
"PenaltyRepair",
|
|
168
|
+
"NoRepair",
|
|
169
|
+
"RepairMethod",
|
|
170
|
+
# Survival
|
|
171
|
+
"Survival",
|
|
172
|
+
"MergeSurvival",
|
|
173
|
+
"CommaSurvival",
|
|
174
|
+
"ReplaceWorstSurvival",
|
|
175
|
+
"FitnessSurvival",
|
|
176
|
+
"AgeSurvival",
|
|
177
|
+
"get_survival",
|
|
178
|
+
]
|