iwopy 0.1.4__py3-none-any.whl → 0.1.8__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.

Potentially problematic release.


This version of iwopy might be problematic. Click here for more details.

iwopy/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.8
@@ -7,7 +7,7 @@ class BraninObjective(SimpleObjective):
7
7
  """
8
8
  The objective function for the Branin problem.
9
9
 
10
- The Branin, or Branin-Hoo function is defined as
10
+ The Branin (or Branin-Hoo) function is defined as
11
11
 
12
12
  f(x,y) = a(y-bx^2+cx-r)^2 + s(1-t)cos(x)+s
13
13
 
iwopy/core/optimizer.py CHANGED
@@ -12,19 +12,22 @@ class Optimizer(Base, metaclass=ABCMeta):
12
12
  ----------
13
13
  problem: iwopy.Problem
14
14
  The problem to optimize
15
- name: str, optional
15
+ name: str
16
16
  The name
17
17
 
18
18
  Attributes
19
19
  ----------
20
20
  problem: iwopy.Problem
21
21
  The problem to optimize
22
+ name: str
23
+ The name
22
24
 
23
25
  """
24
26
 
25
- def __init__(self, problem, name=None):
27
+ def __init__(self, problem, name="optimizer"):
26
28
  super().__init__(name)
27
29
  self.problem = problem
30
+ self.name = name
28
31
 
29
32
  def print_info(self):
30
33
  """
@@ -81,7 +84,10 @@ class Optimizer(Base, metaclass=ABCMeta):
81
84
  if verbosity:
82
85
 
83
86
  print(f"{type(self).__name__}: Optimization run finished")
84
- if len(opt_results.success.flat) == 1:
87
+ if (
88
+ isinstance(opt_results.success, bool)
89
+ or len(opt_results.success.flat) == 1
90
+ ):
85
91
  print(f" Success: {opt_results.success}")
86
92
  else:
87
93
  v = np.sum(opt_results.success) / len(opt_results.success.flat)
iwopy/core/problem.py CHANGED
@@ -709,7 +709,7 @@ class Problem(Base, metaclass=ABCMeta):
709
709
  """
710
710
  return None
711
711
 
712
- def evaluate_individual(self, vars_int, vars_float):
712
+ def evaluate_individual(self, vars_int, vars_float, ret_prob_res=False):
713
713
  """
714
714
  Evaluate a single individual of the problem.
715
715
 
@@ -728,10 +728,12 @@ class Problem(Base, metaclass=ABCMeta):
728
728
  The objective function values, shape: (n_objectives,)
729
729
  con : np.array
730
730
  The constraints values, shape: (n_constraints,)
731
+ prob_res : object, optional
732
+ The problem results
731
733
 
732
734
  """
733
735
  objs, cons = None, None
734
- if self.memory is not None:
736
+ if not ret_prob_res and self.memory is not None:
735
737
  memres = self.memory.lookup_individual(vars_int, vars_float)
736
738
  if memres is not None:
737
739
  objs, cons = memres
@@ -750,9 +752,12 @@ class Problem(Base, metaclass=ABCMeta):
750
752
  if self.memory is not None:
751
753
  self.memory.store_individual(vars_int, vars_float, objs, cons)
752
754
 
753
- return objs, cons
755
+ if ret_prob_res:
756
+ return objs, cons, results
757
+ else:
758
+ return objs, cons
754
759
 
755
- def evaluate_population(self, vars_int, vars_float):
760
+ def evaluate_population(self, vars_int, vars_float, ret_prob_res=False):
756
761
  """
757
762
  Evaluate all individuals of a population.
758
763
 
@@ -762,6 +767,8 @@ class Problem(Base, metaclass=ABCMeta):
762
767
  The integer variable values, shape: (n_pop, n_vars_int)
763
768
  vars_float : np.array
764
769
  The float variable values, shape: (n_pop, n_vars_float)
770
+ ret_prob_res : bool
771
+ Flag for additionally returning of problem results
765
772
 
766
773
  Returns
767
774
  -------
@@ -769,11 +776,13 @@ class Problem(Base, metaclass=ABCMeta):
769
776
  The objective function values, shape: (n_pop, n_objectives)
770
777
  cons : np.array
771
778
  The constraints values, shape: (n_pop, n_constraints)
779
+ prob_res : object, optional
780
+ The problem results
772
781
 
773
782
  """
