UQPyL 2.0.1__tar.gz → 2.0.2__tar.gz

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 (128) hide show
  1. UQPyL-2.0.2/PKG-INFO +96 -0
  2. UQPyL-2.0.2/README.md +78 -0
  3. UQPyL-2.0.2/UQPyL/DoE/__init__.py +8 -0
  4. UQPyL-2.0.1/UQPyL/DoE/fast_sampler.py → UQPyL-2.0.2/UQPyL/DoE/fast_sequence.py +4 -4
  5. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/DoE/full_fact.py +1 -1
  6. UQPyL-2.0.2/UQPyL/DoE/morris_sequence.py +81 -0
  7. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/DoE/random.py +1 -1
  8. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/DoE/sobol_sequence.py +17 -2
  9. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/optimization/__init__.py +5 -1
  10. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/optimization/_binary_ga.py +3 -0
  11. UQPyL-2.0.2/UQPyL/optimization/asmo.py +116 -0
  12. UQPyL-2.0.2/UQPyL/optimization/ga.py +190 -0
  13. UQPyL-2.0.2/UQPyL/optimization/mo_asmo.py +168 -0
  14. UQPyL-2.0.2/UQPyL/optimization/moea_d.py +241 -0
  15. UQPyL-2.0.2/UQPyL/optimization/nsga_ii.py +297 -0
  16. UQPyL-2.0.2/UQPyL/optimization/pso.py +162 -0
  17. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/optimization/sce_ua.py +79 -29
  18. UQPyL-2.0.2/UQPyL/optimization/utility_functions/_uniformPoint.py +53 -0
  19. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/problems/multi_DTLZ.py +11 -48
  20. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/problems/multi_ZDT.py +6 -31
  21. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/problems/pratical_problem.py +2 -6
  22. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/problems/problem_ABC.py +19 -8
  23. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/problems/single_Benchmarks.py +22 -75
  24. UQPyL-2.0.2/UQPyL/problems/utility_functions/_NDsort.py +34 -0
  25. UQPyL-2.0.2/UQPyL/problems/utility_functions/__init__.py +0 -0
  26. UQPyL-2.0.2/UQPyL/sensibility/delta_test.py +146 -0
  27. UQPyL-2.0.2/UQPyL/sensibility/fast.py +183 -0
  28. UQPyL-2.0.2/UQPyL/sensibility/mars_sa.py +124 -0
  29. UQPyL-2.0.2/UQPyL/sensibility/morris.py +183 -0
  30. UQPyL-2.0.2/UQPyL/sensibility/rbd_fast.py +142 -0
  31. UQPyL-2.0.2/UQPyL/sensibility/rsa.py +125 -0
  32. UQPyL-2.0.2/UQPyL/sensibility/sa_ABC.py +92 -0
  33. UQPyL-2.0.2/UQPyL/sensibility/sobol.py +245 -0
  34. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/__init__.py +3 -4
  35. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/gaussian_process.py +10 -7
  36. UQPyL-2.0.2/UQPyL/surrogates/gp_kernels/__init__.py +16 -0
  37. UQPyL-2.0.2/UQPyL/surrogates/gp_kernels/base_kernel.py +20 -0
  38. UQPyL-2.0.2/UQPyL/surrogates/gp_kernels/c_kernel.py +23 -0
  39. UQPyL-2.0.2/UQPyL/surrogates/gp_kernels/dot_kernel.py +82 -0
  40. UQPyL-2.0.2/UQPyL/surrogates/gp_kernels/matern_kernel.py +119 -0
  41. UQPyL-2.0.2/UQPyL/surrogates/gp_kernels/rbf_kernel.py +93 -0
  42. UQPyL-2.0.2/UQPyL/surrogates/gp_kernels/rq_kernel.py +132 -0
  43. UQPyL-2.0.2/UQPyL/surrogates/krg_kernels/__init__.py +8 -0
  44. UQPyL-2.0.2/UQPyL/surrogates/krg_kernels/base_kernel.py +77 -0
  45. UQPyL-2.0.2/UQPyL/surrogates/krg_kernels/cubic_kernel.py +60 -0
  46. UQPyL-2.0.2/UQPyL/surrogates/krg_kernels/exp_kernel.py +58 -0
  47. UQPyL-2.0.2/UQPyL/surrogates/krg_kernels/guass_kernel.py +66 -0
  48. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/kriging.py +59 -42
  49. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/linear_regression.py +6 -6
  50. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars.py +1 -1
  51. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/_pruning.c +672 -648
  52. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/polynomial_regression.py +13 -13
  53. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/support_vector_machine.py +2 -2
  54. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/surrogate_ABC.py +39 -0
  55. UQPyL-2.0.2/UQPyL.egg-info/PKG-INFO +96 -0
  56. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL.egg-info/SOURCES.txt +18 -4
  57. {UQPyL-2.0.1 → UQPyL-2.0.2}/pyproject.toml +1 -1
  58. {UQPyL-2.0.1 → UQPyL-2.0.2}/setup.py +1 -1
  59. UQPyL-2.0.1/PKG-INFO +0 -64
  60. UQPyL-2.0.1/README.md +0 -46
  61. UQPyL-2.0.1/UQPyL/DoE/__init__.py +0 -8
  62. UQPyL-2.0.1/UQPyL/optimization/_ga.py +0 -120
  63. UQPyL-2.0.1/UQPyL/optimization/asmo.py +0 -86
  64. UQPyL-2.0.1/UQPyL/optimization/ga.py +0 -122
  65. UQPyL-2.0.1/UQPyL/optimization/mo_asmo.py +0 -115
  66. UQPyL-2.0.1/UQPyL/optimization/nsga_ii.py +0 -219
  67. UQPyL-2.0.1/UQPyL/sensibility/delta_test.py +0 -78
  68. UQPyL-2.0.1/UQPyL/sensibility/fast.py +0 -74
  69. UQPyL-2.0.1/UQPyL/sensibility/mars_sa.py +0 -60
  70. UQPyL-2.0.1/UQPyL/sensibility/morris.py +0 -88
  71. UQPyL-2.0.1/UQPyL/sensibility/rbd_fast.py +0 -59
  72. UQPyL-2.0.1/UQPyL/sensibility/rsa.py +0 -51
  73. UQPyL-2.0.1/UQPyL/sensibility/sa_ABC.py +0 -133
  74. UQPyL-2.0.1/UQPyL/sensibility/sobol.py +0 -141
  75. UQPyL-2.0.1/UQPyL/surrogates/gp_kernels/Kernel.py +0 -459
  76. UQPyL-2.0.1/UQPyL/surrogates/gp_kernels/__init__.py +0 -9
  77. UQPyL-2.0.1/UQPyL/surrogates/mo_surrogates.py +0 -35
  78. UQPyL-2.0.1/UQPyL.egg-info/PKG-INFO +0 -64
  79. {UQPyL-2.0.1 → UQPyL-2.0.2}/LICENSE.md +0 -0
  80. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/DoE/_lhs.py +0 -0
  81. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/DoE/lhs.py +0 -0
  82. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/DoE/sampler_ABC.py +0 -0
  83. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/__init__.py +0 -0
  84. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/optimization/adam.py +0 -0
  85. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/optimization/boxmin.py +0 -0
  86. {UQPyL-2.0.1/UQPyL/problems → UQPyL-2.0.2/UQPyL/optimization}/utility_functions/_NDsort.py +0 -0
  87. {UQPyL-2.0.1/UQPyL/problems → UQPyL-2.0.2/UQPyL/optimization}/utility_functions/__init__.py +0 -0
  88. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/problems/__init__.py +0 -0
  89. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/problems/utility_functions/_uniformPoint.py +0 -0
  90. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/sensibility/__init__.py +0 -0
  91. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/BaggingEnsemble.py +0 -0
  92. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/BootstrapEnsemble.py +0 -0
  93. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/fully_connect_neural_network.py +0 -0
  94. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/lasso_/__init__.py +0 -0
  95. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/lasso_/lasso_fast.c +0 -0
  96. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/__init__.py +0 -0
  97. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/_basis.c +0 -0
  98. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/_forward.c +0 -0
  99. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/_knot_search.c +0 -0
  100. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/_qr.c +0 -0
  101. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/_record.c +0 -0
  102. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/_types.c +0 -0
  103. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/_util.c +0 -0
  104. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mars_/pyearth/__init__.py +0 -0
  105. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mlp_utility/__init__.py +0 -0
  106. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mlp_utility/_activation_funcs.py +0 -0
  107. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/mlp_utility/base.py +0 -0
  108. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/radial_basis_function.py +0 -0
  109. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/rbf_kernels/__init__.py +0 -0
  110. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/rbf_kernels/base_kernel.py +0 -0
  111. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/rbf_kernels/cubic_kernel.py +0 -0
  112. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/rbf_kernels/gaussian_kernel.py +0 -0
  113. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/rbf_kernels/linear_kernel.py +0 -0
  114. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/rbf_kernels/multiquadric_kernel.py +0 -0
  115. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/rbf_kernels/thin_plate_spline_kernel.py +0 -0
  116. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/svr_/__init__.py +0 -0
  117. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/svr_/libsvm_interface.cpp +0 -0
  118. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/surrogates/svr_/svm.cpp +0 -0
  119. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/utility/__init__.py +0 -0
  120. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/utility/grid_search.py +0 -0
  121. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/utility/metrics.py +0 -0
  122. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/utility/model_selections.py +0 -0
  123. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/utility/polynomial_features.py +0 -0
  124. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL/utility/scalers.py +0 -0
  125. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL.egg-info/dependency_links.txt +0 -0
  126. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL.egg-info/requires.txt +0 -0
  127. {UQPyL-2.0.1 → UQPyL-2.0.2}/UQPyL.egg-info/top_level.txt +0 -0
  128. {UQPyL-2.0.1 → UQPyL-2.0.2}/setup.cfg +0 -0
