iwopy 0.1.8__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 +12 -2
  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 +107 -101
  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.8.dist-info → iwopy-0.2.dist-info}/METADATA +27 -4
  38. iwopy-0.2.dist-info/RECORD +50 -0
  39. iwopy-0.1.8.dist-info/RECORD +0 -48
  40. {iwopy-0.1.8.dist-info → iwopy-0.2.dist-info}/LICENSE +0 -0
  41. {iwopy-0.1.8.dist-info → iwopy-0.2.dist-info}/WHEEL +0 -0
  42. {iwopy-0.1.8.dist-info → iwopy-0.2.dist-info}/top_level.txt +0 -0
  43. {iwopy-0.1.8.dist-info → iwopy-0.2.dist-info}/zip-safe +0 -0
@@ -7,39 +7,24 @@ class RegularDiscretizationGrid:
7
7
  A lightweight regular grid in n dimensions,
8
8
  without points storage.
9
9
 
10
- Parameters
11
- ----------
12
- origin : array-like
13
- The origin point, len: n_dims
14
- deltas : array-like
15
- The step sizes, len: n_dims.
16
- n_steps : array-like
17
- The number of steps, len: n_dims. Use
18
- INT_INF for infinite.
19
- interpolation : str
20
- The interpolation method: None, nearest, linear
21
- tol : list of float, optional
22
- The tolerances for grid bounds, default is 0,
23
- shape: (n_dims,)
24
- digits : int
25
- The grid point precision
26
-
27
10
  Attributes
28
11
  ----------
29
- origin : numpy.ndarray
12
+ origin: numpy.ndarray
30
13
  The origin point, shape: (n_dims,)
31
- deltas : numpy.ndarray
14
+ deltas: numpy.ndarray
32
15
  The step sizes, shape: (n_dims,)
33
- n_steps : numpy.ndarray
16
+ n_steps: numpy.ndarray
34
17
  The number of steps, shape: (n_dims,)
35
- interpolation : str
18
+ interpolation: str
36
19
  The interpolation method: None, nearest, linear
37
- tol : numpy.ndarray
20
+ tol: numpy.ndarray
38
21
  The tolerances for grid bounds, shape: (n_dims,),
39
22
  or None
40
- digits : int
23
+ digits: int
41
24
  The grid point precision
42
25
 
26
+ :group: utils
27
+
43
28
  """
44
29
 
45
30
  INT_INF = -999999
@@ -53,6 +38,27 @@ class RegularDiscretizationGrid:
53
38
  tol=None,
54
39
  digits=12,
55
40
  ):
41
+ """
42
+ Constructor
43
+
44
+ Parameters
45
+ ----------
46
+ origin: array-like
47
+ The origin point, len: n_dims
48
+ deltas: array-like
49
+ The step sizes, len: n_dims.
50
+ n_steps: array-like
51
+ The number of steps, len: n_dims. Use
52
+ INT_INF for infinite.
53
+ interpolation: str
54
+ The interpolation method: None, nearest, linear
55
+ tol: list of float, optional
56
+ The tolerances for grid bounds, default is 0,
57
+ shape: (n_dims,)
58
+ digits: int
59
+ The grid point precision
60
+
61
+ """
56
62
 
57
63
  self.origin = np.array(origin, dtype=np.float64)
58
64
  self.n_steps = np.array(n_steps, dtype=np.int32)
@@ -135,7 +141,7 @@ class RegularDiscretizationGrid:
135
141
 
136
142
  Parameters
137
143
  ----------
138
- spaces : int
144
+ spaces: int
139
145
  The prepending spaces
140
146
 
141
147
  """
@@ -213,7 +219,7 @@ class RegularDiscretizationGrid:
213
219
 
214
220
  Parameters
215
221
  ----------
216
- inds : int
222
+ inds: int
217
223
  The grid point indices, shape: (n_dims,)
218
224
 
219
225
  Returns
@@ -232,15 +238,15 @@ class RegularDiscretizationGrid:
232
238
 
233
239
  Parameters
234
240
  ----------
235
- inds : int
241
+ inds: int
236
242
  The grid point indices, shape: (n_dims,)
237
- error : bool
243
+ error: bool
238
244
  Flag for throwing error if off-grid, else