774
783
 
775
784
  from_mem = False
776
- if self.memory is not None:
785
+ if not ret_prob_res and self.memory is not None:
777
786
  memres = self.memory.lookup_population(vars_int, vars_float)
778
787
  if memres is not None:
779
788
  todo = np.any(np.isnan(memres), axis=1)
@@ -814,7 +823,10 @@ class Problem(Base, metaclass=ABCMeta):
814
823
  if self.memory is not None:
815
824
  self.memory.store_population(vars_int, vars_float, objs, cons)
816
825
 
817
- return objs, cons
826
+ if ret_prob_res:
827
+ return objs, cons, results
828
+ else:
829
+ return objs, cons
818
830
 
819
831
  def check_constraints_individual(self, constraint_values, verbosity=0):
820
832
  """
@@ -945,6 +957,54 @@ class Problem(Base, metaclass=ABCMeta):
945
957
 
946
958
  return results, objs, cons
947
959
 
960
+ def prob_res_einsum_individual(self, prob_res_list, coeffs):
961
+ """
962
+ Calculate the einsum of problem results
963
+
964
+ Parameters
965
+ ----------
966
+ prob_res_list : list
967
+ The problem results
968
+ coeffs : numpy.ndarray
969
+ The coefficients
970
+
971
+ Returns
972
+ -------
973
+ prob_res : object
974
+ The weighted sum of problem results
975
+
976
+ """
977
+ if not len(prob_res_list) or prob_res_list[0] is None:
978
+ return None
979
+
980
+ raise NotImplementedError(
981
+ f"Problem '{self.name}': Einsum not implemented for problem results type '{type(prob_res_list[0]).__name__}'"
982
+ )
983
+
984
+ def prob_res_einsum_population(self, prob_res_list, coeffs):
985
+ """
986
+ Calculate the einsum of problem results
987
+
988
+ Parameters
989
+ ----------
990
+ prob_res_list : list
991
+ The problem results
992
+ coeffs : numpy.ndarray
993
+ The coefficients
994
+
995
+ Returns
996
+ -------
997
+ prob_res : object
998
+ The weighted sum of problem results
999
+
1000
+ """
1001
+ if not len(prob_res_list) or prob_res_list[0] is None:
1002
+ return None
1003
+
1004
+ raise NotImplementedError(
1005
+ f"Problem '{self.name}': Einsum not implemented for problem results type '{type(prob_res_list[0]).__name__}'"
1006
+ )
1007
+
948
1008
 
949
1009
  class ProblemDefaultFunc(OptFunctionList):
950
1010
  """
@@ -1,2 +1,3 @@
1
1
  from . import pygmo
2
2
  from . import pymoo
3
+ from . import scipy
@@ -1,4 +1,4 @@
1
- from .imports import pygmo, check_import
1
+ from . import imports
2
2
 
3
3
 
4
4
  class AlgoFactory:
@@ -22,17 +22,17 @@ class AlgoFactory:
22
22
 
23
23
  Returns
24
24
  -------
25
- pygmo.algo :
25
+ imports.pygmo.algo :
26
26
  The pygmo algorithm object
27
27
 
