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

Files changed (43) hide show
  1. iwopy/VERSION +1 -1
  2. iwopy/__init__.py +6 -1
  3. iwopy/benchmarks/branin/__init__.py +1 -0
  4. iwopy/benchmarks/{branin.py → branin/branin.py} +29 -19
  5. iwopy/benchmarks/rosenbrock/__init__.py +1 -0
  6. iwopy/benchmarks/{rosenbrock.py → rosenbrock/rosenbrock.py} +35 -27
  7. iwopy/core/base.py +14 -8
  8. iwopy/core/constraint.py +20 -14
  9. iwopy/core/function.py +66 -60
  10. iwopy/core/function_list.py +51 -45
  11. iwopy/core/function_subset.py +33 -28
  12. iwopy/core/memory.py +43 -35
  13. iwopy/core/objective.py +4 -1
  14. iwopy/core/opt_results.py +79 -68
  15. iwopy/core/optimizer.py +15 -9
  16. iwopy/core/problem.py +116 -104
  17. iwopy/interfaces/pygmo/__init__.py +3 -0
  18. iwopy/interfaces/pygmo/algos.py +5 -2
  19. iwopy/interfaces/pygmo/imports.py +11 -0
  20. iwopy/interfaces/pygmo/optimizer.py +24 -18
  21. iwopy/interfaces/pygmo/problem.py +24 -19
  22. iwopy/interfaces/pymoo/__init__.py +4 -1
  23. iwopy/interfaces/pymoo/factory.py +6 -0
  24. iwopy/interfaces/pymoo/imports.py +11 -0
  25. iwopy/interfaces/pymoo/optimizer.py +75 -48
  26. iwopy/interfaces/pymoo/problem.py +330 -314
  27. iwopy/interfaces/scipy/optimizer.py +26 -20
  28. iwopy/optimizers/gg.py +41 -35
  29. iwopy/utils/discretization.py +106 -100
  30. iwopy/utils/stdout.py +2 -0
  31. iwopy/wrappers/discretize_reg_grid.py +65 -59
  32. iwopy/wrappers/local_fd.py +40 -34
  33. iwopy/wrappers/problem_wrapper.py +43 -37
  34. iwopy/wrappers/simple_constraint.py +47 -41
  35. iwopy/wrappers/simple_objective.py +42 -36
  36. iwopy/wrappers/simple_problem.py +40 -34
  37. {iwopy-0.1.9.dist-info → iwopy-0.2.dist-info}/METADATA +12 -3
  38. iwopy-0.2.dist-info/RECORD +50 -0
  39. iwopy-0.1.9.dist-info/RECORD +0 -48
  40. {iwopy-0.1.9.dist-info → iwopy-0.2.dist-info}/LICENSE +0 -0
  41. {iwopy-0.1.9.dist-info → iwopy-0.2.dist-info}/WHEEL +0 -0
  42. {iwopy-0.1.9.dist-info → iwopy-0.2.dist-info}/top_level.txt +0 -0
  43. {iwopy-0.1.9.dist-info → iwopy-0.2.dist-info}/zip-safe +0 -0
@@ -13,27 +13,33 @@ class OptFunctionList(OptFunction):
13
13
  Add functions to the list via the `append` function,
14
14
  and don't forget to initialize.
15
15
 
16
- Parameters
17
- ----------
18
- problem: iwopy.Problem
19
- The underlying optimization problem
20
- name: str
21
- The function name
22
-
23
16
  Attributes
24
17
  ----------
25
- func_vars_int : list of lists of int
18
+ func_vars_int: list of lists of int
26
19
  For each added function, the subset of
27
20
  integer variables
28
- func_vars_float : list of lists of int
21
+ func_vars_float: list of lists of int
29
22
  For each added function, the subset of
30
23
  float variables
31
- sizes : list of int
24
+ sizes: list of int
32
25
  The components of each added function
33
26
 
27
+ :group: core
28
+
34
29
  """
35
30
 
36
31
  def __init__(self, problem, name):
32
+ """
33
+ Constructor
34
+
35
+ Parameters
36
+ ----------
37
+ problem: iwopy.Problem
38
+ The underlying optimization problem
39
+ name: str
40
+ The function name
41
+
42
+ """
37
43
  super().__init__(problem, name)
38
44
 
39
45
  self._functions = []
@@ -48,7 +54,7 @@ class OptFunctionList(OptFunction):
48
54
 
49
55
  Parameters
50
56
  ----------
51
- function : iwopy.core.OptFunction
57
+ function: iwopy.core.OptFunction
52
58
  The function
53
59
 
54
60
  """