239
245
  return None in that case
240
246
 
241
247
  Returns
242
248
  -------
243
- gp : numpy.ndarray
249
+ gp: numpy.ndarray
244
250
  The grid point, shape: (n_dims,)
245
251
 
246
252
  """
@@ -257,13 +263,13 @@ class RegularDiscretizationGrid:
257
263
 
258
264
  Parameters
259
265
  ----------
260
- inds : numpy.ndarray
266
+ inds: numpy.ndarray
261
267
  The grid point index candidates,
262
268
  shape: (n_inds, n_dims)
263
269
 
264
270
  Returns
265
271
  -------
266
- sel_grid : numpy.ndarray of bool
272
+ sel_grid: numpy.ndarray of bool
267
273
  Subset selection of on-grid indices,
268
274
  shape: (n_inds, n_dims)
269
275
 
@@ -278,13 +284,13 @@ class RegularDiscretizationGrid:
278
284
 
279
285
  Parameters
280
286
  ----------
281
- inds : array-like
287
+ inds: array-like
282
288
  The integer grid point indices, shape:
283
289
  (n_gpts, dims)
284
290
 
285
291
  Returns
286
292
  -------
287
- gpts : numpy.ndarray
293
+ gpts: numpy.ndarray
288
294
  The grid points, shape: (n_gpts, n_dims)
289
295
 
290
296
  """
@@ -342,12 +348,12 @@ class RegularDiscretizationGrid:
342
348
 
343
349
  Parameters
344
350
  ----------
345
- p : numpy.ndarray
351
+ p: numpy.ndarray
346
352
  The point, shape: (n_dims,)
347
353
 
348
354
  Returns
349
355
  -------
350
- q : numpy.ndarray
356
+ q: numpy.ndarray
351
357
  The corrected point, shape: (n_dims,)
352
358
 
353
359
  """
@@ -372,12 +378,12 @@ class RegularDiscretizationGrid:
372
378
 
373
379
  Parameters
374
380
  ----------
375
- pts : numpy.ndarray
381
+ pts: numpy.ndarray
376
382
  The points, shape: (n_pts, n_dims)
377
383
 
378
384
  Returns
379
385
  -------
380
- q : numpy.ndarray
386
+ q: numpy.ndarray
381
387
  The corrected points, shape: (n_pts, n_dims)
382
388
 
383
389
  """
@@ -408,19 +414,19 @@ class RegularDiscretizationGrid:
408
414
 
409
415
  Parameters
410
416
  ----------
411
- p : numpy.ndarray
417
+ p: numpy.ndarray
412
418
  The point, shape: (n_dims,)
413
- allow_outer : bool
419
+ allow_outer: bool
414
420
  Allow outermost point indices, else
415
421
  reduce those to lower-left cell corner
416
- ret_inds : bool
422
+ ret_inds: bool
417
423
  Additionally return indices
418
424
 
419
425
  Returns
420
426
  -------
421
427
  bool :
422
428
  True if on grid
423
- inds : numpy.ndarray, optional
429
+ inds: numpy.ndarray, optional
424
430
  The grid point indices, shape: (n_dims,)
425
431
 
426
432
  """
@@ -443,20 +449,20 @@ class RegularDiscretizationGrid:
443
449
 
444
450
  Parameters
445
451
  ----------
446
- pts : numpy.ndarray
452
+ pts: numpy.ndarray
447
453
  The points, shape: (n_pts, n_dims)
448
- allow_outer : bool
454
+ allow_outer: bool
449
455
  Allow outermost point indices, else
450
456
  reduce those to lower-left cell corner
451
- ret_inds : bool
457
+ ret_inds: bool
452
458
  Additionally return indices
453
459
 
454
460
  Returns
455
461
  -------
456
- sel_grid : numpy.ndarray of bool
462
+ sel_grid: numpy.ndarray of bool
457
463
  Subset selection of points that are on grid,
458
464
  shape: (n_pts, n_dims)
459
- inds : numpy.ndarray, optional
465
+ inds: numpy.ndarray, optional
460
466
  The grid point indices, shape: (n_gpts, n_dims)
461
467
 
462
468
  """
@@ -482,9 +488,9 @@ class RegularDiscretizationGrid:
482
488
 
483
489
  Parameters