28
28
  """
29
29
 
30
- check_import()
30
+ imports.load()
31
31
 
32
32
  def set_bfe(uda):
33
33
  if pop:
34
34
  try:
35
- bfe = pygmo.bfe()
35
+ bfe = imports.pygmo.bfe()
36
36
  uda.set_bfe(bfe)
37
37
  except AttributeError:
38
38
  print(
@@ -42,28 +42,28 @@ class AlgoFactory:
42
42
  # nlopt:
43
43
  if type == "nlopt":
44
44
 
45
- uda = pygmo.nlopt(kwargs["optimizer"])
45
+ uda = imports.pygmo.nlopt(kwargs["optimizer"])
46
46
  set_bfe(uda)
47
47
 
48
- algo = pygmo.algorithm(uda)
48
+ algo = imports.pygmo.algorithm(uda)
49
49
 
50
50
  if "ftol_rel" in kwargs:
51
- algo.extract(pygmo.nlopt).ftol_rel = kwargs["ftol_rel"]
51
+ algo.extract(imports.pygmo.nlopt).ftol_rel = kwargs["ftol_rel"]
52
52
  if "ftol_abs" in kwargs:
53
- algo.extract(pygmo.nlopt).ftol_abs = kwargs["ftol_abs"]
53
+ algo.extract(imports.pygmo.nlopt).ftol_abs = kwargs["ftol_abs"]
54
54
  if "xtol_rel" in kwargs:
55
- algo.extract(pygmo.nlopt).xtol_rel = kwargs["xtol_rel"]
55
+ algo.extract(imports.pygmo.nlopt).xtol_rel = kwargs["xtol_rel"]
56
56
  if "xtol_abs" in kwargs:
57
- algo.extract(pygmo.nlopt).xtol_abs = kwargs["xtol_abs"]
57
+ algo.extract(imports.pygmo.nlopt).xtol_abs = kwargs["xtol_abs"]
58
58
  if "maxeval" in kwargs:
59
- algo.extract(pygmo.nlopt).maxeval = kwargs["maxeval"]
59
+ algo.extract(imports.pygmo.nlopt).maxeval = kwargs["maxeval"]
60
60
  if "maxtime" in kwargs:
61
- algo.extract(pygmo.nlopt).maxtime = kwargs["maxtime"]
61
+ algo.extract(imports.pygmo.nlopt).maxtime = kwargs["maxtime"]
62
62
 
63
63
  # ipopt:
64
64
  elif type == "ipopt":
65
65
 
66
- uda = pygmo.ipopt()
66
+ uda = imports.pygmo.ipopt()
67
67
  set_bfe(uda)
68
68
 
69
69
  for k, a in kwargs.items():
@@ -77,7 +77,7 @@ class AlgoFactory:
77
77
  else:
78
78
  uda.set_string_option(k, a)
79
79
 
80
- algo = pygmo.algorithm(uda)
80
+ algo = imports.pygmo.algorithm(uda)
81
81
 
82
82
  # sga:
83
83
  elif type == "sga":
@@ -109,10 +109,10 @@ class AlgoFactory:
109
109
  *Crossover*: four different crossover schemes are provided:``single``, ``exponential``, ``binomial``, ``sbx``. The
110
110
  ``single`` point crossover, works selecting a random point in the parent chromosome and, with probability *cr*, inserting the
111
111
  partner chromosome thereafter. The ``exponential`` crossover is taken from the algorithm differential evolution,
112
- implemented, in pygmo, as :class:`~pygmo.de`. It essentially selects a random point in the parent chromosome and inserts,
112
+ implemented, in pygmo, as :class:`~imports.pygmo.de`. It essentially selects a random point in the parent chromosome and inserts,
113
113
  in each successive gene, the partner values with probability *cr* up to when it stops. The binomial crossover
114
114
  inserts each gene from the partner with probability *cr*. The simulated binary crossover (called ``sbx``), is taken
115
- from the NSGA-II algorithm, implemented in pygmo as :class:`~pygmo.nsga2`, and makes use of an additional parameter called
115
+ from the NSGA-II algorithm, implemented in pygmo as :class:`~imports.pygmo.nsga2`, and makes use of an additional parameter called
116
116
  distribution index *eta_c*.
117
117
 
118
118
  *Mutation*: three different mutations schemes are provided: ``uniform``, ``gaussian`` and ``polynomial``. Uniform mutation
@@ -125,10 +125,10 @@ class AlgoFactory:
125
125
 
126
126
  """
