pymoo 0.6.1.5.dev0__cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.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.
Potentially problematic release.
This version of pymoo might be problematic. Click here for more details.
- pymoo/__init__.py +3 -0
- pymoo/algorithms/__init__.py +0 -0
- pymoo/algorithms/base/__init__.py +0 -0
- pymoo/algorithms/base/bracket.py +38 -0
- pymoo/algorithms/base/genetic.py +109 -0
- pymoo/algorithms/base/line.py +62 -0
- pymoo/algorithms/base/local.py +39 -0
- pymoo/algorithms/base/meta.py +79 -0
- pymoo/algorithms/hyperparameters.py +89 -0
- pymoo/algorithms/moo/__init__.py +0 -0
- pymoo/algorithms/moo/age.py +310 -0
- pymoo/algorithms/moo/age2.py +194 -0
- pymoo/algorithms/moo/ctaea.py +298 -0
- pymoo/algorithms/moo/dnsga2.py +76 -0
- pymoo/algorithms/moo/kgb.py +446 -0
- pymoo/algorithms/moo/moead.py +183 -0
- pymoo/algorithms/moo/nsga2.py +113 -0
- pymoo/algorithms/moo/nsga3.py +358 -0
- pymoo/algorithms/moo/pinsga2.py +370 -0
- pymoo/algorithms/moo/rnsga2.py +188 -0
- pymoo/algorithms/moo/rnsga3.py +246 -0
- pymoo/algorithms/moo/rvea.py +214 -0
- pymoo/algorithms/moo/sms.py +195 -0
- pymoo/algorithms/moo/spea2.py +190 -0
- pymoo/algorithms/moo/unsga3.py +47 -0
- pymoo/algorithms/soo/__init__.py +0 -0
- pymoo/algorithms/soo/convex/__init__.py +0 -0
- pymoo/algorithms/soo/nonconvex/__init__.py +0 -0
- pymoo/algorithms/soo/nonconvex/brkga.py +161 -0
- pymoo/algorithms/soo/nonconvex/cmaes.py +554 -0
- pymoo/algorithms/soo/nonconvex/de.py +279 -0
- pymoo/algorithms/soo/nonconvex/direct.py +149 -0
- pymoo/algorithms/soo/nonconvex/es.py +203 -0
- pymoo/algorithms/soo/nonconvex/g3pcx.py +94 -0
- pymoo/algorithms/soo/nonconvex/ga.py +93 -0
- pymoo/algorithms/soo/nonconvex/ga_niching.py +223 -0
- pymoo/algorithms/soo/nonconvex/isres.py +74 -0
- pymoo/algorithms/soo/nonconvex/nelder.py +251 -0
- pymoo/algorithms/soo/nonconvex/optuna.py +80 -0
- pymoo/algorithms/soo/nonconvex/pattern.py +183 -0
- pymoo/algorithms/soo/nonconvex/pso.py +399 -0
- pymoo/algorithms/soo/nonconvex/pso_ep.py +297 -0
- pymoo/algorithms/soo/nonconvex/random_search.py +25 -0
- pymoo/algorithms/soo/nonconvex/sres.py +56 -0
- pymoo/algorithms/soo/univariate/__init__.py +0 -0
- pymoo/algorithms/soo/univariate/backtracking.py +59 -0
- pymoo/algorithms/soo/univariate/exp.py +46 -0
- pymoo/algorithms/soo/univariate/golden.py +65 -0
- pymoo/algorithms/soo/univariate/quadr_interp.py +81 -0
- pymoo/algorithms/soo/univariate/wolfe.py +163 -0
- pymoo/config.py +33 -0
- pymoo/constraints/__init__.py +3 -0
- pymoo/constraints/adaptive.py +62 -0
- pymoo/constraints/as_obj.py +56 -0
- pymoo/constraints/as_penalty.py +41 -0
- pymoo/constraints/eps.py +26 -0
- pymoo/constraints/from_bounds.py +36 -0
- pymoo/core/__init__.py +0 -0
- pymoo/core/algorithm.py +394 -0
- pymoo/core/callback.py +38 -0
- pymoo/core/crossover.py +77 -0
- pymoo/core/decision_making.py +102 -0
- pymoo/core/decomposition.py +76 -0
- pymoo/core/duplicate.py +163 -0
- pymoo/core/evaluator.py +116 -0
- pymoo/core/indicator.py +34 -0
- pymoo/core/individual.py +784 -0
- pymoo/core/infill.py +64 -0
- pymoo/core/initialization.py +42 -0
- pymoo/core/mating.py +39 -0
- pymoo/core/meta.py +21 -0
- pymoo/core/mixed.py +165 -0
- pymoo/core/mutation.py +44 -0
- pymoo/core/operator.py +40 -0
- pymoo/core/parameters.py +134 -0
- pymoo/core/plot.py +210 -0
- pymoo/core/population.py +180 -0
- pymoo/core/problem.py +460 -0
- pymoo/core/recorder.py +99 -0
- pymoo/core/repair.py +23 -0
- pymoo/core/replacement.py +96 -0
- pymoo/core/result.py +52 -0
- pymoo/core/sampling.py +43 -0
- pymoo/core/selection.py +61 -0
- pymoo/core/solution.py +10 -0
- pymoo/core/survival.py +103 -0
- pymoo/core/termination.py +70 -0
- pymoo/core/variable.py +399 -0
- pymoo/cython/__init__.py +0 -0
- pymoo/cython/calc_perpendicular_distance.cpython-312-x86_64-linux-gnu.so +0 -0
- pymoo/cython/calc_perpendicular_distance.pyx +67 -0
- pymoo/cython/decomposition.cpython-312-x86_64-linux-gnu.so +0 -0
- pymoo/cython/decomposition.pyx +165 -0
- pymoo/cython/hv.cpython-312-x86_64-linux-gnu.so +0 -0
- pymoo/cython/hv.pyx +18 -0
- pymoo/cython/info.cpython-312-x86_64-linux-gnu.so +0 -0
- pymoo/cython/info.pyx +5 -0
- pymoo/cython/mnn.cpython-312-x86_64-linux-gnu.so +0 -0
- pymoo/cython/mnn.pyx +273 -0
- pymoo/cython/non_dominated_sorting.cpython-312-x86_64-linux-gnu.so +0 -0
- pymoo/cython/non_dominated_sorting.pyx +645 -0
- pymoo/cython/pruning_cd.cpython-312-x86_64-linux-gnu.so +0 -0
- pymoo/cython/pruning_cd.pyx +197 -0
- pymoo/cython/stochastic_ranking.cpython-312-x86_64-linux-gnu.so +0 -0
- pymoo/cython/stochastic_ranking.pyx +49 -0
- pymoo/cython/utils.pxd +129 -0
- pymoo/cython/vendor/__init__.py +0 -0
- pymoo/cython/vendor/hypervolume.cpp +1621 -0
- pymoo/cython/vendor/hypervolume.h +63 -0
- pymoo/decomposition/__init__.py +0 -0
- pymoo/decomposition/aasf.py +24 -0
- pymoo/decomposition/asf.py +10 -0
- pymoo/decomposition/pbi.py +13 -0
- pymoo/decomposition/perp_dist.py +13 -0
- pymoo/decomposition/tchebicheff.py +11 -0
- pymoo/decomposition/util.py +13 -0
- pymoo/decomposition/weighted_sum.py +8 -0
- pymoo/docs.py +187 -0
- pymoo/experimental/__init__.py +0 -0
- pymoo/experimental/algorithms/__init__.py +0 -0
- pymoo/experimental/algorithms/gde3.py +57 -0
- pymoo/gradient/__init__.py +21 -0
- pymoo/gradient/automatic.py +57 -0
- pymoo/gradient/grad_autograd.py +105 -0
- pymoo/gradient/grad_complex.py +35 -0
- pymoo/gradient/grad_jax.py +51 -0
- pymoo/gradient/toolbox/__init__.py +6 -0
- pymoo/indicators/__init__.py +0 -0
- pymoo/indicators/distance_indicator.py +55 -0
- pymoo/indicators/gd.py +7 -0
- pymoo/indicators/gd_plus.py +7 -0
- pymoo/indicators/hv/__init__.py +63 -0
- pymoo/indicators/hv/exact.py +71 -0
- pymoo/indicators/hv/exact_2d.py +102 -0
- pymoo/indicators/hv/monte_carlo.py +74 -0
- pymoo/indicators/igd.py +7 -0
- pymoo/indicators/igd_plus.py +7 -0
- pymoo/indicators/kktpm.py +151 -0
- pymoo/indicators/migd.py +55 -0
- pymoo/indicators/rmetric.py +203 -0
- pymoo/indicators/spacing.py +52 -0
- pymoo/mcdm/__init__.py +0 -0
- pymoo/mcdm/compromise_programming.py +19 -0
- pymoo/mcdm/high_tradeoff.py +40 -0
- pymoo/mcdm/pseudo_weights.py +32 -0
- pymoo/operators/__init__.py +0 -0
- pymoo/operators/control.py +187 -0
- pymoo/operators/crossover/__init__.py +0 -0
- pymoo/operators/crossover/binx.py +45 -0
- pymoo/operators/crossover/dex.py +122 -0
- pymoo/operators/crossover/erx.py +162 -0
- pymoo/operators/crossover/expx.py +51 -0
- pymoo/operators/crossover/hux.py +37 -0
- pymoo/operators/crossover/nox.py +13 -0
- pymoo/operators/crossover/ox.py +84 -0
- pymoo/operators/crossover/pcx.py +82 -0
- pymoo/operators/crossover/pntx.py +49 -0
- pymoo/operators/crossover/sbx.py +125 -0
- pymoo/operators/crossover/spx.py +5 -0
- pymoo/operators/crossover/ux.py +20 -0
- pymoo/operators/mutation/__init__.py +0 -0
- pymoo/operators/mutation/bitflip.py +17 -0
- pymoo/operators/mutation/gauss.py +58 -0
- pymoo/operators/mutation/inversion.py +42 -0
- pymoo/operators/mutation/nom.py +7 -0
- pymoo/operators/mutation/pm.py +94 -0
- pymoo/operators/mutation/rm.py +23 -0
- pymoo/operators/repair/__init__.py +0 -0
- pymoo/operators/repair/bounce_back.py +32 -0
- pymoo/operators/repair/bounds_repair.py +95 -0
- pymoo/operators/repair/inverse_penalty.py +89 -0
- pymoo/operators/repair/rounding.py +18 -0
- pymoo/operators/repair/to_bound.py +31 -0
- pymoo/operators/repair/vtype.py +11 -0
- pymoo/operators/sampling/__init__.py +0 -0
- pymoo/operators/sampling/lhs.py +73 -0
- pymoo/operators/sampling/rnd.py +50 -0
- pymoo/operators/selection/__init__.py +0 -0
- pymoo/operators/selection/rnd.py +72 -0
- pymoo/operators/selection/tournament.py +76 -0
- pymoo/operators/survival/__init__.py +0 -0
- pymoo/operators/survival/rank_and_crowding/__init__.py +1 -0
- pymoo/operators/survival/rank_and_crowding/classes.py +209 -0
- pymoo/operators/survival/rank_and_crowding/metrics.py +208 -0
- pymoo/optimize.py +72 -0
- pymoo/problems/__init__.py +157 -0
- pymoo/problems/dyn.py +47 -0
- pymoo/problems/dynamic/__init__.py +0 -0
- pymoo/problems/dynamic/cec2015.py +108 -0
- pymoo/problems/dynamic/df.py +452 -0
- pymoo/problems/dynamic/misc.py +167 -0
- pymoo/problems/functional.py +48 -0
- pymoo/problems/many/__init__.py +5 -0
- pymoo/problems/many/cdtlz.py +159 -0
- pymoo/problems/many/dcdtlz.py +88 -0
- pymoo/problems/many/dtlz.py +264 -0
- pymoo/problems/many/wfg.py +550 -0
- pymoo/problems/multi/__init__.py +14 -0
- pymoo/problems/multi/bnh.py +34 -0
- pymoo/problems/multi/carside.py +48 -0
- pymoo/problems/multi/clutch.py +104 -0
- pymoo/problems/multi/csi.py +55 -0
- pymoo/problems/multi/ctp.py +198 -0
- pymoo/problems/multi/dascmop.py +213 -0
- pymoo/problems/multi/kursawe.py +25 -0
- pymoo/problems/multi/modact.py +68 -0
- pymoo/problems/multi/mw.py +400 -0
- pymoo/problems/multi/omnitest.py +48 -0
- pymoo/problems/multi/osy.py +32 -0
- pymoo/problems/multi/srn.py +28 -0
- pymoo/problems/multi/sympart.py +94 -0
- pymoo/problems/multi/tnk.py +24 -0
- pymoo/problems/multi/truss2d.py +83 -0
- pymoo/problems/multi/welded_beam.py +41 -0
- pymoo/problems/multi/wrm.py +36 -0
- pymoo/problems/multi/zdt.py +151 -0
- pymoo/problems/multi_to_single.py +22 -0
- pymoo/problems/single/__init__.py +12 -0
- pymoo/problems/single/ackley.py +24 -0
- pymoo/problems/single/cantilevered_beam.py +34 -0
- pymoo/problems/single/flowshop_scheduling.py +112 -0
- pymoo/problems/single/g.py +874 -0
- pymoo/problems/single/griewank.py +18 -0
- pymoo/problems/single/himmelblau.py +15 -0
- pymoo/problems/single/knapsack.py +48 -0
- pymoo/problems/single/mopta08.py +26 -0
- pymoo/problems/single/multimodal.py +20 -0
- pymoo/problems/single/pressure_vessel.py +30 -0
- pymoo/problems/single/rastrigin.py +20 -0
- pymoo/problems/single/rosenbrock.py +22 -0
- pymoo/problems/single/schwefel.py +18 -0
- pymoo/problems/single/simple.py +13 -0
- pymoo/problems/single/sphere.py +19 -0
- pymoo/problems/single/traveling_salesman.py +79 -0
- pymoo/problems/single/zakharov.py +19 -0
- pymoo/problems/static.py +14 -0
- pymoo/problems/util.py +42 -0
- pymoo/problems/zero_to_one.py +27 -0
- pymoo/termination/__init__.py +23 -0
- pymoo/termination/collection.py +12 -0
- pymoo/termination/cv.py +48 -0
- pymoo/termination/default.py +45 -0
- pymoo/termination/delta.py +64 -0
- pymoo/termination/fmin.py +16 -0
- pymoo/termination/ftol.py +144 -0
- pymoo/termination/indicator.py +49 -0
- pymoo/termination/max_eval.py +14 -0
- pymoo/termination/max_gen.py +15 -0
- pymoo/termination/max_time.py +20 -0
- pymoo/termination/robust.py +34 -0
- pymoo/termination/xtol.py +33 -0
- pymoo/util/__init__.py +0 -0
- pymoo/util/archive.py +150 -0
- pymoo/util/cache.py +29 -0
- pymoo/util/clearing.py +82 -0
- pymoo/util/display/__init__.py +0 -0
- pymoo/util/display/column.py +52 -0
- pymoo/util/display/display.py +34 -0
- pymoo/util/display/multi.py +96 -0
- pymoo/util/display/output.py +53 -0
- pymoo/util/display/progress.py +54 -0
- pymoo/util/display/single.py +67 -0
- pymoo/util/dominator.py +67 -0
- pymoo/util/function_loader.py +129 -0
- pymoo/util/hv.py +23 -0
- pymoo/util/matlab_engine.py +39 -0
- pymoo/util/misc.py +460 -0
- pymoo/util/mnn.py +70 -0
- pymoo/util/nds/__init__.py +0 -0
- pymoo/util/nds/dominance_degree_non_dominated_sort.py +159 -0
- pymoo/util/nds/efficient_non_dominated_sort.py +152 -0
- pymoo/util/nds/fast_non_dominated_sort.py +70 -0
- pymoo/util/nds/naive_non_dominated_sort.py +36 -0
- pymoo/util/nds/non_dominated_sorting.py +67 -0
- pymoo/util/nds/tree_based_non_dominated_sort.py +133 -0
- pymoo/util/normalization.py +312 -0
- pymoo/util/optimum.py +42 -0
- pymoo/util/plotting.py +177 -0
- pymoo/util/pruning_cd.py +89 -0
- pymoo/util/randomized_argsort.py +60 -0
- pymoo/util/ref_dirs/__init__.py +24 -0
- pymoo/util/ref_dirs/construction.py +88 -0
- pymoo/util/ref_dirs/das_dennis.py +52 -0
- pymoo/util/ref_dirs/energy.py +319 -0
- pymoo/util/ref_dirs/energy_layer.py +119 -0
- pymoo/util/ref_dirs/genetic_algorithm.py +63 -0
- pymoo/util/ref_dirs/incremental.py +68 -0
- pymoo/util/ref_dirs/misc.py +128 -0
- pymoo/util/ref_dirs/optimizer.py +59 -0
- pymoo/util/ref_dirs/performance.py +162 -0
- pymoo/util/ref_dirs/reduction.py +85 -0
- pymoo/util/ref_dirs/sample_and_map.py +24 -0
- pymoo/util/reference_direction.py +260 -0
- pymoo/util/remote.py +55 -0
- pymoo/util/roulette.py +27 -0
- pymoo/util/running_metric.py +128 -0
- pymoo/util/sliding_window.py +25 -0
- pymoo/util/stochastic_ranking.py +32 -0
- pymoo/util/value_functions.py +719 -0
- pymoo/util/vectors.py +40 -0
- pymoo/util/vf_dominator.py +99 -0
- pymoo/vendor/__init__.py +0 -0
- pymoo/vendor/cec2018.py +398 -0
- pymoo/vendor/gta.py +617 -0
- pymoo/vendor/hv.py +267 -0
- pymoo/vendor/vendor_cmaes.py +412 -0
- pymoo/vendor/vendor_coco.py +81 -0
- pymoo/vendor/vendor_scipy.py +232 -0
- pymoo/version.py +1 -0
- pymoo/visualization/__init__.py +8 -0
- pymoo/visualization/fitness_landscape.py +127 -0
- pymoo/visualization/heatmap.py +123 -0
- pymoo/visualization/pcp.py +120 -0
- pymoo/visualization/petal.py +91 -0
- pymoo/visualization/radar.py +108 -0
- pymoo/visualization/radviz.py +68 -0
- pymoo/visualization/scatter.py +150 -0
- pymoo/visualization/star_coordinate.py +75 -0
- pymoo/visualization/util.py +123 -0
- pymoo/visualization/video/__init__.py +0 -0
- pymoo/visualization/video/callback_video.py +82 -0
- pymoo/visualization/video/one_var_one_obj.py +57 -0
- pymoo/visualization/video/two_var_one_obj.py +62 -0
- pymoo-0.6.1.5.dev0.dist-info/METADATA +187 -0
- pymoo-0.6.1.5.dev0.dist-info/RECORD +328 -0
- pymoo-0.6.1.5.dev0.dist-info/WHEEL +6 -0
- pymoo-0.6.1.5.dev0.dist-info/licenses/LICENSE +191 -0
- pymoo-0.6.1.5.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import cma
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from pymoo.algorithms.base.local import LocalSearch
|
|
5
|
+
from pymoo.core.population import Population
|
|
6
|
+
from pymoo.core.termination import NoTermination
|
|
7
|
+
from pymoo.docs import parse_doc_string
|
|
8
|
+
from pymoo.termination.max_eval import MaximumFunctionCallTermination
|
|
9
|
+
from pymoo.termination.max_gen import MaximumGenerationTermination
|
|
10
|
+
from pymoo.util.display.column import Column
|
|
11
|
+
from pymoo.util.display.single import SingleObjectiveOutput
|
|
12
|
+
from pymoo.util.normalization import ZeroToOneNormalization, NoNormalization
|
|
13
|
+
from pymoo.util.optimum import filter_optimum
|
|
14
|
+
from pymoo.vendor.vendor_cmaes import my_fmin
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# =========================================================================================================
|
|
18
|
+
# Implementation
|
|
19
|
+
# =========================================================================================================
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class CMAESOutput(SingleObjectiveOutput):
|
|
23
|
+
|
|
24
|
+
def __init__(self):
|
|
25
|
+
super().__init__()
|
|
26
|
+
|
|
27
|
+
self.sigma = Column("sigma")
|
|
28
|
+
self.min_std = Column("min_std", width=8)
|
|
29
|
+
self.max_std = Column("max_std", width=8)
|
|
30
|
+
self.axis = Column("axis", width=8)
|
|
31
|
+
|
|
32
|
+
self.run = Column("run", width=4)
|
|
33
|
+
self.fpop = Column("fpop", width=8)
|
|
34
|
+
self.n_pop = Column("n_pop", width=5)
|
|
35
|
+
|
|
36
|
+
def initialize(self, algorithm):
|
|
37
|
+
super().initialize(algorithm)
|
|
38
|
+
|
|
39
|
+
if algorithm.restarts > 0:
|
|
40
|
+
self.columns += [self.run, self.fpop, self.n_pop]
|
|
41
|
+
|
|
42
|
+
self.columns += [self.sigma, self.min_std, self.max_std, self.axis]
|
|
43
|
+
|
|
44
|
+
def update(self, algorithm):
|
|
45
|
+
super().update(algorithm)
|
|
46
|
+
|
|
47
|
+
if not algorithm.es.gi_frame:
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
fmin = algorithm.es.gi_frame.f_locals
|
|
51
|
+
cma = fmin["es"]
|
|
52
|
+
|
|
53
|
+
self.sigma.set(cma.sigma)
|
|
54
|
+
|
|
55
|
+
val = cma.sigma_vec * cma.dC ** 0.5
|
|
56
|
+
self.min_std.set((cma.sigma * min(val)))
|
|
57
|
+
self.max_std.set((cma.sigma * max(val)))
|
|
58
|
+
|
|
59
|
+
if algorithm.restarts > 0:
|
|
60
|
+
self.run.set(int(fmin["irun"] - fmin["runs_with_small"]) + 1)
|
|
61
|
+
self.fpop.set(algorithm.pop.get("F").min())
|
|
62
|
+
self.n_pop.set(int(cma.opts['popsize']))
|
|
63
|
+
|
|
64
|
+
axis = (cma.D.max() / cma.D.min()
|
|
65
|
+
if not cma.opts['CMA_diagonal'] or cma.countiter > cma.opts['CMA_diagonal']
|
|
66
|
+
else max(cma.sigma_vec * 1) / min(cma.sigma_vec * 1))
|
|
67
|
+
self.axis.set(axis)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class CMAES(LocalSearch):
|
|
71
|
+
|
|
72
|
+
def __init__(self,
|
|
73
|
+
x0=None,
|
|
74
|
+
sigma=0.1,
|
|
75
|
+
normalize=True,
|
|
76
|
+
parallelize=True,
|
|
77
|
+
maxfevals=np.inf,
|
|
78
|
+
tolfun=1e-11,
|
|
79
|
+
tolx=1e-11,
|
|
80
|
+
restarts=0,
|
|
81
|
+
restart_from_best='False',
|
|
82
|
+
incpopsize=2,
|
|
83
|
+
eval_initial_x=False,
|
|
84
|
+
noise_handler=None,
|
|
85
|
+
noise_change_sigma_exponent=1,
|
|
86
|
+
noise_kappa_exponent=0,
|
|
87
|
+
bipop=False,
|
|
88
|
+
cmaes_verbose=-9,
|
|
89
|
+
verb_log=0,
|
|
90
|
+
output=CMAESOutput(),
|
|
91
|
+
pop_size=None,
|
|
92
|
+
**kwargs
|
|
93
|
+
):
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
Parameters
|
|
98
|
+
----------
|
|
99
|
+
|
|
100
|
+
x0 : list or `numpy.ndarray`
|
|
101
|
+
initial guess of minimum solution
|
|
102
|
+
before the application of the geno-phenotype transformation
|
|
103
|
+
according to the ``transformation`` option. It can also be
|
|
104
|
+
a string holding a Python expression that is evaluated
|
|
105
|
+
to yield the initial guess - this is important in case
|
|
106
|
+
restarts are performed so that they start from different
|
|
107
|
+
places. Otherwise ``x0`` can also be a `cma.CMAEvolutionStrategy`
|
|
108
|
+
object instance, in that case ``sigma0`` can be ``None``.
|
|
109
|
+
|
|
110
|
+
sigma : float
|
|
111
|
+
Initial standard deviation in each coordinate.
|
|
112
|
+
``sigma0`` should be about 1/4th of the search domain width
|
|
113
|
+
(where the optimum is to be expected). The variables in
|
|
114
|
+
``objective_function`` should be scaled such that they
|
|
115
|
+
presumably have similar sensitivity.
|
|
116
|
+
See also `ScaleCoordinates`.
|
|
117
|
+
|
|
118
|
+
parallelize : bool
|
|
119
|
+
Whether the objective function should be called for each single evaluation or batch wise.
|
|
120
|
+
|
|
121
|
+
restarts : int, default 0
|
|
122
|
+
Number of restarts with increasing population size, see also
|
|
123
|
+
parameter ``incpopsize``, implementing the IPOP-CMA-ES restart
|
|
124
|
+
strategy, see also parameter ``bipop``; to restart from
|
|
125
|
+
different points (recommended), pass ``x0`` as a string.
|
|
126
|
+
|
|
127
|
+
restart_from_best : bool, default false
|
|
128
|
+
Which point to restart from
|
|
129
|
+
|
|
130
|
+
incpopsize : int
|
|
131
|
+
Multiplier for increasing the population size ``popsize`` before each restart
|
|
132
|
+
|
|
133
|
+
eval_initial_x : bool
|
|
134
|
+
Evaluate initial solution, for ``None`` only with elitist option
|
|
135
|
+
|
|
136
|
+
noise_handler : class
|
|
137
|
+
A ``NoiseHandler`` class or instance or ``None``. Example:
|
|
138
|
+
``cma.fmin(f, 6 * [1], 1, noise_handler=cma.NoiseHandler(6))``
|
|
139
|
+
see ``help(cma.NoiseHandler)``.
|
|
140
|
+
|
|
141
|
+
noise_change_sigma_exponent : int
|
|
142
|
+
Exponent for the sigma increment provided by the noise handler for
|
|
143
|
+
additional noise treatment. 0 means no sigma change.
|
|
144
|
+
|
|
145
|
+
noise_kappa_exponent : int
|
|
146
|
+
Instead of applying reevaluations, the "number of evaluations"
|
|
147
|
+
is (ab)used as init_simplex_scale factor kappa (experimental).
|
|
148
|
+
|
|
149
|
+
bipop : bool
|
|
150
|
+
If `True`, run as BIPOP-CMA-ES; BIPOP is a special restart
|
|
151
|
+
strategy switching between two population sizings - small
|
|
152
|
+
(like the default CMA, but with more focused search) and
|
|
153
|
+
large (progressively increased as in IPOP). This makes the
|
|
154
|
+
algorithm perform well both on functions with many regularly
|
|
155
|
+
or irregularly arranged local optima (the latter by frequently
|
|
156
|
+
restarting with small populations). For the `bipop` parameter
|
|
157
|
+
to actually take effect, also select non-zero number of
|
|
158
|
+
(IPOP) restarts; the recommended setting is ``restarts<=9``
|
|
159
|
+
and `x0` passed as a string using `numpy.rand` to generate
|
|
160
|
+
initial solutions. Note that small-population restarts
|
|
161
|
+
do not count into the total restart count.
|
|
162
|
+
|
|
163
|
+
AdaptSigma : True
|
|
164
|
+
Or False or any CMAAdaptSigmaBase class e.g. CMAAdaptSigmaTPA, CMAAdaptSigmaCSA
|
|
165
|
+
|
|
166
|
+
CMA_active : True
|
|
167
|
+
Negative update, conducted after the original update
|
|
168
|
+
|
|
169
|
+
CMA_activefac : 1
|
|
170
|
+
Learning rate multiplier for active update
|
|
171
|
+
|
|
172
|
+
CMA_cmean : 1
|
|
173
|
+
Learning rate for the mean value
|
|
174
|
+
|
|
175
|
+
CMA_const_trace : False
|
|
176
|
+
Normalize trace, 1, True, "arithm", "geom", "aeig", "geig" are valid
|
|
177
|
+
|
|
178
|
+
CMA_diagonal : 0*100*N/popsize**0.5
|
|
179
|
+
Number of iterations with diagonal covariance matrix, True for always
|
|
180
|
+
|
|
181
|
+
CMA_eigenmethod : np.linalg.eigh or cma.utilities.math.eig or pygsl.eigen.eigenvectors
|
|
182
|
+
|
|
183
|
+
CMA_elitist : False or "initial" or True
|
|
184
|
+
Elitism likely impairs global search performance
|
|
185
|
+
|
|
186
|
+
CMA_injections_threshold_keep_len : 0
|
|
187
|
+
Keep length if Mahalanobis length is below the given relative threshold
|
|
188
|
+
|
|
189
|
+
CMA_mirrors : popsize < 6
|
|
190
|
+
Values <0.5 are interpreted as fraction, values >1 as numbers (rounded), otherwise about 0.16 is used
|
|
191
|
+
|
|
192
|
+
CMA_mirrormethod : int, default 2, 0=unconditional, 1=selective, 2=selective with delay
|
|
193
|
+
|
|
194
|
+
CMA_mu : None
|
|
195
|
+
Parents selection parameter, default is popsize // 2
|
|
196
|
+
|
|
197
|
+
CMA_on : 1
|
|
198
|
+
Multiplier for all covariance matrix updates
|
|
199
|
+
|
|
200
|
+
CMA_sampler : None
|
|
201
|
+
A class or instance that implements the interface of
|
|
202
|
+
`cma.interfaces.StatisticalModelSamplerWithZeroMeanBaseClass`
|
|
203
|
+
|
|
204
|
+
CMA_sampler_options : dict
|
|
205
|
+
Options passed to `CMA_sampler` class init as keyword arguments
|
|
206
|
+
|
|
207
|
+
CMA_rankmu : 1.0
|
|
208
|
+
Multiplier for rank-mu update learning rate of covariance matrix
|
|
209
|
+
|
|
210
|
+
CMA_rankone : 1.0
|
|
211
|
+
Multiplier for rank-one update learning rate of covariance matrix
|
|
212
|
+
|
|
213
|
+
CMA_recombination_weights : None
|
|
214
|
+
A list, see class RecombinationWeights, overwrites CMA_mu and popsize options
|
|
215
|
+
|
|
216
|
+
CMA_dampsvec_fac : np.Inf
|
|
217
|
+
Tentative and subject to changes, 0.5 would be a "default" damping for sigma vector update
|
|
218
|
+
|
|
219
|
+
CMA_dampsvec_fade : 0.1
|
|
220
|
+
Tentative fading out parameter for sigma vector update
|
|
221
|
+
|
|
222
|
+
CMA_teststds : None
|
|
223
|
+
Factors for non-isotropic initial distr. of C, mainly for test purpose, see CMA_stds for production
|
|
224
|
+
|
|
225
|
+
CMA_stds : None
|
|
226
|
+
Multipliers for sigma0 in each coordinate, not represented in C,
|
|
227
|
+
makes scaling_of_variables obsolete
|
|
228
|
+
|
|
229
|
+
CSA_dampfac : 1
|
|
230
|
+
Positive multiplier for step-size damping, 0.3 is close to optimal on the sphere
|
|
231
|
+
|
|
232
|
+
CSA_damp_mueff_exponent : 0.5
|
|
233
|
+
Zero would mean no dependency of damping on mueff, useful with CSA_disregard_length option
|
|
234
|
+
|
|
235
|
+
CSA_disregard_length : False
|
|
236
|
+
True is untested, also changes respective parameters
|
|
237
|
+
|
|
238
|
+
CSA_clip_length_value : None
|
|
239
|
+
Poorly tested, [0, 0] means const length N**0.5, [-1, 1] allows a variation of +- N/(N+2), etc.
|
|
240
|
+
|
|
241
|
+
CSA_squared : False
|
|
242
|
+
Use squared length for sigma-adaptation ',
|
|
243
|
+
|
|
244
|
+
BoundaryHandler : BoundTransform or BoundPenalty, unused when ``bounds in (None, [None, None])``
|
|
245
|
+
|
|
246
|
+
conditioncov_alleviate : [1e8, 1e12]
|
|
247
|
+
When to alleviate the condition in the coordinates and in main axes
|
|
248
|
+
|
|
249
|
+
eval_final_mean : True
|
|
250
|
+
Evaluate the final mean, which is a favorite return candidate
|
|
251
|
+
|
|
252
|
+
fixed_variables : None
|
|
253
|
+
Dictionary with index-value pairs like dict(0=1.1, 2=0.1) that are not optimized
|
|
254
|
+
|
|
255
|
+
ftarget : -inf
|
|
256
|
+
Target function value, minimization
|
|
257
|
+
|
|
258
|
+
integer_variables : []
|
|
259
|
+
Index list, invokes basic integer handling: prevent std dev to become too small in the given variables
|
|
260
|
+
|
|
261
|
+
maxfevals : inf
|
|
262
|
+
Maximum number of function evaluations
|
|
263
|
+
|
|
264
|
+
maxiter : 100 + 150 * (N+3)**2 // popsize**0.5
|
|
265
|
+
Maximum number of iterations
|
|
266
|
+
|
|
267
|
+
mean_shift_line_samples : False
|
|
268
|
+
Sample two new solutions colinear to previous mean shift
|
|
269
|
+
|
|
270
|
+
mindx : 0
|
|
271
|
+
Minimal std in any arbitrary direction, cave interference with tol
|
|
272
|
+
|
|
273
|
+
minstd : 0
|
|
274
|
+
Minimal std (scalar or vector) in any coordinate direction, cave interference with tol
|
|
275
|
+
|
|
276
|
+
maxstd : inf
|
|
277
|
+
Maximal std in any coordinate direction
|
|
278
|
+
|
|
279
|
+
pc_line_samples : False
|
|
280
|
+
One line sample along the evolution path pc
|
|
281
|
+
|
|
282
|
+
popsize : 4+int(3*np.log(N))
|
|
283
|
+
Population size, AKA lambda, number of new solution per iteration
|
|
284
|
+
|
|
285
|
+
randn : np.random.randn
|
|
286
|
+
Randn(lam, N) must return an np.array of shape (lam, N), see also cma.utilities.math.randhss
|
|
287
|
+
|
|
288
|
+
signals_filename : None
|
|
289
|
+
cma_signals.in # read versatile options from this file which contains a single options dict,
|
|
290
|
+
e.g. ``dict("timeout"=0)`` to stop, string-values are evaluated, e.g. "np.inf" is valid
|
|
291
|
+
|
|
292
|
+
termination_callback : None
|
|
293
|
+
A function returning True for termination, called in `stop` with `self` as argument, could be abused
|
|
294
|
+
for side effects
|
|
295
|
+
|
|
296
|
+
timeout : inf
|
|
297
|
+
Stop if timeout seconds are exceeded, the string "2.5 * 60**2" evaluates to 2 hours and 30 minutes
|
|
298
|
+
|
|
299
|
+
tolconditioncov : 1e14
|
|
300
|
+
Stop if the condition of the covariance matrix is above `tolconditioncov`
|
|
301
|
+
|
|
302
|
+
tolfacupx : 1e3
|
|
303
|
+
Termination when step-size increases by tolfacupx (diverges). That is, the initial step-size was chosen
|
|
304
|
+
far too small and better solutions were found far away from the initial solution x0
|
|
305
|
+
|
|
306
|
+
tolupsigma : 1e20
|
|
307
|
+
Sigma/sigma0 > tolupsigma * max(eivenvals(C)**0.5) indicates "creeping behavior" with usually minor
|
|
308
|
+
improvements
|
|
309
|
+
|
|
310
|
+
tolfun : 1e-11
|
|
311
|
+
Termination criterion: tolerance in function value, quite useful
|
|
312
|
+
|
|
313
|
+
tolfunhist : 1e-12
|
|
314
|
+
Termination criterion: tolerance in function value history
|
|
315
|
+
|
|
316
|
+
tolstagnation : int(100 + 100 * N**1.5 / popsize)
|
|
317
|
+
Termination if no improvement over tolstagnation iterations
|
|
318
|
+
|
|
319
|
+
tolx : 1e-11
|
|
320
|
+
Termination criterion: tolerance in x-changes
|
|
321
|
+
|
|
322
|
+
typical_x : None
|
|
323
|
+
Used with scaling_of_variables',
|
|
324
|
+
|
|
325
|
+
updatecovwait : None
|
|
326
|
+
Number of iterations without distribution update, name is subject to future changes
|
|
327
|
+
|
|
328
|
+
cmaes_verbose : 3
|
|
329
|
+
Verbosity e.g. of initial/final message, -1 is very quiet, -9 maximally quiet, may not be fully implemented
|
|
330
|
+
|
|
331
|
+
verb_append : 0
|
|
332
|
+
Initial evaluation counter, if append, do not overwrite output files
|
|
333
|
+
|
|
334
|
+
verb_disp : 100
|
|
335
|
+
Verbosity: display console output every verb_disp iteration
|
|
336
|
+
|
|
337
|
+
verb_filenameprefix : str
|
|
338
|
+
CMADataLogger.default_prefix + Output path and filenames prefix
|
|
339
|
+
|
|
340
|
+
verb_log : 1
|
|
341
|
+
Verbosity: write data to files every verb_log iteration, writing can be time critical on fast to
|
|
342
|
+
evaluate functions
|
|
343
|
+
|
|
344
|
+
verb_plot : 0
|
|
345
|
+
In fmin(): plot() is called every verb_plot iteration
|
|
346
|
+
|
|
347
|
+
verb_time : True
|
|
348
|
+
Output timings on console
|
|
349
|
+
|
|
350
|
+
vv : dict
|
|
351
|
+
Versatile set or dictionary for hacking purposes, value found in self.opts["vv"]
|
|
352
|
+
|
|
353
|
+
kwargs : dict
|
|
354
|
+
A dictionary with additional options passed to the constructor
|
|
355
|
+
of class ``CMAEvolutionStrategy``, see ``cma.CMAOptions`` ()
|
|
356
|
+
for a list of available options.
|
|
357
|
+
|
|
358
|
+
"""
|
|
359
|
+
if pop_size is not None:
|
|
360
|
+
parallelize = True
|
|
361
|
+
kwargs["popsize"] = pop_size
|
|
362
|
+
|
|
363
|
+
super().__init__(x0=x0, output=output, **kwargs)
|
|
364
|
+
|
|
365
|
+
self.termination = NoTermination()
|
|
366
|
+
|
|
367
|
+
self.es = None
|
|
368
|
+
self.cma = None
|
|
369
|
+
|
|
370
|
+
self.normalize = normalize
|
|
371
|
+
self.norm = None
|
|
372
|
+
|
|
373
|
+
self.sigma = sigma
|
|
374
|
+
self.restarts = restarts
|
|
375
|
+
self.restart_from_best = restart_from_best
|
|
376
|
+
self.incpopsize = incpopsize
|
|
377
|
+
self.eval_initial_x = eval_initial_x
|
|
378
|
+
self.noise_handler = noise_handler
|
|
379
|
+
self.noise_change_sigma_exponent = noise_change_sigma_exponent
|
|
380
|
+
self.noise_kappa_exponent = noise_kappa_exponent
|
|
381
|
+
self.bipop = bipop
|
|
382
|
+
|
|
383
|
+
self.options = dict(
|
|
384
|
+
verbose=cmaes_verbose,
|
|
385
|
+
verb_log=verb_log,
|
|
386
|
+
maxfevals=maxfevals,
|
|
387
|
+
tolfun=tolfun,
|
|
388
|
+
tolx=tolx,
|
|
389
|
+
**kwargs
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
self.send_array_to_yield = True
|
|
393
|
+
self.parallelize = parallelize
|
|
394
|
+
self.al = None
|
|
395
|
+
|
|
396
|
+
def _setup(self, problem, **kwargs):
|
|
397
|
+
|
|
398
|
+
xl, xu = problem.bounds()
|
|
399
|
+
if self.normalize:
|
|
400
|
+
self.norm, self.options['bounds'] = bounds_if_normalize(xl, xu)
|
|
401
|
+
else:
|
|
402
|
+
self.norm = NoNormalization()
|
|
403
|
+
self.options['bounds'] = [xl, xu]
|
|
404
|
+
|
|
405
|
+
self.options['seed'] = kwargs.get('seed', self.seed)
|
|
406
|
+
|
|
407
|
+
if isinstance(self.termination, MaximumGenerationTermination):
|
|
408
|
+
self.options['maxiter'] = self.termination.n_max_gen
|
|
409
|
+
elif isinstance(self.termination, MaximumFunctionCallTermination):
|
|
410
|
+
self.options['maxfevals'] = self.termination.n_max_evals
|
|
411
|
+
|
|
412
|
+
def _initialize_advance(self, **kwargs):
|
|
413
|
+
super()._initialize_advance(**kwargs)
|
|
414
|
+
|
|
415
|
+
kwargs = dict(
|
|
416
|
+
options=self.options,
|
|
417
|
+
parallel_objective=self.parallelize,
|
|
418
|
+
restarts=self.restarts,
|
|
419
|
+
restart_from_best=self.restart_from_best,
|
|
420
|
+
incpopsize=self.incpopsize,
|
|
421
|
+
eval_initial_x=self.eval_initial_x,
|
|
422
|
+
noise_handler=self.noise_handler,
|
|
423
|
+
noise_change_sigma_exponent=self.noise_change_sigma_exponent,
|
|
424
|
+
noise_kappa_exponent=self.noise_kappa_exponent,
|
|
425
|
+
bipop=self.bipop)
|
|
426
|
+
|
|
427
|
+
x0 = self.norm.forward(self.x0.X)
|
|
428
|
+
self.es = my_fmin(x0, self.sigma, **kwargs)
|
|
429
|
+
|
|
430
|
+
# do this to allow the printout in the first generation
|
|
431
|
+
self.next_X = next(self.es)
|
|
432
|
+
|
|
433
|
+
def _infill(self):
|
|
434
|
+
|
|
435
|
+
X = np.array(self.next_X)
|
|
436
|
+
self.send_array_to_yield = X.ndim > 1
|
|
437
|
+
X = np.atleast_2d(X)
|
|
438
|
+
|
|
439
|
+
# evaluate the population
|
|
440
|
+
self.pop = Population.new("X", self.norm.backward(X))
|
|
441
|
+
|
|
442
|
+
return self.pop
|
|
443
|
+
|
|
444
|
+
def _advance(self, infills=None, **kwargs):
|
|
445
|
+
|
|
446
|
+
if infills is None:
|
|
447
|
+
self.termination.force_termination = True
|
|
448
|
+
|
|
449
|
+
else:
|
|
450
|
+
|
|
451
|
+
# set infeasible individual's objective values to np.nan - then CMAES can handle it
|
|
452
|
+
for ind in infills:
|
|
453
|
+
if not ind.feas:
|
|
454
|
+
ind.F[:] = np.inf
|
|
455
|
+
|
|
456
|
+
F = infills.get("f").tolist()
|
|
457
|
+
if not self.send_array_to_yield:
|
|
458
|
+
F = F[0]
|
|
459
|
+
|
|
460
|
+
try:
|
|
461
|
+
self.next_X = self.es.send(F)
|
|
462
|
+
except:
|
|
463
|
+
self.next_X = None
|
|
464
|
+
|
|
465
|
+
if self.next_X is None:
|
|
466
|
+
self.termination.force_termination = True
|
|
467
|
+
|
|
468
|
+
def _set_optimum(self):
|
|
469
|
+
pop = self.pop if self.opt is None else Population.merge(self.opt, self.pop)
|
|
470
|
+
self.opt = filter_optimum(pop, least_infeasible=True)
|
|
471
|
+
|
|
472
|
+
def __getstate__(self):
|
|
473
|
+
state = self.__dict__.copy()
|
|
474
|
+
state.pop("es", None)
|
|
475
|
+
return state
|
|
476
|
+
|
|
477
|
+
def __setstate__(self, state):
|
|
478
|
+
self.__dict__.update(state)
|
|
479
|
+
self.ers = None
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
class SimpleCMAES(LocalSearch):
|
|
483
|
+
|
|
484
|
+
def __init__(self, sigma=0.1, opts=None, normalize=True, **kwargs):
|
|
485
|
+
super().__init__(**kwargs)
|
|
486
|
+
self.termination = NoTermination()
|
|
487
|
+
self.es = None
|
|
488
|
+
self.sigma = sigma
|
|
489
|
+
self.normalize = normalize
|
|
490
|
+
self.norm = None
|
|
491
|
+
|
|
492
|
+
DEFAULTS = {"verb_disp": 0}
|
|
493
|
+
|
|
494
|
+
if opts is None:
|
|
495
|
+
opts = {}
|
|
496
|
+
|
|
497
|
+
for k, v in DEFAULTS.items():
|
|
498
|
+
if k not in kwargs:
|
|
499
|
+
opts[k] = v
|
|
500
|
+
|
|
501
|
+
self.opts = opts
|
|
502
|
+
|
|
503
|
+
def _setup(self, problem, **kwargs):
|
|
504
|
+
xl, xu = problem.bounds()
|
|
505
|
+
if self.normalize:
|
|
506
|
+
self.norm, self.opts['bounds'] = bounds_if_normalize(xl, xu)
|
|
507
|
+
else:
|
|
508
|
+
self.norm = NoNormalization()
|
|
509
|
+
self.opts['bounds'] = [xl, xu]
|
|
510
|
+
self.opts['seed'] = self.seed
|
|
511
|
+
|
|
512
|
+
def _initialize_advance(self, infills=None, **kwargs):
|
|
513
|
+
super()._initialize_advance(infills, **kwargs)
|
|
514
|
+
x = self.norm.forward(self.x0.X)
|
|
515
|
+
self.es = cma.CMAEvolutionStrategy(x, self.sigma, inopts=self.opts)
|
|
516
|
+
|
|
517
|
+
def _infill(self):
|
|
518
|
+
X = self.norm.backward(np.array(self.es.ask()))
|
|
519
|
+
return Population.new("X", X)
|
|
520
|
+
|
|
521
|
+
def _advance(self, infills=None, **kwargs):
|
|
522
|
+
X, F = infills.get("X", "F")
|
|
523
|
+
X = self.norm.forward(X)
|
|
524
|
+
|
|
525
|
+
self.es.tell(X, F[:, 0])
|
|
526
|
+
self.pop = infills
|
|
527
|
+
|
|
528
|
+
if self.es.stop():
|
|
529
|
+
self.termination.force_termination = True
|
|
530
|
+
|
|
531
|
+
def _set_optimum(self):
|
|
532
|
+
pop = self.pop if self.opt is None else Population.merge(self.opt, self.pop)
|
|
533
|
+
self.opt = filter_optimum(pop, least_infeasible=True)
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
class BIPOPCMAES(CMAES):
|
|
537
|
+
|
|
538
|
+
def __init__(self, restarts=4, **kwargs):
|
|
539
|
+
super().__init__(restarts=restarts, bipop=True, **kwargs)
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
def bounds_if_normalize(xl, xu):
|
|
543
|
+
norm = ZeroToOneNormalization(xl=xl, xu=xu)
|
|
544
|
+
|
|
545
|
+
_xl, _xu = np.zeros_like(xl), np.ones_like(xu)
|
|
546
|
+
if xl is not None:
|
|
547
|
+
_xl[np.isnan(xl)] = np.nan
|
|
548
|
+
if xu is not None:
|
|
549
|
+
_xu[np.isnan(xu)] = np.nan
|
|
550
|
+
|
|
551
|
+
return norm, [_xl, _xu]
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
parse_doc_string(CMAES.__init__)
|