pymoo 0.6.1.2__cp311-cp311-win_amd64.whl → 0.6.1.5.dev0__cp311-cp311-win_amd64.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.
Files changed (67) hide show
  1. pymoo/algorithms/moo/age.py +13 -7
  2. pymoo/algorithms/moo/age2.py +49 -19
  3. pymoo/algorithms/moo/ctaea.py +2 -2
  4. pymoo/algorithms/moo/kgb.py +9 -9
  5. pymoo/algorithms/moo/nsga2.py +0 -4
  6. pymoo/algorithms/moo/nsga3.py +2 -2
  7. pymoo/algorithms/moo/pinsga2.py +370 -0
  8. pymoo/algorithms/moo/rnsga3.py +2 -2
  9. pymoo/algorithms/soo/nonconvex/es.py +3 -2
  10. pymoo/config.py +1 -1
  11. pymoo/core/algorithm.py +1 -1
  12. pymoo/core/individual.py +8 -7
  13. pymoo/core/replacement.py +5 -5
  14. pymoo/core/survival.py +1 -1
  15. pymoo/core/variable.py +9 -9
  16. pymoo/cython/calc_perpendicular_distance.cp311-win_amd64.pyd +0 -0
  17. pymoo/cython/calc_perpendicular_distance.cpp +27467 -0
  18. pymoo/cython/calc_perpendicular_distance.pyx +67 -0
  19. pymoo/cython/decomposition.cp311-win_amd64.pyd +0 -0
  20. pymoo/cython/decomposition.cpp +28877 -0
  21. pymoo/cython/decomposition.pyx +165 -0
  22. pymoo/cython/hv.cp311-win_amd64.pyd +0 -0
  23. pymoo/cython/hv.cpp +27559 -0
  24. pymoo/cython/hv.pyx +18 -0
  25. pymoo/cython/info.cp311-win_amd64.pyd +0 -0
  26. pymoo/cython/info.cpp +6653 -0
  27. pymoo/cython/info.pyx +5 -0
  28. pymoo/cython/mnn.cp311-win_amd64.pyd +0 -0
  29. pymoo/cython/mnn.cpp +30117 -0
  30. pymoo/cython/mnn.pyx +273 -0
  31. pymoo/cython/non_dominated_sorting.cp311-win_amd64.pyd +0 -0
  32. pymoo/cython/non_dominated_sorting.cpp +35256 -0
  33. pymoo/cython/non_dominated_sorting.pyx +645 -0
  34. pymoo/cython/pruning_cd.cp311-win_amd64.pyd +0 -0
  35. pymoo/cython/pruning_cd.cpp +29277 -0
  36. pymoo/cython/pruning_cd.pyx +197 -0
  37. pymoo/cython/stochastic_ranking.cp311-win_amd64.pyd +0 -0
  38. pymoo/cython/stochastic_ranking.cpp +27872 -0
  39. pymoo/cython/stochastic_ranking.pyx +49 -0
  40. pymoo/cython/vendor/hypervolume.cpp +1621 -0
  41. pymoo/docs.py +1 -1
  42. pymoo/gradient/grad_autograd.py +2 -2
  43. pymoo/operators/crossover/ox.py +1 -1
  44. pymoo/operators/selection/rnd.py +2 -2
  45. pymoo/operators/selection/tournament.py +5 -5
  46. pymoo/optimize.py +2 -2
  47. pymoo/problems/dynamic/df.py +4 -4
  48. pymoo/problems/single/traveling_salesman.py +1 -1
  49. pymoo/util/misc.py +2 -2
  50. pymoo/util/mnn.py +2 -2
  51. pymoo/util/nds/fast_non_dominated_sort.py +5 -3
  52. pymoo/util/nds/non_dominated_sorting.py +2 -2
  53. pymoo/util/normalization.py +5 -8
  54. pymoo/util/ref_dirs/energy.py +4 -2
  55. pymoo/util/ref_dirs/reduction.py +1 -1
  56. pymoo/util/reference_direction.py +3 -2
  57. pymoo/util/value_functions.py +719 -0
  58. pymoo/util/vf_dominator.py +99 -0
  59. pymoo/version.py +1 -1
  60. pymoo/visualization/heatmap.py +3 -3
  61. pymoo/visualization/pcp.py +1 -1
  62. pymoo/visualization/radar.py +1 -1
  63. {pymoo-0.6.1.2.dist-info → pymoo-0.6.1.5.dev0.dist-info}/METADATA +13 -14
  64. {pymoo-0.6.1.2.dist-info → pymoo-0.6.1.5.dev0.dist-info}/RECORD +67 -47
  65. {pymoo-0.6.1.2.dist-info → pymoo-0.6.1.5.dev0.dist-info}/WHEEL +1 -1
  66. {pymoo-0.6.1.2.dist-info → pymoo-0.6.1.5.dev0.dist-info/licenses}/LICENSE +0 -0
  67. {pymoo-0.6.1.2.dist-info → pymoo-0.6.1.5.dev0.dist-info}/top_level.txt +0 -0