@@ -71,7 +77,7 @@ class OptFunctionList(OptFunction):
71
77
 
72
78
  Returns
73
79
  -------
74
- funcs : list of iwopy.core.OptFunction
80
+ funcs: list of iwopy.core.OptFunction
75
81
  The list of added functions
76
82
 
77
83
  """
@@ -84,7 +90,7 @@ class OptFunctionList(OptFunction):
84
90
 
85
91
  Returns
86
92
  -------
87
- n : int
93
+ n: int
88
94
  The total number of added functions
89
95
 
90
96
  """
@@ -96,7 +102,7 @@ class OptFunctionList(OptFunction):
96
102
 
97
103
  Parameters
98
104
  ----------
99
- verbosity : int
105
+ verbosity: int
100
106
  The verbosity level, 0 = silent
101
107
 
102
108
  """
@@ -134,7 +140,7 @@ class OptFunctionList(OptFunction):
134
140
 
135
141
  Returns
136
142
  -------
137
- deps : numpy.ndarray of bool
143
+ deps: numpy.ndarray of bool
138
144
  The dependencies of components on function
139
145
  variables, shape: (n_components, n_vars_int)
140
146
 
@@ -156,7 +162,7 @@ class OptFunctionList(OptFunction):
156
162
 
157
163
  Returns
158
164
  -------
159
- deps : numpy.ndarray of bool
165
+ deps: numpy.ndarray of bool
160
166
  The dependencies of components on function
161
167
  variables, shape: (n_components, n_vars_float)
162
168
 
@@ -191,12 +197,12 @@ class OptFunctionList(OptFunction):
191
197
 
192
198
  Parameters
193
199
  ----------
194
- data : numpy.ndarray
200
+ data: numpy.ndarray
195
201
  The data, shape: (n_components,)
196
202
 
197
203
  Returns
198
204
  -------
199
- fdata : list of numpy.ndarray
205
+ fdata: list of numpy.ndarray
200
206
  The data for each function, list entry
201
207
  shapes: (n_func_components,)
202
208
 
@@ -216,12 +222,12 @@ class OptFunctionList(OptFunction):
216
222
 
217
223
  Parameters
218
224
  ----------
219
- data : numpy.ndarray
225
+ data: numpy.ndarray
220
226
  The data, shape: (n_pop, n_components)
221
227
 
222
228
  Returns
223
229
  -------
224
- fdata : list of numpy.ndarray
230
+ fdata: list of numpy.ndarray
225
231
  The data for each function, list entry
226
232
  shapes: (n_pop, n_func_components)
227
233
 
@@ -241,19 +247,19 @@ class OptFunctionList(OptFunction):
241
247
 
242
248
  Parameters
243
249
  ----------
244
- vars_int : np.array
250
+ vars_int: np.array
245
251
  The integer variable values, shape: (n_vars_int,)
246
- vars_float : np.array
252
+ vars_float: np.array
247
253
  The float variable values, shape: (n_vars_float,)
248
- problem_results : Any
254
+ problem_results: Any
249
255
  The results of the variable application
250
256
  to the problem
251
- components : list of int, optional
257
+ components: list of int, optional
252
258
  The selected components or None for all
253
259
 
254
260
  Returns
255
261
  -------
256
- values : np.array
262
+ values: np.array
257
263
  The component values, shape: (n_sel_components,)
258
264
 
259
265
  """
@@ -285,19 +291,19 @@ class OptFunctionList(OptFunction):
285
291
 
286
292
  Parameters
287
293
  ----------
288
- vars_int : np.array
294
+ vars_int: np.array
289
295
  The integer variable values, shape: (n_pop, n_vars_int)
290
- vars_float : np.array
296
+ vars_float: np.array
291
297
  The float variable values, shape: (n_pop, n_vars_float)
292
- problem_results : Any
298
+ problem_results: Any
293
299
  The results of the variable application
294
300
  to the problem
295
- components : list of int, optional
301
+ components: list of int, optional
296
302
  The selected components or None for all
297
303
 
298
304
  Returns
299
305
  -------
300
- values : np.array
306
+ values: np.array
301
307
  The component values, shape: (n_pop, n_sel_components,)
302
308
 
303
309
  """
@@ -330,19 +336,19 @@ class OptFunctionList(OptFunction):
330
336
 
331
337
  Parameters
332
338
  ----------
333
- vars_int : np.array
339
+ vars_int: np.array
334
340
  The optimal integer variable values, shape: (n_vars_int,)
335
- vars_float : np.array
341
+ vars_float: np.array
336
342
  The optimal float variable values, shape: (n_vars_float,)
337
- problem_results : Any
343
+ problem_results: Any
338
344
  The results of the variable application
339
345
  to the problem
340
- verbosity : int
346
+ verbosity: int
341
347
  The verbosity level, 0 = silent
342
348
 
343
349
  Returns
344
350
  -------
345
- values : np.array
351
+ values: np.array
346
352
  The component values, shape: (n_components,)
347
353
 
348
354
  """
@@ -366,21 +372,21 @@ class OptFunctionList(OptFunction):
366
372
 
367
373
  Parameters
368
374
  ----------
369
- vars_int : np.array
375
+ vars_int: np.array
370
376
  The integer variable values of the final
371
377
  generation, shape: (n_pop, n_vars_int)
372
- vars_float : np.array
378
+ vars_float: np.array
373
379
  The float variable values of the final
374
380
  generation, shape: (n_pop, n_vars_float)
375
- problem_results : Any
381
+ problem_results: Any
376
382
  The results of the variable application
377
383
  to the problem
378
- verbosity : int
384
+ verbosity: int
379
385
  The verbosity level, 0 = silent
380
386
 
381
387
  Returns
382
388
  -------
383
- values : np.array
389
+ values: np.array
384
390
  The component values, shape: (n_pop, n_components)
385
391
 
386
392
  """
@@ -407,18 +413,18 @@ class OptFunctionList(OptFunction):
407
413
 
408
414
  Parameters
409
415
  ----------
410
- vars_int : np.array
416
+ vars_int: np.array
411
417
  The integer variable values, shape: (n_vars_int,)
412
- vars_float : np.array
418
+ vars_float: np.array
413
419
  The float variable values, shape: (n_vars_float,)
414
- var : int
420
+ var: int
415
421
  The index of the differentiation float variable
416
- components : list of int
422
+ components: list of int
417
423
  The selected components, or None for all
418
424
 
419
425
  Returns
420
426
  -------
421
- deriv : numpy.ndarray
427
+ deriv: numpy.ndarray
422
428
  The derivative values, shape: (n_sel_components,)
423
429
 
424
430
  """
@@ -8,26 +8,31 @@ class OptFunctionSubset(OptFunction):
8
8
  A function composed of a subset of a function's
9
9
  components.
10
10
 
11
- Parameters
12
- ----------
13
- function: iwopy.OptFunction
14
- The original function
15
- subset : list of int
16
- The component choice
17
- name: str, optional
18
- The function name
19
-
20
11
  Attributes
21
12
  ----------
22
13
  func_org: iwopy.OptFunction
23
14
  The original function
24
- subset : list of int
15
+ subset: list of int
25
16
  The component choice
26
17
 
18
+ :group: core
19
+
27
20
  """
28
21
 
29
22
  def __init__(self, function, subset, name=None):
23
+ """
24
+ Constructor
30
25
 
26
+ Parameters
27
+ ----------
28
+ function: iwopy.OptFunction
29
+ The original function
30
+ subset: list of int
31
+ The component choice
32
+ name: str, optional
33
+ The function name
34
+
35
+ """
31
36
  if name is None:
32
37
  name = f"{function.name}[" + ",".join([str(i) for i in subset]) + "]"
33
38
  super().__init__(function.problem, name)
@@ -41,7 +46,7 @@ class OptFunctionSubset(OptFunction):
41
46
 
42
47
  Parameters
43
48
  ----------
44
- verbosity : int
49
+ verbosity: int
45
50
  The verbosity level, 0 = silent
46
51
 
47
52
  """
@@ -64,7 +69,7 @@ class OptFunctionSubset(OptFunction):
64
69
 
65
70
  Returns
66
71
  -------
67
- deps : numpy.ndarray of bool
72
+ deps: numpy.ndarray of bool
68
73
  The dependencies of components on function
69
74
  variables, shape: (n_components, n_vars_int)
70
75
 
@@ -78,7 +83,7 @@ class OptFunctionSubset(OptFunction):
78
83
 
79
84
  Returns
80
85
  -------
81
- deps : numpy.ndarray of bool
86
+ deps: numpy.ndarray of bool
82
87
  The dependencies of components on function
83
88
  variables, shape: (n_components, n_vars_float)
84
89
 
@@ -105,19 +110,19 @@ class OptFunctionSubset(OptFunction):
105
110
 
106
111
  Parameters
107
112
  ----------