484
490
  ----------
485
- pts : numpy.ndarray
491
+ pts: numpy.ndarray
486
492
  The points space, shape: (n_pts, n_dims)
487
- allow_outer : bool
493
+ allow_outer: bool
488
494
  Allow outermost point indices, else
489
495
  reduce those to lower-left cell corner
490
496
 
@@ -503,7 +509,7 @@ class RegularDiscretizationGrid:
503
509
 
504
510
  Parameters
505
511
  ----------
506
- p : numpy.ndarray
512
+ p: numpy.ndarray
507
513
  The point, shape: (n_dims,)
508
514
 
509
515
  Returns
@@ -521,12 +527,12 @@ class RegularDiscretizationGrid:
521
527
 
522
528
  Parameters
523
529
  ----------
524
- pts : numpy.ndarray
530
+ pts: numpy.ndarray
525
531
  The points, shape: (n_pts, n_dims)
526
532
 
527
533
  Returns
528
534
  -------
529
- sel_grid : numpy.ndarray of bool
535
+ sel_grid: numpy.ndarray of bool
530
536
  Subset selection of points that are in grid,
531
537
  shape: (n_pts, n_dims)
532
538
 
@@ -540,18 +546,18 @@ class RegularDiscretizationGrid:
540
546
 
541
547
  Parameters
542
548
  ----------
543
- gp : numpy.ndarray
549
+ gp: numpy.ndarray
544
550
  The point, shape: (n_dims,)
545
- allow_outer : bool
551
+ allow_outer: bool
546
552
  Allow outermost point indices, else
547
553
  reduce those to lower-left cell corner
548
- error : bool
554
+ error: bool
549
555
  Flag for throwing error if off-grid, else
550
556
  return None in that case
551
557
 
552
558
  Returns
553
559
  -------
554
- inds : numpy.ndarray
560
+ inds: numpy.ndarray
555
561
  The lower-left grid corner point indices, shape: (n_dims,)
556
562
 
557
563
  """
@@ -577,18 +583,18 @@ class RegularDiscretizationGrid:
577
583
 
578
584
  Parameters
579
585
  ----------
580
- gpts : numpy.ndarray
586
+ gpts: numpy.ndarray
581
587
  The grid points, shape: (n_gpts, n_dims)
582
- allow_outer : bool
588
+ allow_outer: bool
583
589
  Allow outermost point indices, else
584
590
  reduce those to lower-left cell corner
585
- error : bool
591
+ error: bool
586
592
  Flag for throwing error if off-grid, else
587
593
  return None in that case
588
594
 
589
595
  Returns
590
596
  -------
591
- inds : numpy.ndarray
597
+ inds: numpy.ndarray
592
598
  The lower-left grid corner indices,
593
599
  shape: (n_gpts, n_dims)
594
600
 
@@ -612,15 +618,15 @@ class RegularDiscretizationGrid:
612
618
 
613
619
  Parameters
614
620
  ----------
615
- p : numpy.ndarray
621
+ p: numpy.ndarray
616
622
  The point, shape: (n_dims,)
617
- allow_outer : bool
623
+ allow_outer: bool
618
624
  Allow outermost point indices, else
619
625
  reduce those to lower-left cell corner
620
626
 
621
627
  Returns
622
628
  -------
623
- p0 : numpy.ndarray
629
+ p0: numpy.ndarray
624
630
  The lower-left grid corner point, shape: (n_dims,)
625
631
 
626
632
  """
@@ -643,15 +649,15 @@ class RegularDiscretizationGrid:
643
649
 
644
650
  Parameters
645
651
  ----------
646
- pts : numpy.ndarray
652
+ pts: numpy.ndarray
647
653
  The points space, shape: (n_pts, n_dims)
648
- allow_outer : bool
654
+ allow_outer: bool
649
655
  Allow outermost point indices, else
650
656
  reduce those to lower-left cell corner
651
657
 
652
658
  Returns
653
659
  -------
654
- p0 : numpy.ndarray
660
+ p0: numpy.ndarray
655
661
  The lower-left grid corner points, shape: (n_pts, n_dims)
656
662
 