UQPyL-2.0.2/PKG-INFO ADDED
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.1
2
+ Name: UQPyL
3
+ Version: 2.0.2
4
+ Summary: A python package for parameter uncertainty quantification and optimization
5
+ Author: wmtSky
6
+ Author-email: wmtSky <wmtsky@hhu.edu.cn>
7
+ Classifier: Programming Language :: Python :: 3.6
8
+ Classifier: Programming Language :: Python :: 3.7
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE.md
18
+
19
+ # Uncertainty Quantification Python Laboratory <br> (UQPyL)
20
+
21
+ **UQPyL:** The **Uncertainty Quantification Python Laboratory** provide comprehensive workflows tailored to the **Uncertainty Quantification** and **Optimization** for computational models and their associated applications (e.g. model calibration, resource scheduling, product design).
22
+
23
+ The **main characteristics** of UQPyL includes:
24
+
25
+ 1. Implementation of widely used sensitivity analysis methodologies and optimization algorithms.
26
+
27
+ 2. Integration of diverse surrogate models equipped with tunable to solving computational expensive problems.
28
+
29
+ 3. Provision of a comprehensive suite of benchmark problems and practical case studies, enabling users to quick start.
30
+
31
+ 4. A modular and extensible architecture that encourages and facilitates the development of novel methods or algorithms by users, aligning with our commitment to openness and collaboration. (**We appreciate and welcome contributions**)
32
+
33
+ **Website:** http://www.uq-pyl.com/ (**#TODO** it need to update now.) <br>
34
+ **Source Code:** https://github.com/smasky/UQPyL/ <br>
35
+ **Documentation:** **#TODO** <br>
36
+ **Citing in your work:** **#TODO** <br>
37
+
38
+ # Included Methods and Algorithms
39
+ **Sensibility Analysis:** (all methods support for surrogate models)
40
+ - Sobol'
41
+ - Delta_test (DT)
42
+ - extended Fourier Amplitude Sensitivity Test (eFAST)
43
+ - Random Balance Designs - Fourier Amplitude Sensitivity Test
44
+ - Multivariate Adaptive Regression Splines-Sensibility Analysis (MARS-SA)
45
+ - Morris
46
+ - Regional Sensitivity Analysis (RSA)
47
+
48
+ **Optimization Algorithms:** (* indicates the use of surrogate models)
49
+ - SCE-UA
50
+ - Genetic Algorithm (GA)
51
+ - Non-dominated Sorting Genetic Algorithm-II (NSGA-II)
52
+ - AMSMO*
53
+ - MO_ASMO*
54
+ - MASTO* #TODO
55
+ - AMSMO* #TODO
56
+
57
+ **Surrogate Models:**
58
+ - Full connect neural network (FNN)
59
+ - Kriging (KRG)
60
+ - Gaussian Process (GP)
61
+ - Linear Regression (LR)
62
+ - Polynomial Regression (PR)
63
+ - Radial Basis Function (RBF)
64
+ - Support Vector Machine (SVM)
65
+ - Multivariate Adaptive Regression Splines (MARS)
66
+
67
+ # Installation
68
+
69
+ Recommend (PyPi or Conda):
70
+
71
+ ```
72
+ pip install UQPyL
73
+
74
+ conda install UQPyL
75
+ ```
76
+
77
+ And also:
78
+
79
+ ```
80
+ git clone https://github.com/smasky/UQPyL.git
81
+ pip install .
82
+ ```
83
+
84
+
85
+ # Call for Contributions
86
+ We appreciate and welcome contributions. Because, we only set up standard workflows here. More advanced quantification methods and optimization algorithms are waited for pulling to this project.
87
+
88
+ ---
89
+ # Contact:
90
+
91
+ wmtSky, <wmtsky@hhu.edu.cn>
92
+
93
+
94
+
95
+
96
+
UQPyL-2.0.2/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Uncertainty Quantification Python Laboratory <br> (UQPyL)
2
+
3
+ **UQPyL:** The **Uncertainty Quantification Python Laboratory** provide comprehensive workflows tailored to the **Uncertainty Quantification** and **Optimization** for computational models and their associated applications (e.g. model calibration, resource scheduling, product design).
4
+
5
+ The **main characteristics** of UQPyL includes:
6
+
7
+ 1. Implementation of widely used sensitivity analysis methodologies and optimization algorithms.
8
+
9
+ 2. Integration of diverse surrogate models equipped with tunable to solving computational expensive problems.
10
+
11
+ 3. Provision of a comprehensive suite of benchmark problems and practical case studies, enabling users to quick start.
12
+
13
+ 4. A modular and extensible architecture that encourages and facilitates the development of novel methods or algorithms by users, aligning with our commitment to openness and collaboration. (**We appreciate and welcome contributions**)
14
+
15
+ **Website:** http://www.uq-pyl.com/ (**#TODO** it need to update now.) <br>
16
+ **Source Code:** https://github.com/smasky/UQPyL/ <br>
17
+ **Documentation:** **#TODO** <br>
18
+ **Citing in your work:** **#TODO** <br>
19
+
20
+ # Included Methods and Algorithms
21
+ **Sensibility Analysis:** (all methods support for surrogate models)
22
+ - Sobol'
23
+ - Delta_test (DT)
24
+ - extended Fourier Amplitude Sensitivity Test (eFAST)
25
+ - Random Balance Designs - Fourier Amplitude Sensitivity Test
26
+ - Multivariate Adaptive Regression Splines-Sensibility Analysis (MARS-SA)
27
+ - Morris
28
+ - Regional Sensitivity Analysis (RSA)
29
+
30
+ **Optimization Algorithms:** (* indicates the use of surrogate models)
31
+ - SCE-UA
32
+ - Genetic Algorithm (GA)
33
+ - Non-dominated Sorting Genetic Algorithm-II (NSGA-II)
34
+ - AMSMO*
35
+ - MO_ASMO*
36
+ - MASTO* #TODO
37
+ - AMSMO* #TODO
38
+
39
+ **Surrogate Models:**
40
+ - Full connect neural network (FNN)
41
+ - Kriging (KRG)
42
+ - Gaussian Process (GP)
43
+ - Linear Regression (LR)
44
+ - Polynomial Regression (PR)
45
+ - Radial Basis Function (RBF)
46
+ - Support Vector Machine (SVM)
47
+ - Multivariate Adaptive Regression Splines (MARS)
48
+
49
+ # Installation
50
+
51
+ Recommend (PyPi or Conda):
52
+
53
+ ```
54
+ pip install UQPyL
55
+
56
+ conda install UQPyL
57
+ ```
58
+
59
+ And also:
60
+
61
+ ```
62
+ git clone https://github.com/smasky/UQPyL.git
63
+ pip install .
64
+ ```
65
+
66
+
67
+ # Call for Contributions
68
+ We appreciate and welcome contributions. Because, we only set up standard workflows here. More advanced quantification methods and optimization algorithms are waited for pulling to this project.
69
+
70
+ ---
71
+ # Contact:
72
+
73
+ wmtSky, <wmtsky@hhu.edu.cn>
74
+
75
+
76
+
77
+
78
+
@@ -0,0 +1,8 @@
1
+ from .lhs import LHS
2
+ from .full_fact import FFD
3
+ from .random import Random
4
+ from .sampler_ABC import Sampler
5
+ from .sobol_sequence import Sobol_Sequence
6
+ from .fast_sequence import FAST_Sequence
7
+ from .morris_sequence import Morris_Sequence
8
+ __all__=['LHS', 'FFD', 'Random', 'Sobol_Sequence', 'Morris_Sequence','FAST_Sequence','Sampler']
@@ -2,7 +2,7 @@ import numpy as np
2
2
 
3
3
  from .sampler_ABC import Sampler
4
4
 
5
- class FAST_Sampler(Sampler):
5
+ class FAST_Sequence(Sampler):
6
6
  '''
7
7
  The sample technique for FAST(Fourier Amplitude Sensitivity Test) method
8
8
 
@@ -16,9 +16,9 @@ class FAST_Sampler(Sampler):
16
16
  __call__ or sample: Generate a sample for FAST method
17
17
 
18
18
  Examples:
19
- >>> fast=FAST_Sampler()
20
- >>> samples=fast(5, 4) or fast.sample(5,4)
21
-
19
+ >>> fast_seq=FAST_Sequence()
20
+ >>> samples=fast_seq(5, 4) or fast_seq.sample(5,4)
21
+
22
22
  '''
23
23
  def __init__(self, M: int=4):
24
24
 
@@ -30,7 +30,7 @@ class FFD(Sampler):
30
30
  if len(levels)!=nx:
31
31
  raise ValueError('The length of levels should be equal to nx or 1')
32
32
 
33
- factor_levels = [np.linspace(0, 1, num=level + 1)[:level] for level in levels]
33
+ factor_levels = [np.linspace(0, 1, num=level)[:level] for level in levels]
34
34
 
35
35
  factor_combinations = list(product(*factor_levels))