108
- vars_int : np.array
113
+ vars_int: np.array
109
114
  The integer variable values, shape: (n_vars_int,)
110
- vars_float : np.array
115
+ vars_float: np.array
111
116
  The float variable values, shape: (n_vars_float,)
112
- problem_results : Any
117
+ problem_results: Any
113
118
  The results of the variable application
114
119
  to the problem
115
- components : list of int, optional
120
+ components: list of int, optional
116
121
  The selected components or None for all
117
122
 
118
123
  Returns
119
124
  -------
120
- values : np.array
125
+ values: np.array
121
126
  The component values, shape: (n_sel_components,)
122
127
 
123
128
  """
@@ -134,19 +139,19 @@ class OptFunctionSubset(OptFunction):
134
139
 
135
140
  Parameters
136
141
  ----------
137
- vars_int : np.array
142
+ vars_int: np.array
138
143
  The integer variable values, shape: (n_pop, n_vars_int)
139
- vars_float : np.array
144
+ vars_float: np.array
140
145
  The float variable values, shape: (n_pop, n_vars_float)
141
- problem_results : Any
146
+ problem_results: Any
142
147
  The results of the variable application
143
148
  to the problem
144
- components : list of int, optional
149
+ components: list of int, optional
145
150
  The selected components or None for all
146
151
 
147
152
  Returns
148
153
  -------
149
- values : np.array
154
+ values: np.array
150
155
  The component values, shape: (n_pop, n_sel_components,)
151
156
 
152
157
  """
@@ -165,18 +170,18 @@ class OptFunctionSubset(OptFunction):
165
170
 
166
171
  Parameters
167
172
  ----------
168
- vars_int : np.array
173
+ vars_int: np.array
169
174
  The integer variable values, shape: (n_vars_int,)
170
- vars_float : np.array
175
+ vars_float: np.array
171
176
  The float variable values, shape: (n_vars_float,)
172
- var : int
177
+ var: int
173
178
  The index of the differentiation float variable
174
- components : list of int
179
+ components: list of int
175
180
  The selected components, or None for all
176
181
 
177
182
  Returns
178
183
  -------
179
- deriv : numpy.ndarray
184
+ deriv: numpy.ndarray
180
185
  The derivative values, shape: (n_sel_components,)
181
186
 
182
187
  """
iwopy/core/memory.py CHANGED
@@ -7,7 +7,7 @@ def get_default_keyf(digits=12):
7
7
 
8
8
  Parameters
9
9
  ----------
10
- digits : int
10
+ digits: int
11
11
  The number of digits for floats
12
12
 
13
13
  Returns
@@ -15,6 +15,8 @@ def get_default_keyf(digits=12):
15
15
  Function :
16
16
  The default key function
17
17
 
18
+ :group: core
19
+
18
20
  """
19
21
 
20
22
  def default_key(vars_int, vars_float):
@@ -23,9 +25,9 @@ def get_default_keyf(digits=12):
23
25
 
24
26
  Parameters
25
27
  ----------
26
- vars_int : np.array
28
+ vars_int: np.array
27
29
  The integer variable values, shape: (n_vars_int,)
28
- vars_float : np.array
30
+ vars_float: np.array
29
31
  The float variable values, shape: (n_vars_float,)
30
32
 
31
33
  Returns
@@ -45,28 +47,34 @@ class Memory:
45
47
  """
46
48
  Storage for function results.
47
49
 
48
- Parameters
49
- ----------
50
- size : int
51
- The number of maximally stored results
52
- keyf : Function, optional
53
- The memory key function. Parameters:
54
- (vars_int, vars_float), returns key Object
55
-
56
50
  Attributes
57
51
  ----------
58
- max_size : int
52
+ max_size: int
59
53
  The number of maximally stored results
60
- data : dict
54
+ data: dict
61
55
  The stored data. Key: keyf return type,
62
56
  Values: tuples (objs, cons)
63
- keyf : Function
57
+ keyf: Function
64
58
  The memory key function. Parameters:
65
59
  (vars_int, vars_float), returns key Object
66
60
 
61
+ :group: core
62
+
67
63
  """
68
64
 
69
65
  def __init__(self, size, keyf=None):
66
+ """
67
+ Constructor
68
+
69
+ Parameters
70
+ ----------
71
+ size: int
72
+ The number of maximally stored results
73
+ keyf: Function, optional
74
+ The memory key function. Parameters:
75
+ (vars_int, vars_float), returns key Object
76
+
77
+ """
70
78
  self.max_size = size
71
79
  self.keyf = keyf if keyf is not None else get_default_keyf()
