pymoo 0.6.1.5.dev0__cp39-cp39-musllinux_1_2_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-39-x86_64-linux-gnu.so +0 -0
- pymoo/cython/calc_perpendicular_distance.pyx +67 -0
- pymoo/cython/decomposition.cpython-39-x86_64-linux-gnu.so +0 -0
- pymoo/cython/decomposition.pyx +165 -0
- pymoo/cython/hv.cpython-39-x86_64-linux-gnu.so +0 -0
- pymoo/cython/hv.pyx +18 -0
- pymoo/cython/info.cpython-39-x86_64-linux-gnu.so +0 -0
- pymoo/cython/info.pyx +5 -0
- pymoo/cython/mnn.cpython-39-x86_64-linux-gnu.so +0 -0
- pymoo/cython/mnn.pyx +273 -0
- pymoo/cython/non_dominated_sorting.cpython-39-x86_64-linux-gnu.so +0 -0
- pymoo/cython/non_dominated_sorting.pyx +645 -0
- pymoo/cython/pruning_cd.cpython-39-x86_64-linux-gnu.so +0 -0
- pymoo/cython/pruning_cd.pyx +197 -0
- pymoo/cython/stochastic_ranking.cpython-39-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 +330 -0
- pymoo-0.6.1.5.dev0.dist-info/WHEEL +5 -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
- pymoo.libs/libgcc_s-2298274a.so.1 +0 -0
- pymoo.libs/libstdc++-08d5c7eb.so.6.0.33 +0 -0
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from pymoo.core.problem import Problem
|
|
4
|
+
from pymoo.problems.many import generic_sphere, get_ref_dirs
|
|
5
|
+
from pymoo.util.function_loader import load_function
|
|
6
|
+
from pymoo.util.misc import powerset
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class WFG(Problem):
|
|
10
|
+
|
|
11
|
+
def __init__(self, n_var, n_obj, k=None, l=None, **kwargs):
|
|
12
|
+
super().__init__(n_var=n_var,
|
|
13
|
+
n_obj=n_obj,
|
|
14
|
+
xl=0.0,
|
|
15
|
+
xu=2 * np.arange(1, n_var + 1).astype(float),
|
|
16
|
+
vtype=float,
|
|
17
|
+
**kwargs)
|
|
18
|
+
|
|
19
|
+
self.S = np.arange(2, 2 * self.n_obj + 1, 2).astype(float)
|
|
20
|
+
self.A = np.ones(self.n_obj - 1)
|
|
21
|
+
|
|
22
|
+
if k:
|
|
23
|
+
self.k = k
|
|
24
|
+
else:
|
|
25
|
+
if n_obj == 2:
|
|
26
|
+
self.k = 4
|
|
27
|
+
else:
|
|
28
|
+
self.k = 2 * (n_obj - 1)
|
|
29
|
+
|
|
30
|
+
if l:
|
|
31
|
+
self.l = l
|
|
32
|
+
else:
|
|
33
|
+
self.l = n_var - self.k
|
|
34
|
+
|
|
35
|
+
self.validate(self.l, self.k, self.n_obj)
|
|
36
|
+
|
|
37
|
+
def validate(self, l, k, n_obj):
|
|
38
|
+
if n_obj < 2:
|
|
39
|
+
raise ValueError('WFG problems must have two or more objectives.')
|
|
40
|
+
if not k % (n_obj - 1) == 0:
|
|
41
|
+
raise ValueError('Position parameter (k) must be divisible by number of objectives minus one.')
|
|
42
|
+
if k < 4:
|
|
43
|
+
raise ValueError('Position parameter (k) must be greater or equal than 4.')
|
|
44
|
+
if (k + l) < n_obj:
|
|
45
|
+
raise ValueError('Sum of distance and position parameters must be greater than num. of objs. (k + l >= M).')
|
|
46
|
+
|
|
47
|
+
def _post(self, t, a):
|
|
48
|
+
x = []
|
|
49
|
+
for i in range(t.shape[1] - 1):
|
|
50
|
+
x.append(np.maximum(t[:, -1], a[i]) * (t[:, i] - 0.5) + 0.5)
|
|
51
|
+
x.append(t[:, -1])
|
|
52
|
+
return np.column_stack(x)
|
|
53
|
+
|
|
54
|
+
def _calculate(self, x, s, h):
|
|
55
|
+
return x[:, -1][:, None] + s * np.column_stack(h)
|
|
56
|
+
|
|
57
|
+
def _rand_optimal_position(self, n):
|
|
58
|
+
return np.random.random((n, self.k))
|
|
59
|
+
|
|
60
|
+
def _positional_to_optimal(self, K):
|
|
61
|
+
suffix = np.full((len(K), self.l), 0.35)
|
|
62
|
+
X = np.column_stack([K, suffix])
|
|
63
|
+
return X * self.xu
|
|
64
|
+
|
|
65
|
+
def _calc_pareto_set_extremes(self):
|
|
66
|
+
ps = np.ones((2 ** self.k, self.k))
|
|
67
|
+
for i, s in enumerate(powerset(np.arange(self.k))):
|
|
68
|
+
ps[i, s] = 0
|
|
69
|
+
return self._positional_to_optimal(ps)
|
|
70
|
+
|
|
71
|
+
def _calc_pareto_set_interior(self, n_points):
|
|
72
|
+
return self._positional_to_optimal(self._rand_optimal_position(n_points))
|
|
73
|
+
|
|
74
|
+
def _calc_pareto_set(self, n_points=500, *args, **kwargs):
|
|
75
|
+
extremes = self._calc_pareto_set_extremes()
|
|
76
|
+
interior = self._calc_pareto_set_interior(n_points - len(extremes))
|
|
77
|
+
return np.row_stack([extremes, interior])
|
|
78
|
+
|
|
79
|
+
def _calc_pareto_front(self, ref_dirs=None, n_iterations=200, points_each_iteration=200, *args, **kwargs):
|
|
80
|
+
pf = self.evaluate(self._calc_pareto_set_extremes(), return_values_of=["F"])
|
|
81
|
+
|
|
82
|
+
if ref_dirs is None:
|
|
83
|
+
ref_dirs = get_ref_dirs(self.n_obj)
|
|
84
|
+
|
|
85
|
+
for k in range(n_iterations):
|
|
86
|
+
_pf = self.evaluate(self._calc_pareto_set_interior(points_each_iteration), return_values_of=["F"])
|
|
87
|
+
pf = np.row_stack([pf, _pf])
|
|
88
|
+
|
|
89
|
+
ideal, nadir = pf.min(axis=0), pf.max(axis=0)
|
|
90
|
+
|
|
91
|
+
N = (pf - ideal) / (nadir-ideal)
|
|
92
|
+
dist_matrix = load_function("calc_perpendicular_distance")(N, ref_dirs)
|
|
93
|
+
|
|
94
|
+
closest = np.argmin(dist_matrix, axis=0)
|
|
95
|
+
pf = pf[closest]
|
|
96
|
+
|
|
97
|
+
pf = pf[np.lexsort(pf.T[::-1])]
|
|
98
|
+
return pf
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class WFG1(WFG):
|
|
102
|
+
|
|
103
|
+
@staticmethod
|
|
104
|
+
def t1(x, n, k):
|
|
105
|
+
x[:, k:n] = _transformation_shift_linear(x[:, k:n], 0.35)
|
|
106
|
+
return x
|
|
107
|
+
|
|
108
|
+
@staticmethod
|
|
109
|
+
def t2(x, n, k):
|
|
110
|
+
x[:, k:n] = _transformation_bias_flat(x[:, k:n], 0.8, 0.75, 0.85)
|
|
111
|
+
return x
|
|
112
|
+
|
|
113
|
+
@staticmethod
|
|
114
|
+
def t3(x, n):
|
|
115
|
+
x[:, :n] = _transformation_bias_poly(x[:, :n], 0.02)
|
|
116
|
+
return x
|
|
117
|
+
|
|
118
|
+
@staticmethod
|
|
119
|
+
def t4(x, m, n, k):
|
|
120
|
+
w = np.arange(2, 2 * n + 1, 2)
|
|
121
|
+
gap = k // (m - 1)
|
|
122
|
+
t = []
|
|
123
|
+
for m in range(1, m):
|
|
124
|
+
_y = x[:, (m - 1) * gap: (m * gap)]
|
|
125
|
+
_w = w[(m - 1) * gap: (m * gap)]
|
|
126
|
+
t.append(_reduction_weighted_sum(_y, _w))
|
|
127
|
+
t.append(_reduction_weighted_sum(x[:, k:n], w[k:n]))
|
|
128
|
+
return np.column_stack(t)
|
|
129
|
+
|
|
130
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
131
|
+
y = x / self.xu
|
|
132
|
+
y = WFG1.t1(y, self.n_var, self.k)
|
|
133
|
+
y = WFG1.t2(y, self.n_var, self.k)
|
|
134
|
+
y = WFG1.t3(y, self.n_var)
|
|
135
|
+
y = WFG1.t4(y, self.n_obj, self.n_var, self.k)
|
|
136
|
+
|
|
137
|
+
y = self._post(y, self.A)
|
|
138
|
+
|
|
139
|
+
h = [_shape_convex(y[:, :-1], m + 1) for m in range(self.n_obj - 1)]
|
|
140
|
+
h.append(_shape_mixed(y[:, 0], alpha=1.0, A=5.0))
|
|
141
|
+
|
|
142
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
143
|
+
|
|
144
|
+
def _rand_optimal_position(self, n):
|
|
145
|
+
return np.power(np.random.random((n, self.k)), 50.0)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class WFG2(WFG):
|
|
149
|
+
|
|
150
|
+
def validate(self, l, k, n_obj):
|
|
151
|
+
super().validate(l, k, n_obj)
|
|
152
|
+
validate_wfg2_wfg3(l)
|
|
153
|
+
|
|
154
|
+
@staticmethod
|
|
155
|
+
def t2(x, n, k):
|
|
156
|
+
y = [x[:, i] for i in range(k)]
|
|
157
|
+
|
|
158
|
+
l = n - k
|
|
159
|
+
ind_non_sep = k + l // 2
|
|
160
|
+
|
|
161
|
+
i = k + 1
|
|
162
|
+
while i <= ind_non_sep:
|
|
163
|
+
head = k + 2 * (i - k) - 2
|
|
164
|
+
tail = k + 2 * (i - k)
|
|
165
|
+
y.append(_reduction_non_sep(x[:, head:tail], 2))
|
|
166
|
+
i += 1
|
|
167
|
+
|
|
168
|
+
return np.column_stack(y)
|
|
169
|
+
|
|
170
|
+
@staticmethod
|
|
171
|
+
def t3(x, m, n, k):
|
|
172
|
+
ind_r_sum = k + (n - k) // 2
|
|
173
|
+
gap = k // (m - 1)
|
|
174
|
+
|
|
175
|
+
t = [_reduction_weighted_sum_uniform(x[:, (m - 1) * gap: (m * gap)]) for m in range(1, m)]
|
|
176
|
+
t.append(_reduction_weighted_sum_uniform(x[:, k:ind_r_sum]))
|
|
177
|
+
|
|
178
|
+
return np.column_stack(t)
|
|
179
|
+
|
|
180
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
181
|
+
y = x / self.xu
|
|
182
|
+
y = WFG1.t1(y, self.n_var, self.k)
|
|
183
|
+
y = WFG2.t2(y, self.n_var, self.k)
|
|
184
|
+
y = WFG2.t3(y, self.n_obj, self.n_var, self.k)
|
|
185
|
+
y = self._post(y, self.A)
|
|
186
|
+
|
|
187
|
+
h = [_shape_convex(y[:, :-1], m + 1) for m in range(self.n_obj - 1)]
|
|
188
|
+
h.append(_shape_disconnected(y[:, 0], alpha=1.0, beta=1.0, A=5.0))
|
|
189
|
+
|
|
190
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class WFG3(WFG):
|
|
194
|
+
|
|
195
|
+
def __init__(self, n_var, n_obj, k=None, **kwargs):
|
|
196
|
+
super().__init__(n_var, n_obj, k=k, **kwargs)
|
|
197
|
+
self.A[1:] = 0
|
|
198
|
+
|
|
199
|
+
def validate(self, l, k, n_obj):
|
|
200
|
+
super().validate(l, k, n_obj)
|
|
201
|
+
validate_wfg2_wfg3(l)
|
|
202
|
+
|
|
203
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
204
|
+
y = x / self.xu
|
|
205
|
+
y = WFG1.t1(y, self.n_var, self.k)
|
|
206
|
+
y = WFG2.t2(y, self.n_var, self.k)
|
|
207
|
+
y = WFG2.t3(y, self.n_obj, self.n_var, self.k)
|
|
208
|
+
y = self._post(y, self.A)
|
|
209
|
+
|
|
210
|
+
h = [_shape_linear(y[:, :-1], m + 1) for m in range(self.n_obj)]
|
|
211
|
+
|
|
212
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
213
|
+
|
|
214
|
+
# def _calc_pareto_front(self, ref_dirs=None):
|
|
215
|
+
# if ref_dirs is None:
|
|
216
|
+
# ref_dirs = get_ref_dirs(self.n_obj)
|
|
217
|
+
# return ref_dirs * self.S
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class WFG4(WFG):
|
|
221
|
+
|
|
222
|
+
@staticmethod
|
|
223
|
+
def t1(x):
|
|
224
|
+
return _transformation_shift_multi_modal(x, 30.0, 10.0, 0.35)
|
|
225
|
+
|
|
226
|
+
@staticmethod
|
|
227
|
+
def t2(x, m, k):
|
|
228
|
+
gap = k // (m - 1)
|
|
229
|
+
t = [_reduction_weighted_sum_uniform(x[:, (m - 1) * gap: (m * gap)]) for m in range(1, m)]
|
|
230
|
+
t.append(_reduction_weighted_sum_uniform(x[:, k:]))
|
|
231
|
+
return np.column_stack(t)
|
|
232
|
+
|
|
233
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
234
|
+
y = x / self.xu
|
|
235
|
+
y = WFG4.t1(y)
|
|
236
|
+
y = WFG4.t2(y, self.n_obj, self.k)
|
|
237
|
+
y = self._post(y, self.A)
|
|
238
|
+
|
|
239
|
+
h = [_shape_concave(y[:, :-1], m + 1) for m in range(self.n_obj)]
|
|
240
|
+
|
|
241
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
242
|
+
|
|
243
|
+
# def _calc_pareto_front(self, ref_dirs=None):
|
|
244
|
+
# if ref_dirs is None:
|
|
245
|
+
# ref_dirs = get_ref_dirs(self.n_obj)
|
|
246
|
+
# return generic_sphere(ref_dirs) * self.S
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class WFG5(WFG):
|
|
250
|
+
|
|
251
|
+
@staticmethod
|
|
252
|
+
def t1(x):
|
|
253
|
+
return _transformation_param_deceptive(x, A=0.35, B=0.001, C=0.05)
|
|
254
|
+
|
|
255
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
256
|
+
y = x / self.xu
|
|
257
|
+
y = WFG5.t1(y)
|
|
258
|
+
y = WFG4.t2(y, self.n_obj, self.k)
|
|
259
|
+
y = self._post(y, self.A)
|
|
260
|
+
|
|
261
|
+
h = [_shape_concave(y[:, :-1], m + 1) for m in range(self.n_obj)]
|
|
262
|
+
|
|
263
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
264
|
+
|
|
265
|
+
# def _calc_pareto_front(self, ref_dirs=None):
|
|
266
|
+
# if ref_dirs is None:
|
|
267
|
+
# ref_dirs = get_ref_dirs(self.n_obj)
|
|
268
|
+
# return generic_sphere(ref_dirs) * self.S
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class WFG6(WFG):
|
|
272
|
+
|
|
273
|
+
@staticmethod
|
|
274
|
+
def t2(x, m, n, k):
|
|
275
|
+
gap = k // (m - 1)
|
|
276
|
+
t = [_reduction_non_sep(x[:, (m - 1) * gap: (m * gap)], gap) for m in range(1, m)]
|
|
277
|
+
t.append(_reduction_non_sep(x[:, k:], n - k))
|
|
278
|
+
return np.column_stack(t)
|
|
279
|
+
|
|
280
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
281
|
+
y = x / self.xu
|
|
282
|
+
y = WFG1.t1(y, self.n_var, self.k)
|
|
283
|
+
y = WFG6.t2(y, self.n_obj, self.n_var, self.k)
|
|
284
|
+
y = self._post(y, self.A)
|
|
285
|
+
|
|
286
|
+
h = [_shape_concave(y[:, :-1], m + 1) for m in range(self.n_obj)]
|
|
287
|
+
|
|
288
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
289
|
+
|
|
290
|
+
# def _calc_pareto_front(self, ref_dirs=None):
|
|
291
|
+
# if ref_dirs is None:
|
|
292
|
+
# ref_dirs = get_ref_dirs(self.n_obj)
|
|
293
|
+
# return generic_sphere(ref_dirs) * self.S
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
class WFG7(WFG):
|
|
297
|
+
|
|
298
|
+
@staticmethod
|
|
299
|
+
def t1(x, k):
|
|
300
|
+
for i in range(k):
|
|
301
|
+
aux = _reduction_weighted_sum_uniform(x[:, i + 1:])
|
|
302
|
+
x[:, i] = _transformation_param_dependent(x[:, i], aux)
|
|
303
|
+
return x
|
|
304
|
+
|
|
305
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
306
|
+
y = x / self.xu
|
|
307
|
+
y = WFG7.t1(y, self.k)
|
|
308
|
+
y = WFG1.t1(y, self.n_var, self.k)
|
|
309
|
+
y = WFG4.t2(y, self.n_obj, self.k)
|
|
310
|
+
y = self._post(y, self.A)
|
|
311
|
+
|
|
312
|
+
h = [_shape_concave(y[:, :-1], m + 1) for m in range(self.n_obj)]
|
|
313
|
+
|
|
314
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
315
|
+
|
|
316
|
+
# def _calc_pareto_front(self, ref_dirs=None):
|
|
317
|
+
# if ref_dirs is None:
|
|
318
|
+
# ref_dirs = get_ref_dirs(self.n_obj)
|
|
319
|
+
# return generic_sphere(ref_dirs) * self.S
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class WFG8(WFG):
|
|
323
|
+
|
|
324
|
+
@staticmethod
|
|
325
|
+
def t1(x, n, k):
|
|
326
|
+
ret = []
|
|
327
|
+
for i in range(k, n):
|
|
328
|
+
aux = _reduction_weighted_sum_uniform(x[:, :i])
|
|
329
|
+
ret.append(_transformation_param_dependent(x[:, i], aux, A=0.98 / 49.98, B=0.02, C=50.0))
|
|
330
|
+
return np.column_stack(ret)
|
|
331
|
+
|
|
332
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
333
|
+
y = x / self.xu
|
|
334
|
+
y[:, self.k:self.n_var] = WFG8.t1(y, self.n_var, self.k)
|
|
335
|
+
y = WFG1.t1(y, self.n_var, self.k)
|
|
336
|
+
y = WFG4.t2(y, self.n_obj, self.k)
|
|
337
|
+
y = self._post(y, self.A)
|
|
338
|
+
|
|
339
|
+
h = [_shape_concave(y[:, :-1], m + 1) for m in range(self.n_obj)]
|
|
340
|
+
|
|
341
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
342
|
+
|
|
343
|
+
def _positional_to_optimal(self, K):
|
|
344
|
+
k, l = self.k, self.l
|
|
345
|
+
|
|
346
|
+
for i in range(k, k + l):
|
|
347
|
+
u = K.sum(axis=1) / K.shape[1]
|
|
348
|
+
tmp1 = np.abs(np.floor(0.5 - u) + 0.98 / 49.98)
|
|
349
|
+
tmp2 = 0.02 + 49.98 * (0.98 / 49.98 - (1.0 - 2.0 * u) * tmp1)
|
|
350
|
+
suffix = np.power(0.35, np.power(tmp2, -1.0))
|
|
351
|
+
|
|
352
|
+
K = np.column_stack([K, suffix[:, None]])
|
|
353
|
+
|
|
354
|
+
ret = K * (2 * (np.arange(self.n_var) + 1))
|
|
355
|
+
return ret
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
class WFG9(WFG):
|
|
359
|
+
|
|
360
|
+
@staticmethod
|
|
361
|
+
def t1(x, n):
|
|
362
|
+
ret = []
|
|
363
|
+
for i in range(0, n - 1):
|
|
364
|
+
aux = _reduction_weighted_sum_uniform(x[:, i + 1:])
|
|
365
|
+
ret.append(_transformation_param_dependent(x[:, i], aux))
|
|
366
|
+
return np.column_stack(ret)
|
|
367
|
+
|
|
368
|
+
@staticmethod
|
|
369
|
+
def t2(x, n, k):
|
|
370
|
+
a = [_transformation_shift_deceptive(x[:, i], 0.35, 0.001, 0.05) for i in range(k)]
|
|
371
|
+
b = [_transformation_shift_multi_modal(x[:, i], 30.0, 95.0, 0.35) for i in range(k, n)]
|
|
372
|
+
return np.column_stack(a + b)
|
|
373
|
+
|
|
374
|
+
@staticmethod
|
|
375
|
+
def t3(x, m, n, k):
|
|
376
|
+
gap = k // (m - 1)
|
|
377
|
+
t = [_reduction_non_sep(x[:, (m - 1) * gap: (m * gap)], gap) for m in range(1, m)]
|
|
378
|
+
t.append(_reduction_non_sep(x[:, k:], n - k))
|
|
379
|
+
return np.column_stack(t)
|
|
380
|
+
|
|
381
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
382
|
+
y = x / self.xu
|
|
383
|
+
y[:, :self.n_var - 1] = WFG9.t1(y, self.n_var)
|
|
384
|
+
y = WFG9.t2(y, self.n_var, self.k)
|
|
385
|
+
y = WFG9.t3(y, self.n_obj, self.n_var, self.k)
|
|
386
|
+
|
|
387
|
+
h = [_shape_concave(y[:, :-1], m + 1) for m in range(self.n_obj)]
|
|
388
|
+
|
|
389
|
+
out["F"] = self._calculate(y, self.S, h)
|
|
390
|
+
|
|
391
|
+
def _positional_to_optimal(self, K):
|
|
392
|
+
k, l = self.k, self.l
|
|
393
|
+
|
|
394
|
+
suffix = np.full((len(K), self.l), 0.0)
|
|
395
|
+
X = np.column_stack([K, suffix])
|
|
396
|
+
X[:, self.k + self.l - 1] = 0.35
|
|
397
|
+
|
|
398
|
+
for i in range(self.k + self.l - 2, self.k - 1, -1):
|
|
399
|
+
m = X[:, i + 1:k + l]
|
|
400
|
+
val = m.sum(axis=1) / m.shape[1]
|
|
401
|
+
X[:, i] = 0.35 ** ((0.02 + 1.96 * val) ** -1)
|
|
402
|
+
|
|
403
|
+
ret = X * (2 * (np.arange(self.n_var) + 1))
|
|
404
|
+
return ret
|
|
405
|
+
|
|
406
|
+
def _calc_pareto_front(self, ref_dirs=None):
|
|
407
|
+
if ref_dirs is None:
|
|
408
|
+
ref_dirs = get_ref_dirs(self.n_obj)
|
|
409
|
+
return generic_sphere(ref_dirs) * self.S
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
413
|
+
# TRANSFORMATIONS
|
|
414
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def _transformation_shift_linear(value, shift=0.35):
|
|
418
|
+
return correct_to_01(np.fabs(value - shift) / np.fabs(np.floor(shift - value) + shift))
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
def _transformation_shift_deceptive(y, A=0.35, B=0.005, C=0.05):
|
|
422
|
+
tmp1 = np.floor(y - A + B) * (1.0 - C + (A - B) / B) / (A - B)
|
|
423
|
+
tmp2 = np.floor(A + B - y) * (1.0 - C + (1.0 - A - B) / B) / (1.0 - A - B)
|
|
424
|
+
ret = 1.0 + (np.fabs(y - A) - B) * (tmp1 + tmp2 + 1.0 / B)
|
|
425
|
+
return correct_to_01(ret)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
def _transformation_shift_multi_modal(y, A, B, C):
|
|
429
|
+
tmp1 = np.fabs(y - C) / (2.0 * (np.floor(C - y) + C))
|
|
430
|
+
tmp2 = (4.0 * A + 2.0) * np.pi * (0.5 - tmp1)
|
|
431
|
+
ret = (1.0 + np.cos(tmp2) + 4.0 * B * np.power(tmp1, 2.0)) / (B + 2.0)
|
|
432
|
+
return correct_to_01(ret)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def _transformation_bias_flat(y, a, b, c):
|
|
436
|
+
ret = a + np.minimum(0, np.floor(y - b)) * (a * (b - y) / b) \
|
|
437
|
+
- np.minimum(0, np.floor(c - y)) * ((1.0 - a) * (y - c) / (1.0 - c))
|
|
438
|
+
return correct_to_01(ret)
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def _transformation_bias_poly(y, alpha):
|
|
442
|
+
return correct_to_01(y ** alpha)
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def _transformation_param_dependent(y, y_deg, A=0.98 / 49.98, B=0.02, C=50.0):
|
|
446
|
+
aux = A - (1.0 - 2.0 * y_deg) * np.fabs(np.floor(0.5 - y_deg) + A)
|
|
447
|
+
ret = np.power(y, B + (C - B) * aux)
|
|
448
|
+
return correct_to_01(ret)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def _transformation_param_deceptive(y, A=0.35, B=0.001, C=0.05):
|
|
452
|
+
tmp1 = np.floor(y - A + B) * (1.0 - C + (A - B) / B) / (A - B)
|
|
453
|
+
tmp2 = np.floor(A + B - y) * (1.0 - C + (1.0 - A - B) / B) / (1.0 - A - B)
|
|
454
|
+
ret = 1.0 + (np.fabs(y - A) - B) * (tmp1 + tmp2 + 1.0 / B)
|
|
455
|
+
return correct_to_01(ret)
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
459
|
+
# REDUCTION
|
|
460
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def _reduction_weighted_sum(y, w):
|
|
464
|
+
return correct_to_01(np.dot(y, w) / w.sum())
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
def _reduction_weighted_sum_uniform(y):
|
|
468
|
+
return correct_to_01(y.mean(axis=1))
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def _reduction_non_sep(y, A):
|
|
472
|
+
n, m = y.shape
|
|
473
|
+
val = np.ceil(A / 2.0)
|
|
474
|
+
|
|
475
|
+
num = np.zeros(n)
|
|
476
|
+
for j in range(m):
|
|
477
|
+
num += y[:, j]
|
|
478
|
+
for k in range(A - 1):
|
|
479
|
+
num += np.fabs(y[:, j] - y[:, (1 + j + k) % m])
|
|
480
|
+
|
|
481
|
+
denom = m * val * (1.0 + 2.0 * A - 2 * val) / A
|
|
482
|
+
|
|
483
|
+
return correct_to_01(num / denom)
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
487
|
+
# SHAPE
|
|
488
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
def _shape_concave(x, m):
|
|
492
|
+
M = x.shape[1]
|
|
493
|
+
if m == 1:
|
|
494
|
+
ret = np.prod(np.sin(0.5 * x[:, :M] * np.pi), axis=1)
|
|
495
|
+
elif 1 < m <= M:
|
|
496
|
+
ret = np.prod(np.sin(0.5 * x[:, :M - m + 1] * np.pi), axis=1)
|
|
497
|
+
ret *= np.cos(0.5 * x[:, M - m + 1] * np.pi)
|
|
498
|
+
else:
|
|
499
|
+
ret = np.cos(0.5 * x[:, 0] * np.pi)
|
|
500
|
+
return correct_to_01(ret)
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def _shape_convex(x, m):
|
|
504
|
+
M = x.shape[1]
|
|
505
|
+
if m == 1:
|
|
506
|
+
ret = np.prod(1.0 - np.cos(0.5 * x[:, :M] * np.pi), axis=1)
|
|
507
|
+
elif 1 < m <= M:
|
|
508
|
+
ret = np.prod(1.0 - np.cos(0.5 * x[:, :M - m + 1] * np.pi), axis=1)
|
|
509
|
+
ret *= 1.0 - np.sin(0.5 * x[:, M - m + 1] * np.pi)
|
|
510
|
+
else:
|
|
511
|
+
ret = 1.0 - np.sin(0.5 * x[:, 0] * np.pi)
|
|
512
|
+
return correct_to_01(ret)
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
def _shape_linear(x, m):
|
|
516
|
+
M = x.shape[1]
|
|
517
|
+
if m == 1:
|
|
518
|
+
ret = np.prod(x, axis=1)
|
|
519
|
+
elif 1 < m <= M:
|
|
520
|
+
ret = np.prod(x[:, :M - m + 1], axis=1)
|
|
521
|
+
ret *= 1.0 - x[:, M - m + 1]
|
|
522
|
+
else:
|
|
523
|
+
ret = 1.0 - x[:, 0]
|
|
524
|
+
return correct_to_01(ret)
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
def _shape_mixed(x, A=5.0, alpha=1.0):
|
|
528
|
+
aux = 2.0 * A * np.pi
|
|
529
|
+
ret = np.power(1.0 - x - (np.cos(aux * x + 0.5 * np.pi) / aux), alpha)
|
|
530
|
+
return correct_to_01(ret)
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
def _shape_disconnected(x, alpha=1.0, beta=1.0, A=5.0):
|
|
534
|
+
aux = np.cos(A * np.pi * x ** beta)
|
|
535
|
+
return correct_to_01(1.0 - x ** alpha * aux ** 2)
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
539
|
+
# UTIL
|
|
540
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
541
|
+
|
|
542
|
+
def validate_wfg2_wfg3(l):
|
|
543
|
+
if not l % 2 == 0:
|
|
544
|
+
raise ValueError('In WFG2/WFG3 the distance-related parameter (l) must be divisible by 2.')
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def correct_to_01(X, epsilon=1.0e-10):
|
|
548
|
+
X[np.logical_and(X < 0, X >= 0 - epsilon)] = 0
|
|
549
|
+
X[np.logical_and(X > 1, X <= 1 + epsilon)] = 1
|
|
550
|
+
return X
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pymoo.problems.multi.bnh import *
|
|
2
|
+
from pymoo.problems.multi.carside import *
|
|
3
|
+
from pymoo.problems.multi.ctp import *
|
|
4
|
+
from pymoo.problems.multi.dascmop import *
|
|
5
|
+
from pymoo.problems.multi.kursawe import *
|
|
6
|
+
from pymoo.problems.multi.modact import *
|
|
7
|
+
from pymoo.problems.multi.mw import *
|
|
8
|
+
from pymoo.problems.multi.osy import *
|
|
9
|
+
from pymoo.problems.multi.srn import *
|
|
10
|
+
from pymoo.problems.multi.tnk import *
|
|
11
|
+
from pymoo.problems.multi.truss2d import *
|
|
12
|
+
from pymoo.problems.multi.welded_beam import *
|
|
13
|
+
from pymoo.problems.multi.zdt import *
|
|
14
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import pymoo.gradient.toolbox as anp
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from pymoo.core.problem import Problem
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class BNH(Problem):
|
|
8
|
+
|
|
9
|
+
def __init__(self):
|
|
10
|
+
super().__init__(n_var=2, n_obj=2, n_ieq_constr=2, vtype=float)
|
|
11
|
+
self.xl = np.zeros(self.n_var)
|
|
12
|
+
self.xu = np.array([5.0, 3.0])
|
|
13
|
+
|
|
14
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
15
|
+
f1 = 4 * x[:, 0] ** 2 + 4 * x[:, 1] ** 2
|
|
16
|
+
f2 = (x[:, 0] - 5) ** 2 + (x[:, 1] - 5) ** 2
|
|
17
|
+
g1 = (1 / 25) * ((x[:, 0] - 5) ** 2 + x[:, 1] ** 2 - 25)
|
|
18
|
+
g2 = -1 / 7.7 * ((x[:, 0] - 8) ** 2 + (x[:, 1] + 3) ** 2 - 7.7)
|
|
19
|
+
|
|
20
|
+
out["F"] = anp.column_stack([f1, f2])
|
|
21
|
+
out["G"] = anp.column_stack([g1, g2])
|
|
22
|
+
|
|
23
|
+
def _calc_pareto_front(self, n_points=100):
|
|
24
|
+
x1 = np.linspace(0, 5, n_points)
|
|
25
|
+
x2 = np.linspace(0, 5, n_points)
|
|
26
|
+
x2[x1 >= 3] = 3
|
|
27
|
+
|
|
28
|
+
X = np.column_stack([x1, x2])
|
|
29
|
+
return self.evaluate(X, return_values_of=["F"])
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import pymoo.gradient.toolbox as anp
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from pymoo.core.problem import Problem
|
|
5
|
+
from pymoo.util.remote import Remote
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Carside(Problem):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
super().__init__(n_var=7, n_obj=3, n_ieq_constr=10, vtype=float)
|
|
11
|
+
self.xl = np.array([0.5, 0.45, 0.5, 0.5, 0.875, 0.4, 0.4])
|
|
12
|
+
self.xu = np.array([1.5, 1.35, 1.5, 1.5, 2.625, 1.2, 1.2])
|
|
13
|
+
|
|
14
|
+
def _evaluate(self, x, out, *args, **kwargs):
|
|
15
|
+
g1 = 1.16 - 0.3717 * x[:,1] * x[:,3] - 0.0092928 * x[:,2]
|
|
16
|
+
g2 = 0.261 - 0.0159 * x[:,0] * x[:,1] - 0.188 * x[:,0] * 0.345 - 0.019 * x[:,1] * x[:,6] + 0.0144 * x[:,2] * x[:,4] + 0.08045 * x[:,5] * 0.192
|
|
17
|
+
g3 = 0.214 + 0.00817 * x[:,4] - 0.131 * x[:,0] * 0.345 - 0.0704 * x[:,0] * 0.192 + 0.03099 * x[:,1] * x[:,5] - 0.018 * x[:,1] * x[:,6] + 0.0208 * x[:,2] * 0.345 + 0.121 * x[:,2] * 0.192 - 0.00364 * x[:,4] * x[:,5] - 0.018 * x[:,1] ** 2
|
|
18
|
+
g4 = 0.74 - 0.61 * x[:,1] - 0.031296 * x[:,2] - 0.166 * x[:,6] * 0.192 + 0.227 * x[:,1] ** 2
|
|
19
|
+
g5 = 28.98 + 3.818 * x[:,2] - 4.2 * x[:,0] * x[:,1] + 6.63 * x[:,5] * 0.192 - 7.77 * x[:,6] * 0.345
|
|
20
|
+
g6 = 33.86 + 2.95 * x[:,2] - 5.057 * x[:,0] * x[:,1] - 11 * x[:,1] * 0.345 - 9.98 * x[:,6] * 0.345 + 22 * 0.345 * 0.192
|
|
21
|
+
g7 = 46.36 - 9.9 * x[:,1] - 12.9 * x[:,0] * 0.345
|
|
22
|
+
g8 = 4.72 - 0.5 * x[:,3] - 0.19 * x[:,1] * x[:,2]
|
|
23
|
+
g9 = 10.58 - 0.674 * x[:,0] * x[:,1] - 1.95 * x[:,1] * 0.345
|
|
24
|
+
g10 = 16.45 - 0.489 * x[:,2] * x[:,6] - 0.843 * x[:,4] * x[:,5]
|
|
25
|
+
|
|
26
|
+
f1 = 1.98 + 4.9 * x[:,0] + 6.67 * x[:,1] + 6.98 * x[:,2] + 4.01 * x[:,3] + 1.78 * x[:,4] + 0.00001 * x[:,5] + 2.73 * x[:,6]
|
|
27
|
+
f2 = g8
|
|
28
|
+
f3 = (g9 + g10) / 2.0
|
|
29
|
+
|
|
30
|
+
g1 = - 1 + g1 / 1.0
|
|
31
|
+
g2 = -1 + g2 / 0.32
|
|
32
|
+
g3 = -1 + g3 / 0.32
|
|
33
|
+
g4 = -1 + g4 / 0.32
|
|
34
|
+
g5 = -1 + g5 / 32.0
|
|
35
|
+
g6 = -1 + g6 / 32.0
|
|
36
|
+
g7 = -1 + g7 / 32.0
|
|
37
|
+
g8 = -1 + g8 / 4.0
|
|
38
|
+
g9 = -1 + g9 / 9.9
|
|
39
|
+
g10 = -1 + g10 / 15.7
|
|
40
|
+
|
|
41
|
+
out["F"] = anp.column_stack([f1, f2, f3])
|
|
42
|
+
out["G"] = anp.column_stack([g1, g2, g3, g4, g5, g6, g7, g8, g9, g10])
|
|
43
|
+
|
|
44
|
+
def _calc_pareto_front(self, *args, **kwargs):
|
|
45
|
+
return Remote.get_instance().load("pymoo", "pf", "carside.pf")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|