127
127
 
128
- uda = pygmo.sga(**kwargs)
128
+ uda = imports.pygmo.sga(**kwargs)
129
129
  set_bfe(uda)
130
130
 
131
- algo = pygmo.algorithm(uda)
131
+ algo = imports.pygmo.algorithm(uda)
132
132
 
133
133
  # pso:
134
134
  elif type == "pso":
@@ -171,10 +171,10 @@ class AlgoFactory:
171
171
 
172
172
  """
173
173
 
174
- uda = pygmo.pso(**kwargs)
174
+ uda = imports.pygmo.pso(**kwargs)
175
175
  set_bfe(uda)
176
176
 
177
- algo = pygmo.algorithm(uda)
177
+ algo = imports.pygmo.algorithm(uda)
178
178
 
179
179
  # bee_colony:
180
180
  elif type == "bee_colony":
@@ -193,10 +193,10 @@ class AlgoFactory:
193
193
 
194
194
  """
195
195
 
196
- uda = pygmo.bee_colony(**kwargs)
196
+ uda = imports.pygmo.bee_colony(**kwargs)
197
197
  set_bfe(uda)
198
198
 
199
- algo = pygmo.algorithm(uda)
199
+ algo = imports.pygmo.algorithm(uda)
200
200
 
201
201
  # nsga2:
202
202
  elif type == "nsga2":
@@ -219,10 +219,10 @@ class AlgoFactory:
219
219
 
220
220
  """
221
221
 
222
- uda = pygmo.nsga2(**kwargs)
222
+ uda = imports.pygmo.nsga2(**kwargs)
223
223
  set_bfe(uda)
224
224
 
225
- algo = pygmo.algorithm(uda)
225
+ algo = imports.pygmo.algorithm(uda)
226
226
 
227
227
  # unknown driver:
228
228
  else:
@@ -1,20 +1,21 @@
1
- try:
2
- import pygmo
3
-
4
- IMPORT_OK = True
5
- except ImportError:
6
- pygmo = None
7
- IMPORT_OK = False
8
-
9
-
10
- def check_import():
11
- """
12
- Checks if library import worked,
13
- raises error otherwise.
14
- """
15
- if not IMPORT_OK:
16
- print("\n\nFailed to import pygmo. Please install, either via pip:\n")
17
- print(" pip install pygmo\n")
18
- print("or via conda:\n")
19
- print(" conda install -c conda-forge pygmo\n")
20
- raise ImportError("Failed to import pygmo")
1
+ from iwopy.utils import import_module
2
+
3
+ pygmo = None
4
+ loaded = False
5
+
6
+
7
+ def load(verbosity=1):
8
+
9
+ global pygmo, loaded
10
+
11
+ if not loaded:
12
+
13
+ if verbosity:
14
+ print("Loading pygmo")
15
+
16
+ pygmo = import_module("pygmo", hint="pip install pygmo")
17
+
18
+ loaded = True
19
+
20
+ if verbosity:
21
+ print("pygmo successfully loaded")
@@ -4,7 +4,7 @@ from iwopy.core import Optimizer
4
4
  from iwopy.utils import suppress_stdout
5
5
  from .problem import UDP
6
6
  from .algos import AlgoFactory
7
- from .imports import pygmo, check_import
7
+ from . import imports
8
8
 
9
9
 
10
10
  class Optimizer_pygmo(Optimizer):
@@ -31,9 +31,9 @@ class Optimizer_pygmo(Optimizer):
31
31
  Parameters for the alorithm
32
32
  setup_pars : dict
33
33
  Parameters for the calculation setup
34
- udp : iwopy.interfaces.pygmo.UDA
34
+ udp : iwopy.interfaces.imports.pygmo.UDA
35
35
  The pygmo problem
36
- algo : pygmo.algo
36
+ algo : imports.pygmo.algo
37
37
  The pygmo algorithm
38
38
 
39
39
  """
@@ -41,7 +41,7 @@ class Optimizer_pygmo(Optimizer):
41
41
  def __init__(self, problem, problem_pars, algo_pars, setup_pars={}):
42
42
  super().__init__(problem)
43
43
 
44
- check_import()
44
+ imports.load()
45
45
 
46
46
  self.problem_pars = problem_pars
47
47
  self.algo_pars = algo_pars
@@ -72,7 +72,7 @@ class Optimizer_pygmo(Optimizer):
72
72
  psize = self.setup_pars.get("pop_size", 1)
73
73
  pseed = self.setup_pars.get("seed", None)
74
74
  pnrfi = self.setup_pars.get("norandom_first", psize == 1)
75
- self.pop = pygmo.population(self.udp, size=psize, seed=pseed)
75
+ self.pop = imports.pygmo.population(self.udp, size=psize, seed=pseed)
76
76
  self.pop.problem.c_tol = [
77
77
  self.setup_pars.get("c_tol", 1e-4)
78
78
  ] * self.pop.problem.get_nc()
@@ -1 +1 @@
1
- from .optimizer import Optimizer_pymoo, DefaultCallback
1
+ from .optimizer import Optimizer_pymoo
@@ -1,23 +1,4 @@
1
- from .imports import IMPORT_OK, check_import
2
-
3
- if IMPORT_OK:
4
- from pymoo.operators.sampling.rnd import (
5
- IntegerRandomSampling,
6
- FloatRandomSampling,
7
- BinaryRandomSampling,
8
- PermutationRandomSampling,
9
- )
10
- from pymoo.operators.sampling.lhs import LatinHypercubeSampling
11
- from pymoo.operators.crossover.sbx import SBX
12
- from pymoo.operators.mutation.pm import PM
13
- from pymoo.algorithms.soo.nonconvex.ga import GA
14
- from pymoo.algorithms.moo.nsga2 import NSGA2
15
- from pymoo.algorithms.soo.nonconvex.pso import PSO
16
- from pymoo.core.mixed import MixedVariableGA
17
- from pymoo.termination.default import (
18
- DefaultSingleObjectiveTermination,
19
- DefaultMultiObjectiveTermination,
20
- )
1
+ from . import imports
21
2
 
22
3
 
23
4
  class Factory:
@@ -26,10 +7,11 @@ class Factory:
26
7
  """
27
8
 
28
9
  def __init__(self, pymoo_problem, verbosity):
29
- check_import()
30
10
  self.pymoo_problem = pymoo_problem
31
11
  self.verbosity = verbosity
32
12
 
13
+ imports.load(verbosity)
14
+
33
15
  def print(self, *args, **kwargs):
34
16
  if self.verbosity:
35
17
  print(*args, **kwargs)
@@ -45,15 +27,15 @@ class Factory:
45
27
  samp_name = "float_random"
46
28
 
47
29
  if samp_name == "int_random":
48
- out = IntegerRandomSampling(**kwargs)
30
+ out = imports.IntegerRandomSampling(**kwargs)
49
31
  elif samp_name == "float_random":
50
- out = FloatRandomSampling(**kwargs)
32
+ out = imports.FloatRandomSampling(**kwargs)
51
33
  elif samp_name == "binary_random":
52
- out = BinaryRandomSampling(**kwargs)
34
+ out = imports.BinaryRandomSampling(**kwargs)
53
35
  elif samp_name == "permutation_random":
54
- out = PermutationRandomSampling(**kwargs)
36
+ out = imports.PermutationRandomSampling(**kwargs)
55
37
  elif samp_name == "lhs":
56
- out = LatinHypercubeSampling(**kwargs)
38
+ out = imports.LatinHypercubeSampling(**kwargs)
57
39
  else:
58
40
  raise KeyError(
59
41
  f"Unknown sampling '{samp_name}', please choose: int_random, float_random, binary_random, permutation_random, lhs"
@@ -68,7 +50,7 @@ class Factory:
68
50
  Crossover factory function
69
51
  """