72
80
  self.data = {}
@@ -98,14 +106,14 @@ class Memory:
98
106
 
99
107
  Parameters
100
108
  ----------
101
- vars_int : np.array
109
+ vars_int: np.array
102
110
  The integer variable values, shape: (n_vars_int,)
103
- vars_float : np.array
111
+ vars_float: np.array
104
112
  The float variable values, shape: (n_vars_float,)
105
113
 
106
114
  Returns
107
115
  -------
108
- found : bool
116
+ found: bool
109
117
  True if data is available
110
118
 
111
119
  """
@@ -118,14 +126,14 @@ class Memory:
118
126
 
119
127
  Parameters
120
128
  ----------
121
- vars_int : np.array
129
+ vars_int: np.array
122
130
  The integer variable values, shape: (n_pop, n_vars_int)
123
- vars_float : np.array
131
+ vars_float: np.array
124
132
  The float variable values, shape: (n_pop, n_vars_float)
125
133
 
126
134
  Returns
127
135
  -------
128
- found : numpy.ndarray of bool
136
+ found: numpy.ndarray of bool
129
137
  True if data is available, shape: (n_pop,)
130
138
 
131
139
  """
@@ -141,13 +149,13 @@ class Memory:
141
149
 
142
150
  Parameters
143
151
  ----------
144
- vars_int : np.array
152
+ vars_int: np.array
145
153
  The integer variable values, shape: (n_vars_int,)
146
- vars_float : np.array
154
+ vars_float: np.array
147
155
  The float variable values, shape: (n_vars_float,)
148
- objs : np.array
156
+ objs: np.array
149
157
  The objective function values, shape: (n_objectives,)
150
- con : np.array
158
+ con: np.array
151
159
  The constraints values, shape: (n_constraints,)
152
160
 
153
161
  """
@@ -163,13 +171,13 @@ class Memory:
163
171
 
164
172
  Parameters
165
173
  ----------
166
- vars_int : np.array
174
+ vars_int: np.array
167
175
  The integer variable values, shape: (n_pop, n_vars_int)
168
- vars_float : np.array
176
+ vars_float: np.array
169
177
  The float variable values, shape: (n_pop, n_vars_float)
170
- objs : np.array
178
+ objs: np.array
171
179
  The objective function values, shape: (n_pop, n_objectives)
172
- con : np.array
180
+ con: np.array
173
181
  The constraints values, shape: (n_pop, n_constraints)
174
182
 
175
183
  """
@@ -182,14 +190,14 @@ class Memory:
182
190
 
183
191
  Parameters
184
192
  ----------
185
- vars_int : np.array
193
+ vars_int: np.array
186
194
  The integer variable values, shape: (n_vars_int,)
187
- vars_float : np.array
195
+ vars_float: np.array
188
196
  The float variable values, shape: (n_vars_float,)
189
197
 
190
198
  Returns
191
199
  -------
192
- results : tuple or None
200
+ results: tuple or None
193
201
  The results (objs, cons) if found, None otherwise
194
202
 
195
203
  """
@@ -205,17 +213,17 @@ class Memory:
205
213
 
206
214
  Parameters
207
215
  ----------
208
- vars_int : np.array
216
+ vars_int: np.array
209
217
  The integer variable values, shape: (n_pop, n_vars_int)
210
- vars_float : np.array
218
+ vars_float: np.array
211
219
  The float variable values, shape: (n_pop, n_vars_float)
212
- target : numpy.ndarray, optional
220
+ target: numpy.ndarray, optional
213
221
  The results array to write to, shape:
214
222
  (n_pop, n_objs_cmpnts + n_cons_cmpnts)
215
223
 
216
224
  Returns
217
225
  -------
218
- results : numpy.ndarray or None
226
+ results: numpy.ndarray or None
219
227
  None if no results at all found, otherwise array
220
228
  with shape: (n_pop, n_objs_cmpnts + n_cons_cmpnts)
221
229
 
iwopy/core/objective.py CHANGED
@@ -6,6 +6,9 @@ from .function import OptFunction
6
6
  class Objective(OptFunction):
7
7
  """
8
8
  Abstract base class for objective functions.
9
+
10
+ :group: core
11
+
9
12
  """
10
13
 
11
14
  @abstractmethod
@@ -15,7 +18,7 @@ class Objective(OptFunction):
15
18
 
16
19
  Returns
17
20
  -------
18
- flags : np.array
21
+ flags: np.array
19
22
  Bool array for component maximization,
20
23
  shape: (n_components,)
21
24