36
36
 
@@ -0,0 +1,81 @@
1
+ import numpy as np
2
+
3
+ from .sampler_ABC import Sampler
4
+
5
+ class Morris_Sequence(Sampler):
6
+ '''
7
+ The sample technique for Morris analysis
8
+
9
+ Parameters:
10
+ num_levels (p): each x_i would take value on {0, 1/(p-1), 2/(p-1), ..., 1}.
11
+ Morris et al[1]. recommend the num_levels to be even and range from 4 and 10.
12
+
13
+ Methods:
14
+ __call__ or sample: Generate a sample for FAST method
15
+
16
+ Examples:
17
+ >>> mor_seq=Morris_Sequence(num_levels=4)
18
+ >>> mor_seq.sample(100, 4) or mor_seq(100, 4)
19
+
20
+ Reference:
21
+ [1] Max D. Morris (1991) Factorial Sampling Plans for Preliminary Computational Experiments, Technometrics, 33:2, 161-174
22
+ '''
23
+ def __init__(self, num_levels: int=4):
24
+
25
+ super().__init__()
26
+ self.num_levels=num_levels
27
+
28
+ def _generate(self, nt: int, nx: int) -> np.ndarray:
29
+ '''
30
+ Generate a shape of (nt*nx, nx) sample for FAST
31
+
32
+ parameters:
33
+ nt: int
34
+ the number of trajectory
35
+ nx: int
36
+ the input dimensions of sampled points
37
+
38
+ Returns:
39
+ H: 2d-array
40
+ An n-by-samples design matrix that has been normalized so factor values
41
+ are uniformly spaced between zero and one.
42
+ '''
43
+ X=np.zeros((nt*(nx+1), nx))
44
+
45
+ for i in range(nt):
46
+ X[i*(nx+1):(i+1)*(nx+1), :]=self._generate_trajectory(nx)
47
+
48
+ return X
49
+
50
+ def _generate_trajectory(self, nx: int) -> np.ndarray:
51
+ '''
52
+
53
+ '''
54
+ delta=self.num_levels/(2*(self.num_levels-1))
55
+
56
+ B=np.tril(np.ones([nx + 1, nx], dtype=int), -1)
57
+
58
+ # from paper[1] page 164
59
+ D_star = np.diag(np.random.choice([-1, 1], nx)) #step1
60
+ J=np.ones((nx+1, nx))
61
+
62
+ levels_grids=np.linspace(0, 1-delta, int(self.num_levels / 2))
63
+ x_star=np.random.choice(levels_grids, nx).reshape(1,-1) #step2
64
+
65
+ P_star=np.zeros((nx,nx))
66
+ cols = np.random.choice(nx, nx, replace=False)
67
+ P_star[np.arange(nx), cols]=1 #step3
68
+
69
+ element_a = J[0, :] * x_star
70
+ element_b = P_star.T
71
+ element_c = np.matmul(2.0 * B, element_b)
72
+ element_d = np.matmul((element_c - J), D_star)
73
+
74
+ B_star = element_a + (delta / 2.0) * (element_d + J)
75
+
76
+ return B_star
77
+
78
+
79
+
80
+
81
+
@@ -2,7 +2,7 @@ import numpy as np
2
2
 
3
3
  from .sampler_ABC import Sampler
4
4
 
5
- class RANDOM(Sampler):
5
+ class Random(Sampler):
6
6
  '''
7
7
  Random Design
8
8
 
@@ -6,21 +6,36 @@ from .sampler_ABC import Sampler
6
6
  class Sobol_Sequence(Sampler):
7
7
  '''
8
8
  Sobol Sequence
9
+ ------------------------------------------------
10
+ Parameters:
11
+ scramble: bool default=True
12
+ the switch to scramble the sequence or not
13
+ skip_value: int default=0
14
+ the number of skipped points for Sobol sequence
9
15
 
10
16
  Methods:
11
17
  __call__ or sample: generate the shape of (nt*nx, nx) and numpy array Sobol sequence.
12
18
 
19
+ Examples:
20
+ >>> sobol_seq=Sobol_Sequence(skip_value=128)
21
+ >>> sobol_seq.sample(64, 4)
13
22
  '''
14
- def __init__(self):
23
+ def __init__(self, scramble: bool=True, skip_value: int=0):
15
24
 
16
25
  super().__init__()
26
+
27
+ self.scramble=scramble
28
+ self.skip_value=skip_value
17
29
 
18
30
  def _generate(self, nt: int, nx: int) -> np.ndarray:
19
31
  '''
20
32
  generate the shape of (nt*nx, nx) and numpy array Sobol sequence.
21
33
  '''
22
34
 
23
- return Sobol(d=nx).random(nt)
35
+ sampler=Sobol(d=nx, scramble=self.scramble)
36
+ X=sampler.random(nt+self.skip_value)
37
+
38
+ return X[self.skip_value:, :]
24
39
 
25
40
  def sample(self, nt: int, nx: int) -> np.ndarray:
26
41
  '''
@@ -4,8 +4,10 @@ from .adam import Adam
4
4
  from .sce_ua import SCE_UA
5
5
  from .asmo import ASMO
6
6
  from .nsga_ii import NSGAII
7
+ from .moea_d import MOEA_D
7
8
  from .mo_asmo import MOASMO
8
9
  from ._binary_ga import Binary_GA
10
+ from .pso import PSO
9
11
  __all__=[
10
12
  'GA',
11
13
  'Boxmin',
@@ -14,7 +16,9 @@ __all__=[
14
16
  'ASMO',
15
17
  'NSGAII',
16
18
  'MOASMO',
17
- 'Binary_GA'
19
+ 'MOEA_D',
20
+ 'Binary_GA',
21
+ 'PSO'
18
22
  ]
19
23
 
20
24
  MP_List=['Boxmin']
@@ -1,6 +1,9 @@
1
1
  import numpy as np
2
2
 
3
3
  class Binary_GA():
4
+ '''
5
+ Binary_GA for Delta Test
6
+ '''
4
7
  def __init__(self, evaluate, n_features, population_size=50, n_generations=100, crossover_rate=0.7, mutation_rate=0.01):
5
8
  self.population_size = population_size
6
9
  self.n_generations = n_generations
@@ -0,0 +1,116 @@
1
+ import numpy as np
2
+ from tqdm import tqdm
3
+ from typing import Optional
4
+
5
+ from .sce_ua import SCE_UA
6
+ from ..DoE import LHS
7
+ from ..problems import Problem
8
+ from ..surrogates import Surrogate
9
+
10
+ lhs=LHS('classic')
11
+ class ASMO():
12
+ '''
13
+ Adaptive Surrogate Modelling-based Optimization <Single> <Surrogate>
14
+ ----------------------------------------------
15
+ Attributes:
16
+ problem: Problem
17
+ the problem you want to solve, including the following attributes:
18
+ n_input: int
19
+ the input number of the problem
20
+ ub: 1d-np.ndarray or float
21
+ the upper bound of the problem
22
+ lb: 1d-np.ndarray or float
23
+ the lower bound of the problem
24
+ evaluate: Callable
25
+ the function to evaluate the input
26
+ surrogate: Surrogate
27
+ the surrogate model you want to use
28
+ n_init: int, default=50
29
+ Number of initial samples for surrogate modelling
30
+ '''
31
+ def __init__(self, problem: Problem, surrogate: Surrogate,
32
+ n_init: int=50, x_init: Optional[np.ndarray]=None, y_init: Optional[np.ndarray]=None,
33
+ maxFE: int=500, maxTolerateTime=50):
34
+ #base setting
35
+ self.evaluate=problem.evaluate
36
+ self.lb=problem.lb; self.ub=problem.ub
37
+ self.n_input=problem.n_input
38
+ self.maxFE=maxFE; self.maxTolerateTime=maxTolerateTime
39
+
40
+ #surrogate setting
41
+ self.surrogate=surrogate
42
+ self.n_init=n_init
43
+ self.x_init=x_init
44
+ self.y_init=y_init
45
+
46
+ #construct optimization problem to combine surrogate and algorithm
47
+ self.subProblem=Problem(self.surrogate.predict, self.n_input, 1, self.ub, self.lb)
48
+
49
+ def run(self,maxFE=1000, Tolerate=0.001, maxTolerateTime=50, oneStep=False):
50
+ '''
51
+ main procedure
52
+ '''
53
+ show_process=tqdm(total=maxFE)
54
+ FE=0
55
+ TT=0
56
+ n_input=self.n_input
57
+ lb=self.lb
58
+ ub=self.ub
59
+
60
+ if self.x_init is None:
61
+ self.x_init=(ub-lb)*lhs(self.n_init, n_input)+lb
62
+ if self.y_init is None:
63
+ self.y_init=self.evaluate(self.x_init)
64
+
65
+ XPop=self.x_init
66
+ YPop=self.y_init
67
+
68
+ fe=YPop.shape[0]
69
+ show_process.update(fe)
70
+ ###
71
+ idx=np.argsort(YPop, axis=0)
72
+ BestY=YPop[idx[0,0],0]
73
+ BestX=XPop[idx[0,0],:]
74
+ # history_BestY=[]; history_BestX=[]
75
+ # history_BestX.append(BestX)
76
+ # history_BestY.append(BestY)
77
+
78
+ if (oneStep==False):
79
+ while fe<self.maxFE and TT<self.maxTolerateTime:
80
+ show_process.update(1)
81
+ # Build surrogate model
82
+ self.surrogate.fit(XPop, YPop)
83
+ res=SCE_UA(self.subProblem).run()
84
+ BestX_SM=res['best_dec']
85
+
86
+ TempY=self.evaluate(BestX_SM)
87
+ FE+=1
88
+ XPop=np.vstack((XPop,BestX_SM))
89
+ YPop=np.vstack((YPop,TempY))
90
+
91
+ if TempY[0,0]<BestY:
92
+ BestY=np.copy(TempY)
93
+ BestX=np.copy(BestX_SM)
94
+ else:
95
+ self.surrogate.fit(XPop, YPop)
96
+ res=SCE_UA(self.subProblem).run()
97
+ BestX_SM=res['best_decs']
98
+
99
+ TempY=self.evaluate(BestX_SM)
100
+
101
+ fe+=1
102
+ XPop=np.vstack((XPop,BestX_SM))
103
+ YPop=np.vstack((YPop,TempY))
104
+
105
+ if TempY[0,0]<BestY:
106
+ BestY=np.copy(TempY)
107
+ BestX=np.copy(BestX_SM)
108
+
109
+ Result={'best_dec':BestX, 'best_obj':BestY, 'FE':fe}
110
+
111
+ return Result
112
+
113
+
114
+
115
+
116
+
@@ -0,0 +1,190 @@
1
+ import numpy as np
2
+ import math
3
+
4
+ from ..problems import Problem
5
+ from ..DoE import LHS
6
+ class GA():
7
+ '''
8
+ Genetic Algorithm <Single>
9
+ -------------------------------
10
+ Attributes:
11
+ problem: Problem
12
+ the problem you want to solve, including the following attributes:
13
+ n_input: int
14
+ the input number of the problem
15
+ ub: 1d-np.ndarray or float
16
+ the upper bound of the problem
17
+ lb: 1d-np.ndarray or float
18
+ the lower bound of the problem
19
+ evaluate: Callable
20
+ the function to evaluate the input
21
+ n_samples: int, default=50
22
+ the number of samples as the population
23
+ proC: float, default=1
24
+ the probability of crossover
25
+ disC: float, default=20
26
+ the distribution index of crossover
27
+ proM: float, default=1
28
+ the probability of mutation
29
+ disM: float, default=20
30
+ the distribution index of mutation
31
+ maxIterTimes: int, default=10000
32
+ the maximum iteration times
33
+ maxFEs: int, default=2000000
34
+ the maximum function evaluations
35
+ maxTolerateTimes: int, default=1000
36
+ the maximum tolerate times which the best objective value does not change
37
+ tolerate: float, default=1e-6
38
+ the tolerate value which the best objective value does not change
39
+
40
+ Methods:
41
+ run: run the Genetic Algorithm
42
+
43
+ References:
44
+ [1] D. E. Goldberg, Genetic Algorithms in Search, Optimization, and Machine Learning, 1989.
45
+ [2] M. Mitchell, An Introduction to Genetic Algorithms, 1998.
46
+ [3] D. Simon, Evolutionary Optimization Algorithms, 2013.
47
+ [4] J. H. Holland, Adaptation in Natural and Artificial Systems, MIT Press, 1992.
48
+ '''
49
+ type="EA" #Evolutionary Algorithm
50
+ def __init__(self, problem, n_samples: int=50,
51
+ proC: float=1, disC: float=20, proM: float=1, disM: float=20,
52
+ maxIterTimes: int=1000,
53
+ maxFEs: int=50000,
54
+ maxTolerateTimes: int=1000,
55
+ tolerate=1e-6):
56
+ #problem setting
57
+ self.evaluate=problem.evaluate
58
+ self.n_input=problem.n_input
59
+ self.ub=problem.ub.reshape(1,-1);self.lb=problem.lb.reshape(1,-1)
60
+
61
+ #algorithm setting
62
+ self.proC=proC;self.disC=disC
63
+ self.proM=proM;self.disM=disM
64
+ self.tolerate=tolerate
65
+ self.n_samples=n_samples
66
+
67
+ #termination setting
68
+ self.maxTolerateTimes=maxTolerateTimes
69
+ self.maxIterTimes=maxIterTimes
70
+ self.maxFEs=maxFEs
71
+
72
+ #--------------------------Public Functions--------------------------#
73
+ def run(self) -> dict:
74
+ '''
75
+ Run the Genetic Algorithm
76
+ -------------------------------
77
+ Returns:
78
+ Result: dict
79
+ the result of the Genetic Algorithm, including the following keys:
80
+ best_decs: 2d-np.ndarray
81
+ the decision variables of the best solution
82
+ best_objs: 2d-np.ndarray
83
+ the objective values of the best solution
84
+ history_best_decs: 2d-np.ndarray
85
+ the best decision variables of each iteration
86
+ history_best_objs: 2d-np.ndarray
87
+ the best objective values of each iteration
88
+ iters: int
89
+ the iteration times of the Genetic Algorithm
90
+ FEs: int
91
+ the function evaluations of the Genetic Algorithm
92
+ '''
93
+ best_objs=np.inf
94
+ best_decs=None
95
+ time=1
96
+ iter=0
97
+ FEs=0
98
+
99
+ lhs=LHS('classic')
100
+ decs=(lhs(self.n_samples,self.n_input))*(self.ub-self.lb)+self.lb
101
+ objs=self.evaluate(decs)
102
+ FEs+=objs.shape[0]
103
+
104
+ history_decs={}
105
+ history_objs={}
106
+ Result={}
107
+ while iter<self.maxIterTimes and FEs<self.maxFEs and time<=self.maxTolerateTimes:
108
+
109
+ matingPool=self._tournamentSelection(decs,objs,2)
110
+ matingDecs=self._operationGA(matingPool)
111
+ matingObjs=self.evaluate(matingDecs)
112
+
113
+
114
+ tempObjs=np.vstack((objs,matingObjs))
115
+ tempDecs=np.vstack((decs,matingDecs))
116
+ rank=np.argsort(tempObjs,axis=0)
117
+ decs=tempDecs[rank[:self.n_samples,0],:]
118
+ objs=tempObjs[rank[:self.n_samples,0],:]
119
+
120
+ if(abs(best_objs-np.min(objs))>self.tolerate):
121
+ best_objs=np.min(objs)
122
+ best_decs=decs[np.argmin(objs,axis=0),:]
123
+ time=0
124
+ else:
125
+ time+=1
126
+
127
+ iter+=1
128
+ FEs+=matingObjs.shape[0]
129
+
130
+ history_decs[FEs]=best_decs
131
+ history_objs[FEs]=best_objs
132
+
133
+ Result['best_dec']=best_decs
134
+ Result['best_obj']=best_objs
135
+ Result['history_best_decs']=history_decs
136
+ Result['history_best_objs']=history_objs
137
+ Result['iters']=iter
138
+ Result['FEs']=FEs
139
+
140
+ return Result
141
+ #--------------------Private Functions--------------------#
142
+ def _tournamentSelection(self,decs: np.ndarray, objs: np.ndarray, K: int=2):
143
+ '''
144
+ K-tournament selection
145
+ '''
146
+ rankIndex=np.argsort(objs,axis=0)
147
+ rank=np.argsort(rankIndex,axis=0)
148
+
149
+ tourSelection=np.random.randint(0,high=objs.shape[0],size=(objs.shape[0],K))
150
+ winner=np.min(rank[tourSelection,:].ravel().reshape(objs.shape[0],2),axis=1)
151
+ winIndex=rankIndex[winner]
152
+
153
+ return decs[winIndex.ravel(),:]
154
+
155
+ def _operationGA(self,decs: np.ndarray):
156
+ '''
157
+ GA Operation: crossover and mutation
158
+ '''
159
+ n_samples=decs.shape[0]
160
+ parent1=decs[:math.floor(n_samples/2),:]
161
+ parent2=decs[math.floor(n_samples/2):math.floor(n_samples/2)*2,:]
162
+
163
+ n, d = parent1.shape
164
+ beta = np.zeros_like(parent1)
165
+ mu = np.random.rand(n, d)
166
+
167
+ beta[mu <= 0.5] = np.power(2 * mu[mu <= 0.5], 1 / (self.disC + 1))
168
+ beta[mu > 0.5] = np.power(2 - 2 * mu[mu > 0.5], -1 / (self.disC + 1))
169
+ beta = beta * (-1) ** np.random.randint(0, 2, size=(n, d))
170
+ beta[np.random.rand(n, d) < 0.5] = 1
171
+ beta[np.repeat(np.random.rand(n, 1) > self.proC, d, axis=1)] = 1
172
+
173
+ offspring = np.concatenate(( (parent1 + parent2) / 2 + beta * (parent1 - parent2) / 2,
174
+ (parent1 + parent2) / 2 - beta * (parent1 - parent2) / 2 ), axis=0)
175
+
176
+ lower = np.repeat(self.lb, 2 * n, axis=0)
177
+ upper = np.repeat(self.ub, 2 * n, axis=0)
178
+ site = np.random.rand(2 * n, d) < self.proM / d
179
+ mu = np.random.rand(2 * n, d)
180
+
181
+ temp = site & (mu <= 0.5)
182
+ offspring = np.clip(offspring, lower, upper)
183
+ t1 = (1 - 2 * mu[temp]) * np.power(1 - (offspring[temp] - lower[temp]) / (upper[temp] - lower[temp]), self.disM + 1)
184
+ offspring[temp] = offspring[temp] + (upper[temp] - lower[temp]) * (np.power(2 * mu[temp] + t1, 1 / (self.disM + 1)) - 1)
185
+
186
+ temp = site & (mu > 0.5)
187
+ t2 = 2 * (mu[temp] - 0.5) * np.power(1 - (upper[temp] - offspring[temp]) / (upper[temp] - lower[temp]), self.disM + 1)
188
+ offspring[temp] = offspring[temp] + (upper[temp] - lower[temp]) * (1 - np.power(2 * (1 - mu[temp]) + t2, 1 / (self.disM + 1)))
189
+
190
+ return offspring