657
663
  """
@@ -685,12 +691,12 @@ class RegularDiscretizationGrid:
685
691
 
686
692
  Parameters
687
693
  ----------
688
- p : numpy.ndarray
694
+ p: numpy.ndarray
689
695
  The point, shape: (n_dims,)
690
696
 
691
697
  Returns
692
698
  -------
693
- cell : numpy.ndarray
699
+ cell: numpy.ndarray
694
700
  The min and max values of each dimension. Shape:
695
701
  (n_dims, 2)
696
702
 
@@ -707,12 +713,12 @@ class RegularDiscretizationGrid:
707
713
 
708
714
  Parameters
709
715
  ----------
710
- pts : numpy.ndarray
716
+ pts: numpy.ndarray
711
717
  The points, shape: (n_pts, n_dims)
712
718
 
713
719
  Returns
714
720
  -------
715
- cells : numpy.ndarray
721
+ cells: numpy.ndarray
716
722
  The min and max values of each dimension. Shape:
717
723
  (n_pts, n_dims, 2)
718
724
 
@@ -752,7 +758,7 @@ class RegularDiscretizationGrid:
752
758
  ).all(), f"Found coordinates above 1: {qts[np.any(qts>1., axis=-1)].tolist()}"
753
759
 
754
760
  opts = self._get_opts()
755
- return np.product(1 - np.abs(qts[:, None] - opts[None, :]), axis=-1)
761
+ return np.prod(1 - np.abs(qts[:, None] - opts[None, :]), axis=-1)
756
762
 
757
763
  def interpolation_coeffs_point(self, p):
758
764
  """
@@ -769,15 +775,15 @@ class RegularDiscretizationGrid:
769
775
 
770
776
  Parameters
771
777
  ----------
772
- p : numpy.ndarray
778
+ p: numpy.ndarray
773
779
  The point, shape: (n_dims,)
774
780
 
775
781
  Returns
776
782
  -------
777
- gpts : numpy.ndarray
783
+ gpts: numpy.ndarray
778
784
  The grid points relevant for coeffs,
779
785
  shape: (n_gpts, n_dims)
780
- coeffs : numpy.ndarray
786
+ coeffs: numpy.ndarray
781
787
  The interpolation coefficients, shape: (n_gpts,)
782
788
 
783
789
  """
@@ -833,21 +839,21 @@ class RegularDiscretizationGrid:
833
839
 
834
840
  Parameters
835
841
  ----------
836
- pts : numpy.ndarray
842
+ pts: numpy.ndarray
837
843
  The points, shape: (n_pts, n_dims)
838
- ret_pmap : bool
844
+ ret_pmap: bool
839
845
  Additionally return the map from pts to
840
846
  gpts
841
847
 
842
848
  Returns
843
849
  -------
844
- gpts : numpy.ndarray
850
+ gpts: numpy.ndarray
845
851
  The grid points relevant for coeffs,
846
852
  shape: (n_gpts, n_dims)
847
- coeffs : numpy.ndarray
853
+ coeffs: numpy.ndarray
848
854
  The interpolation coefficients, shape:
849
855
  (n_pts, n_gpts)
850
- pmap : numpy.ndarray, optional
856
+ pmap: numpy.ndarray, optional
851
857
  The map from pts to gpts, shape: (n_pts, n_gp)
852
858
 
853
859
  """
@@ -916,24 +922,24 @@ class RegularDiscretizationGrid:
916
922
 
917
923
  Parameters
918
924
  ----------
919
- inds : numpy.ndarray
925
+ inds: numpy.ndarray
920
926
  The integer grid point indices, shape:
921
927
  (n_inds, n_dims)
922
- var : int
928
+ var: int
923
929
  The dimension representing the variable
924
930
  wrt which to differentiate
925
- order : int
931
+ order: int
926
932
  The finite difference order,
927
933
  1 = forward, -1 = backward, 2 = centre
928
- orderb : int
934
+ orderb: int
929
935
  The finite difference order at boundary points
930
936
 
931
937
  Returns
932
938
  -------
933
- gpts : numpy.ndarray
939
+ gpts: numpy.ndarray
934
940
  The grid points relevant for coeffs,
935
941
  shape: (n_gpts, n_dims)
936
- coeffs : numpy.ndarray
942
+ coeffs: numpy.ndarray
937
943
  The gradient coefficients, shape:
938
944
  (n_inds, n_gpts)