70
52
  if cross == "sbx":
71
- out = SBX(**pars)
53
+ out = imports.SBX(**pars)
72
54
  else:
73
55
  raise KeyError(f"Unknown crossover '{cross}', please choose: sbx")
74
56
 
@@ -81,7 +63,7 @@ class Factory:
81
63
  Mutation factory function
82
64
  """
83
65
  if mut == "pm":
84
- out = PM(**pars)
66
+ out = imports.PM(**pars)
85
67
  else:
86
68
  raise KeyError(f"Unknown mutation '{mut}', please choose: pm")
87
69
 
@@ -118,7 +100,7 @@ class Factory:
118
100
  mut = pars["mutation"]
119
101
  pars["mutation"] = self.get_mutation(mut, **mut_pars)
120
102
 
121
- out = GA(**pars)
103
+ out = imports.GA(**pars)
122
104
 
123
105
  # Particle Swarm:
124
106
  elif typ == "PSO":
@@ -144,7 +126,7 @@ class Factory:
144
126
  mut = pars["mutation"]
145
127
  pars["mutation"] = self.get_mutation(mut, **mut_pars)
146
128
 
147
- out = PSO(**pars)
129
+ out = imports.PSO(**pars)
148
130
 
149
131
  # NSGA2:
150
132
  elif typ == "NSGA2":
@@ -169,7 +151,7 @@ class Factory:
169
151
  mut = pars["mutation"]
170
152
  pars["mutation"] = self.get_mutation(mut, **mut_pars)
171
153
 
172
- out = NSGA2(**pars)
154
+ out = imports.NSGA2(**pars)
173
155
 
174
156
  # MixedVariableGA:
175
157
  elif typ == "MixedVariableGA":
@@ -188,10 +170,12 @@ class Factory:
188
170
  mut = pars["mutation"]
189
171
  pars["mutation"] = self.get_mutation(mut, **mut_pars)
190
172
 
191
- out = MixedVariableGA(**pars)
173
+ out = imports.MixedVariableGA(**pars)
192
174
 
193
175
  else:
194
- raise KeyError(f"Unknown algorithm '{typ}', please choose: GA, PSO, NSGA2, MixedVariableGA")
176
+ raise KeyError(
177
+ f"Unknown algorithm '{typ}', please choose: GA, PSO, NSGA2, MixedVariableGA"
178
+ )
195
179
 
196
180
  self.print(f"Selecting algorithm: {typ} ({type(out).__name__})")
197
181
 
@@ -210,9 +194,9 @@ class Factory:
210
194
  return typ
211
195
  elif typ == "default":
212
196
  if self.pymoo_problem.problem.n_objectives > 1:
213
- out = DefaultMultiObjectiveTermination(**term_pars)
197
+ out = imports.DefaultMultiObjectiveTermination(**term_pars)
214
198
  else:
215
- out = DefaultSingleObjectiveTermination(**term_pars)
199
+ out = imports.DefaultSingleObjectiveTermination(**term_pars)
216
200
  else:
217
201
  raise KeyError(f"Unknown termination '{type}', please choose: default")
218
202
 
@@ -1,30 +1,83 @@
1
- try:
1
+ from iwopy.utils import import_module
2
2
 
3
- from pymoo.core.callback import Callback
4
- from pymoo.core.problem import Problem
5
- from pymoo.core.variable import Real, Integer
3
+ Callback = None
4
+ Problem = None
5
+ Real = None
6
+ Integer = None
6
7
 
7
- IMPORT_OK = True
8
+ IntegerRandomSampling = None
9
+ FloatRandomSampling = None
10
+ BinaryRandomSampling = None
11
+ PermutationRandomSampling = None
8
12
 
9
- except ImportError:
13
+ LatinHypercubeSampling = None
14
+ SBX = None
15
+ PM = None
16
+ GA = None
17
+ NSGA2 = None
18
+ PSO = None
19
+ MixedVariableGA = None
10
20
 
11
- Problem = object
21
+ DefaultSingleObjectiveTermination = None
22
+ DefaultMultiObjectiveTermination = None
12
23
 
13
- class Callback:
14
- def __init__(self):
15
- self.data = dict()
24
+ minimize = None
16
25
 
17
- IMPORT_OK = False
26
+ loaded = False
18
27
 
19
28
 
20
- def check_import():
21
- """
22
- Checks if library import worked,
23
- raises error otherwise.
24
- """
25
- if not IMPORT_OK:
26
- print("\n\nFailed to import pmoo. Please install, either via pip:\n")
27
- print(" pip install pymoo\n")
28
- print("or via conda:\n")
29
- print(" conda install -c conda-forge pymoo\n")
30
- raise ImportError("Failed to import pymoo")
29
+ def load(verbosity=1):
30
+
31
+ global Callback, Problem, Real, Integer, IntegerRandomSampling, FloatRandomSampling
32
+ global BinaryRandomSampling, PermutationRandomSampling, LatinHypercubeSampling, SBX
33
+ global PM, GA, NSGA2, PSO, MixedVariableGA, DefaultSingleObjectiveTermination
34
+ global DefaultMultiObjectiveTermination, minimize, loaded
35
+
36
+ if not loaded:
37
+
38
+ if verbosity:
39
+ print("Loading pymoo")
40
+
41
+ Callback = import_module(
42
+ "pymoo.core.callback", hint="pip install pymoo"
43
+ ).Callback
44
+ Problem = import_module("pymoo.core.problem", hint="pip install pymoo").Problem
45
+ Real = import_module("pymoo.core.variable", hint="pip install pymoo").Real
46
+ Integer = import_module("pymoo.core.variable", hint="pip install pymoo").Integer
47
+
48
+ rnd = import_module("pymoo.operators.sampling.rnd", hint="pip install pymoo")
49
+ IntegerRandomSampling = rnd.IntegerRandomSampling
50
+ FloatRandomSampling = rnd.FloatRandomSampling
51
+ BinaryRandomSampling = rnd.BinaryRandomSampling
52
+ PermutationRandomSampling = rnd.PermutationRandomSampling
53
+
54
+ LatinHypercubeSampling = import_module(
55
+ "pymoo.operators.sampling.lhs", hint="pip install pymoo"
56
+ ).LatinHypercubeSampling
57
+ SBX = import_module(
58
+ "pymoo.operators.crossover.sbx", hint="pip install pymoo"
59
+ ).SBX
60
+ PM = import_module("pymoo.operators.mutation.pm", hint="pip install pymoo").PM
61
+ GA = import_module(
62
+ "pymoo.algorithms.soo.nonconvex.ga", hint="pip install pymoo"
63
+ ).GA
64
+ NSGA2 = import_module(
65
+ "pymoo.algorithms.moo.nsga2", hint="pip install pymoo"
66
+ ).NSGA2
67
+ PSO = import_module(
68
+ "pymoo.algorithms.soo.nonconvex.pso", hint="pip install pymoo"
69
+ ).PSO
70
+ MixedVariableGA = import_module(
71
+ "pymoo.core.mixed", hint="pip install pymoo"
72
+ ).MixedVariableGA
73
+
74
+ ter = import_module("pymoo.termination.default", hint="pip install pymoo")
75
+ DefaultSingleObjectiveTermination = ter.DefaultSingleObjectiveTermination
76
+ DefaultMultiObjectiveTermination = ter.DefaultMultiObjectiveTermination
77
+
78
+ minimize = import_module("pymoo.optimize", hint="pip install pymoo").minimize
79
+
80
+ loaded = True
81
+
82
+ if verbosity:
83
+ print("pymoo successfully loaded")