pymoo/docs.py CHANGED
@@ -87,7 +87,7 @@ algorithms = {
87
87
 
88
88
  visualization = {
89
89
  "figsize": """tuple
90
- The figure size. Default (figsize=(8, 6)). For some plots changing the size might have side-effects for position.
90
+ The figure size. Default (figsize=(8, 6)). For some plots changing the size might have side effects for position.
91
91
  """,
92
92
 
93
93
  "title": """str or tuple
@@ -3,7 +3,6 @@ import numpy as np
3
3
 
4
4
  try:
5
5
  import autograd.numpy as anp
6
- from autograd import value_and_grad
7
6
  from autograd.core import VJPNode, backward_pass
8
7
  from autograd.tracer import new_box, isbox
9
8
  except:
@@ -11,7 +10,8 @@ except:
11
10
 
12
11
 
13
12
  def value_and_grad(*args, **kwargs):
14
- return value_and_grad(*args, **kwargs)
13
+ from autograd import value_and_grad as vag
14
+ return vag(*args, **kwargs)
15
15
 
16
16
 
17
17
  def log(*args, **kwargs):
@@ -36,7 +36,7 @@ def ox(receiver, donor, seq=None, shift=False):
36
36
  assert len(donor) == len(receiver)
37
37
 
38
38
  # the sequence which shall be use for the crossover
39
- seq = seq if not None else random_sequence(len(receiver))
39
+ seq = seq if seq is not None else random_sequence(len(receiver))
40
40
  start, end = seq
41
41
 
42
42
  # the donation and a set of it to allow a quick lookup
@@ -3,7 +3,7 @@ import math
3
3
  import numpy as np
4
4
 
5
5
  from pymoo.core.selection import Selection
6
- from pymoo.util.misc import random_permuations
6
+ from pymoo.util.misc import random_permutations
7
7
 
8
8
 
9
9
  class RandomSelection(Selection):
@@ -16,7 +16,7 @@ class RandomSelection(Selection):
16
16
  n_perms = math.ceil(n_random / len(pop))
17
17
 
18
18
  # get random permutations and reshape them
19
- P = random_permuations(n_perms, len(pop))[:n_random]
19
+ P = random_permutations(n_perms, len(pop))[:n_random]
20
20
 
21
21
  return np.reshape(P, (n_select, n_parents))
22
22
 
@@ -3,12 +3,12 @@ import math
3
3
  import numpy as np
4
4
 
5
5
  from pymoo.core.selection import Selection
6
- from pymoo.util.misc import random_permuations
6
+ from pymoo.util.misc import random_permutations
7
7
 
8
8
 
9
9
  class TournamentSelection(Selection):
10
10
  """
11
- The Tournament selection is used to simulated a tournament between individuals. The pressure balances
11
+ The Tournament selection is used to simulate a tournament between individuals. The pressure balances
12
12
  greedy the genetic algorithm will be.
13
13
  """
14
14
 
@@ -19,10 +19,10 @@ class TournamentSelection(Selection):
19
19
  ----------
20
20
  func_comp: func
21
21
  The function to compare two individuals. It has the shape: comp(pop, indices) and returns the winner.
22
- If the function is None it is assumed the population is sorted by a criterium and only indices are compared.
22
+ If the function is None it is assumed the population is sorted by a criterion and only indices are compared.
23
23
 
24
24
  pressure: int
25
- The selection pressure to bie applied. Default it is a binary tournament.
25
+ The selection pressure to be applied. Default it is a binary tournament.
26
26
  """
27
27
 
28
28
  super().__init__(**kwargs)
@@ -42,7 +42,7 @@ class TournamentSelection(Selection):
42
42
  n_perms = math.ceil(n_random / len(pop))
43
43
 
44
44
  # get random permutations and reshape them
45
- P = random_permuations(n_perms, len(pop))[:n_random]
45
+ P = random_permutations(n_perms, len(pop))[:n_random]
46
46
  P = np.reshape(P, (n_select * n_parents, self.pressure))
47
47
 
48
48
  # compare using tournament function
pymoo/optimize.py CHANGED
@@ -8,7 +8,7 @@ def minimize(problem, algorithm, termination=None, copy_algorithm=True, copy_ter
8
8
 
9
9
  This is used as a convenience function to execute several algorithms with default settings which turned
10
10
  out to work for a test single. However, evolutionary computations utilizes the idea of customizing a
11
- meta-algorithm. Customizing the algorithm using the object oriented interface is recommended to improve the
11
+ meta-algorithm. Customizing the algorithm using the object-oriented interface is recommended to improve the
12
12
  convergence.
13
13
 
14
14
  Parameters
@@ -48,7 +48,7 @@ def minimize(problem, algorithm, termination=None, copy_algorithm=True, copy_ter
48
48
 
49
49
  """
50
50
 
51
- # create a copy of the algorithm object to ensure no side-effects
51
+ # create a copy of the algorithm object to ensure no side effects
52
52
  if copy_algorithm:
53
53
  algorithm = copy.deepcopy(algorithm)
54
54
 
@@ -318,10 +318,10 @@ class DF11(DF):
318
318
  y1 = np.pi * G / 6 + (np.pi / 2 - np.pi * G / 3) * x1
319
319
  y2 = np.pi * G / 6 + (np.pi / 2 - np.pi * G / 3) * x2
320
320
 
321
- f1 = np.sin(y1)
322
- f2 = np.dot(np.multiply(1, np.sin(y2)), np.cos(y1))
323
- f3 = np.dot(np.multiply(1, np.cos(y2)), np.cos(y1))
324
-
321
+ f1 = (1 + G) * np.sin(y1)
322
+ f2 = (1 + G) * np.sin(y2) * np.cos(y1) # Correct element-wise multiplication
323
+ f3 = (1 + G) * np.cos(y2) * np.cos(y1) # Correct element-wise multiplication
324
+
325
325
  return get_PF(np.array([f1, f2, f3]), False)
326
326
 
327
327
 
@@ -14,7 +14,7 @@ class TravelingSalesman(ElementwiseProblem):
14
14
  Parameters
15
15
  ----------
16
16
  cities : numpy.array
17
- The cities with 2-dimensional coordinates provided by a matrix where where city is represented by a row.
17
+ The cities with 2-dimensional coordinates provided by a matrix where city is represented by a row.
18
18
 
19
19
  """
20
20
  n_cities, _ = cities.shape
pymoo/util/misc.py CHANGED
@@ -58,7 +58,7 @@ def parameter_less_constraints(F, CV, F_max=None):
58
58
  return F
59
59
 
60
60
 
61
- def random_permuations(n, l, concat=True):
61
+ def random_permutations(n, l, concat=True):
62
62
  P = []
63
63
  for i in range(n):
64
64
  P.append(np.random.permutation(l))
@@ -360,7 +360,7 @@ def intersect(a, b):
360
360
 
361
361
 
362
362
  def has_feasible(pop):
363
- return np.any(pop.get("feasible"))
363
+ return np.any(pop.get("FEAS"))
364
364
 
365
365
 
366
366
  def to_numpy(a):
pymoo/util/mnn.py CHANGED
@@ -40,7 +40,7 @@ def calc_mnn_base(X, n_remove=0, twonn=False):
40
40
 
41
41
  D = squareform(pdist(X, metric="sqeuclidean"))
42
42
  Dnn = np.partition(D, range(1, M+1), axis=1)[:, 1:M+1]
43
- d = np.product(Dnn, axis=1)
43
+ d = np.prod(Dnn, axis=1)
44
44
  d[extremes] = np.inf
45
45
 
46
46
  n_removed = 0
@@ -63,7 +63,7 @@ def calc_mnn_base(X, n_remove=0, twonn=False):
63
63
 
64
64
  D[:, k] = np.inf
65
65
  Dnn[H] = np.partition(D[H], range(1, M+1), axis=1)[:, 1:M+1]
66
- d[H] = np.product(Dnn[H], axis=1)
66
+ d[H] = np.prod(Dnn[H], axis=1)
67
67
  d[extremes] = np.inf
68
68
 
69
69
  return d
@@ -3,8 +3,11 @@ import numpy as np
3
3
  from pymoo.util.dominator import Dominator
4
4
 
5
5
 
6
- def fast_non_dominated_sort(F, **kwargs):
7
- M = Dominator.calc_domination_matrix(F)
6
+ def fast_non_dominated_sort(F, dominator=Dominator(), **kwargs):
7
+ if "dominator" in kwargs:
8
+ M = Dominator.calc_domination_matrix(F)
9
+ else:
10
+ M = dominator.calc_domination_matrix(F)
8
11
 
9
12
  # calculate the dominance matrix
10
13
  n = M.shape[0]
@@ -65,4 +68,3 @@ def fast_non_dominated_sort(F, **kwargs):
65
68
  current_front = next_front
66
69
 
67
70
  return fronts
68
-
@@ -1,5 +1,5 @@
1
1
  import numpy as np
2
-
2
+ import sys
3
3
  from pymoo.util.dominator import Dominator
4
4
  from pymoo.util.function_loader import load_function
5
5
 
@@ -53,7 +53,7 @@ class NonDominatedSorting:
53
53
 
54
54
  def rank_from_fronts(fronts, n):
55
55
  # create the rank array and set values
56
- rank = np.full(n, 1e16, dtype=int)
56
+ rank = np.full(n, sys.maxsize, dtype=int)
57
57
  for i, front in enumerate(fronts):
58
58
  rank[front] = i
59
59
 
@@ -66,7 +66,7 @@ class ZeroToOneNormalization(Normalization):
66
66
  # now create all the masks that are necessary
67
67
  self.xl_only, self.xu_only = np.logical_and(~xl_nan, xu_nan), np.logical_and(xl_nan, ~xu_nan)
68
68
  self.both_nan = np.logical_and(np.isnan(xl), np.isnan(xu))
69
- self.neither_nan = ~self.both_nan
69
+ self.neither_nan = np.logical_and(~np.isnan(xl), ~np.isnan(xu))
70
70
 
71
71
  # if neither is nan than xu must be greater or equal than xl
72
72
  any_nan = np.logical_or(np.isnan(xl), np.isnan(xu))
@@ -76,18 +76,15 @@ class ZeroToOneNormalization(Normalization):
76
76
  if X is None or (self.xl is None and self.xu is None):
77
77
  return X
78
78
 
79
- xl, xu, xl_only, xu_only = self.xl, self.xu, self.xl_only, self.xu_only
80
- both_nan, neither_nan = self.both_nan, self.neither_nan
81
-
82
79
  # simple copy the input
83
80
  N = np.copy(X)
84
81
 
85
82
  # normalize between zero and one if neither of them is nan
86
- N[..., neither_nan] = (X[..., neither_nan] - xl[neither_nan]) / (xu[neither_nan] - xl[neither_nan])
83
+ N[..., self.neither_nan] = (X[..., self.neither_nan] - self.xl[self.neither_nan]) / (self.xu[self.neither_nan] - self.xl[self.neither_nan])
87
84
 
88
- N[..., xl_only] = X[..., xl_only] - xl[xl_only]
85
+ N[..., self.xl_only] = X[..., self.xl_only] - self.xl[self.xl_only]
89
86
 
90
- N[..., xu_only] = 1.0 - (xu[xu_only] - X[..., xu_only])
87
+ N[..., self.xu_only] = 1.0 - (self.xu[self.xu_only] - X[..., self.xu_only])
91
88
 
92
89
  return N
93
90
 
@@ -305,7 +302,7 @@ class ObjectiveSpaceNormalization:
305
302
  self._worst = None
306
303
 
307
304
  def update(self, pop):
308
- F, feas = pop.get("F", "feasible")
305
+ F, feas = pop.get("F", "FEAS")
309
306
  self._infeas_ideal = find_ideal(F, current=self._infeas_ideal)
310
307
 
311
308
  if np.any(feas):
@@ -156,12 +156,14 @@ class RieszEnergyReferenceDirectionFactory(ReferenceDirectionFactory):
156
156
  X = ReductionBasedReferenceDirectionFactory(self.n_dim,
157
157
  self.n_points,
158
158
  kmeans=True,
159
- lexsort=False) \
159
+ lexsort=False,
160
+ seed=self.seed) \
160
161
  .do()
161
162
 
162
163
  elif self.sampling == "construction":
163
164
  X = ConstructionBasedReferenceDirectionFactory(self.n_dim,
164
- self.n_points) \
165
+ self.n_points,
166
+ seed=self.seed) \
165
167
  .do()
166
168
  else:
167
169
  raise Exception("Unknown sampling method. Either reduction or construction.")
@@ -62,7 +62,7 @@ class ReductionBasedReferenceDirectionFactory(ReferenceDirectionFactory):
62
62
  self.n_points = n_points
63
63
 
64
64
  def _do(self):
65
- rnd = sample_on_unit_simplex(self.n_sample_points, self.n_dim, unit_simplex_mapping=self.sampling)
65
+ rnd = sample_on_unit_simplex(self.n_sample_points, self.n_dim, seed=self.seed, unit_simplex_mapping=self.sampling)
66
66
 
67
67
  def h(n):
68
68
  return get_partition_closest_to_points(n, self.n_dim)
@@ -174,12 +174,13 @@ class MultiLayerReferenceDirectionFactory:
174
174
  # Util
175
175
  # =========================================================================================================
176
176
 
177
- def get_rng(seed = None):
177
+ def get_rng(seed=None):
178
178
  if seed is None or type(seed) == int:
179
179
  rng = np.random.default_rng(seed)
180
180
  return rng
181
181
 
182
- def sample_on_unit_simplex(n_points, n_dim, unit_simplex_mapping="kraemer", seed = None):
182
+
183
+ def sample_on_unit_simplex(n_points, n_dim, unit_simplex_mapping="kraemer", seed=None):
183
184
  if unit_simplex_mapping == "sum":
184
185
  rnd = map_onto_unit_simplex(get_rng(seed).random((n_points, n_dim)), "sum")
185
186