939
945
 
@@ -1072,23 +1078,23 @@ class RegularDiscretizationGrid:
1072
1078
 
1073
1079
  Parameters
1074
1080
  ----------
1075
- pts : numpy.ndarray
1081
+ pts: numpy.ndarray
1076
1082
  The evaluation points, shape: (n_pts, n_dims)
1077
- var : int
1083
+ var: int
1078
1084
  The dimension representing the variable
1079
1085
  wrt which to differentiate
1080
- order : int
1086
+ order: int
1081
1087
  The finite difference order,
1082
1088
  1 = forward, -1 = backward, 2 = centre
1083
- orderb : int
1089
+ orderb: int
1084
1090
  The finite difference order at boundary points
1085
1091
 
1086
1092
  Returns
1087
1093
  -------
1088
- gpts : numpy.ndarray
1094
+ gpts: numpy.ndarray
1089
1095
  The grid points relevant for coeffs,
1090
1096
  shape: (n_gpts, n_dims)
1091
- coeffs : numpy.ndarray
1097
+ coeffs: numpy.ndarray
1092
1098
  The gradient coefficients, shape:
1093
1099
  (n_pts, n_gpts)
1094
1100
 
@@ -1113,25 +1119,25 @@ class RegularDiscretizationGrid:
1113
1119
 
1114
1120
  Parameters
1115
1121
  ----------
1116
- inds : numpy.ndarray
1122
+ inds: numpy.ndarray
1117
1123
  The integer grid point indices, shape:
1118
1124
  (n_inds, n_dims)
1119
- vars : list of int, optional
1125
+ vars: list of int, optional
1120
1126
  The dimensions representing the variables
1121
1127
  wrt which to differentiate, shape: (n_vars,).
1122
1128
  Default is all dimensions
1123
- order : int or list of int
1129
+ order: int or list of int
1124
1130
  The finite difference order,
1125
1131
  1 = forward, -1 = backward, 2 = centre
1126
- orderb : int list of int
1132
+ orderb: int list of int
1127
1133
  The finite difference order at boundary points
1128
1134
 
1129
1135
  Returns
1130
1136
  -------
1131
- gpts : numpy.ndarray
1137
+ gpts: numpy.ndarray
1132
1138
  The grid points relevant for coeffs,
1133
1139
  shape: (n_gpts, n_dims)
1134
- coeffs : numpy.ndarray
1140
+ coeffs: numpy.ndarray
1135
1141
  The gradient coefficients,
1136
1142
  shape: (n_inds, n_vars, n_gpts)
1137
1143
 
@@ -1178,24 +1184,24 @@ class RegularDiscretizationGrid:
1178
1184
 
1179
1185
  Parameters
1180
1186
  ----------
1181
- pts : numpy.ndarray
1187
+ pts: numpy.ndarray
1182
1188
  The evaluation points, shape: (n_pts, n_dims)
1183
- vars : list of int, optional
1189
+ vars: list of int, optional
1184
1190
  The dimensions representing the variables
1185
1191
  wrt which to differentiate, shape: (n_vars,).
1186
1192
  Default is all dimensions
1187
- order : int list of int
1193
+ order: int list of int
1188
1194
  The finite difference order,
1189
1195
  1 = forward, -1 = backward, 2 = centre
1190
- orderb : int list of int
1196
+ orderb: int list of int
1191
1197
  The finite difference order at boundary points
1192
1198
 
1193
1199
  Returns
1194
1200
  -------
1195
- gpts : numpy.ndarray
1201
+ gpts: numpy.ndarray
1196
1202
  The grid points relevant for coeffs,
1197
1203
  shape: (n_gpts, n_dims)
1198
- coeffs : numpy.ndarray
1204
+ coeffs: numpy.ndarray
1199
1205
  The gradient coefficients,
1200
1206
  shape: (n_pts, n_vars, n_gpts)
1201
1207
 
iwopy/utils/stdout.py CHANGED
@@ -21,6 +21,8 @@ def suppress_stdout(silent=True):
21
21
  silent: bool
22
22
  Flag for the silent treatment.
23
23
 
24
+ :group: utils
25
+
24
26
  """
25
27
  with open(os.devnull, "w") as devnull:
26
28
  if silent: