UQPyL 2.0.6__tar.gz → 2.0.7__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.
- UQPyL-2.0.7/PKG-INFO +196 -0
- UQPyL-2.0.7/README.md +179 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/DoE/fast_sequence.py +20 -8
- UQPyL-2.0.7/UQPyL/DoE/full_fact.py +68 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/DoE/lhs.py +13 -15
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/DoE/morris_sequence.py +23 -5
- UQPyL-2.0.7/UQPyL/DoE/random.py +43 -0
- UQPyL-2.0.7/UQPyL/DoE/samplerABC.py +50 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/DoE/sobol_sequence.py +20 -6
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/__init__.py +1 -1
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/algorithmABC.py +2 -2
- UQPyL-2.0.7/UQPyL.egg-info/PKG-INFO +196 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/pyproject.toml +1 -1
- {UQPyL-2.0.6 → UQPyL-2.0.7}/setup.py +1 -1
- UQPyL-2.0.6/PKG-INFO +0 -156
- UQPyL-2.0.6/README.md +0 -139
- UQPyL-2.0.6/UQPyL/DoE/full_fact.py +0 -57
- UQPyL-2.0.6/UQPyL/DoE/random.py +0 -27
- UQPyL-2.0.6/UQPyL/DoE/samplerABC.py +0 -36
- UQPyL-2.0.6/UQPyL.egg-info/PKG-INFO +0 -156
- {UQPyL-2.0.6 → UQPyL-2.0.7}/LICENSE.md +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/DoE/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/mathematics/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/mathematics/adam.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/mathematics/boxmin.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/metric/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/metric/gd.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/metric/hv.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/metric/igd.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/multi_objective/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/multi_objective/moasmo.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/multi_objective/moea_d.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/multi_objective/nsga_ii.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/multi_objective/rvea.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/population.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/result.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/_binary_ga.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/abc.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/asmo.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/csa.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/de.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/ego.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/ga.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/ml_sce_ua.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/pso.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/single_objective/sce_ua.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/utility_functions/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/utility_functions/crowding_distance.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/utility_functions/ndsort.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/utility_functions/operationGA.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/utility_functions/tournament_selection.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/optimization/utility_functions/uniform_point.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/multi_objective/DTLZ.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/multi_objective/ZDT.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/multi_objective/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/pratical_problem.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/problemABC.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/single_objective/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/single_objective/single_base_problem.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/utility_functions/NDsort.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/utility_functions/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/problems/utility_functions/uniformPoint.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/delta_test.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/fast.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/mars_sa.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/morris.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/rbd_fast.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/rsa.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/saABC.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/sensibility/sobol.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/fnn/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/fnn/_activation_funcs.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/fnn/base.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/fnn/fully_connect_neural_network.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/gaussian_process.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/kernel/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/kernel/base_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/kernel/c_kernel_.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/kernel/dot_kernel_.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/kernel/matern_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/kernel/rbf_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/gp/kernel/rq_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/kriging/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/kriging/kernel/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/kriging/kernel/base_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/kriging/kernel/cubic_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/kriging/kernel/exp_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/kriging/kernel/guass_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/kriging/kriging.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/_basis.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/_forward.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/_knot_search.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/_pruning.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/_qr.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/_record.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/_types.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/core/_util.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/mars/mars.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/kernel/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/kernel/base_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/kernel/cubic_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/kernel/gaussian_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/kernel/linear_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/kernel/multiquadric_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/kernel/thin_plate_spline_kernel.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/rbf/radial_basis_function.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/regression/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/regression/lasso/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/regression/lasso/lasso_fast.c +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/regression/linear_regression.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/regression/polynomial_regression.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/setting.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/surrogateABC.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/svr/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/svr/core/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/svr/core/libsvm_interface.cpp +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/svr/core/svm.cpp +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/surrogates/svr/support_vector_machine.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/utility/__init__.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/utility/grid_search.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/utility/metrics.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/utility/model_selections.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/utility/polynomial_features.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/utility/scalers.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL/utility/verbose.py +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL.egg-info/SOURCES.txt +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL.egg-info/dependency_links.txt +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL.egg-info/requires.txt +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/UQPyL.egg-info/top_level.txt +0 -0
- {UQPyL-2.0.6 → UQPyL-2.0.7}/setup.cfg +0 -0
UQPyL-2.0.7/PKG-INFO
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: UQPyL
|
|
3
|
+
Version: 2.0.7
|
|
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.7
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE.md
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Uncertainty Quantification Python Laboratory (UQPyL)
|
|
20
|
+
|
|
21
|
+
**UQPyL:** The **Uncertainty Quantification Python Laboratory** provides comprehensive workflows tailored for **Uncertainty Quantification** and **Optimization** of computational models and their associated applications (e.g., model calibration, resource scheduling, product design).
|
|
22
|
+
|
|
23
|
+
## Main Characteristics
|
|
24
|
+
|
|
25
|
+
1. **Comprehensive Sensitivity Analysis and Optimization Algorithm**: Implements widely used sensitivity analysis methodologies and optimization algorithms.
|
|
26
|
+
2. **Advanced Surrogate Modeling**: Integrates diverse surrogate models equipped to solve computationally expensive problems.
|
|
27
|
+
3. **Rich Application Resources**: Provides a comprehensive suite of benchmark problems and practical case studies, enabling users to get started quickly.
|
|
28
|
+
4. **Modular and Extensible Architecture**: 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**)
|
|
29
|
+
|
|
30
|
+
## Quick Links
|
|
31
|
+
|
|
32
|
+
- **Website**: [UQPyL Official Site](http://www.uq-pyl.com) (**#TODO**: Needs update)
|
|
33
|
+
- **Source Code**: [GitHub Repository](https://github.com/smasky/UQPyL/)
|
|
34
|
+
- **Documentation**: [ReadTheDocs](https://uqpyl.readthedocs.io/en/latest/)(**#TODO**: Being updating )
|
|
35
|
+
- **Citation Info**: [UQPyL 2.0](**#TODO**: Needs update), [UQPyL 1.0](https://www.sciencedirect.com/science/article/pii/S1364815215300955)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Included Methods and Algorithms
|
|
40
|
+
|
|
41
|
+
### Sensitivity Analysis
|
|
42
|
+
|
|
43
|
+
(All methods support surrogate models)
|
|
44
|
+
- Sobol'
|
|
45
|
+
- Delta Test (DT)
|
|
46
|
+
- Extended Fourier Amplitude Sensitivity Test (eFAST)
|
|
47
|
+
- Random Balance Designs - Fourier Amplitude Sensitivity Test (RBD-FAST)
|
|
48
|
+
- Multivariate Adaptive Regression Splines-Sensitivity Analysis (MARS-SA)
|
|
49
|
+
- Morris
|
|
50
|
+
- Regional Sensitivity Analysis (RSA)
|
|
51
|
+
|
|
52
|
+
### Optimization Algorithms
|
|
53
|
+
|
|
54
|
+
(* indicates solving computational expensive optimization problem)
|
|
55
|
+
- **Single Objective Optimization**: SCE-UA, ML-SCE-UA, GA, CSA, PSO, DE, ABC, ASMO*, EGO*
|
|
56
|
+
- **Multi-Objective Optimization**: MOEA/D, NSGA-II, RVEA, MOASMO*
|
|
57
|
+
|
|
58
|
+
*Note: The library is still being updated. If you need other algorithms, please contact us.*
|
|
59
|
+
|
|
60
|
+
### Surrogate Models
|
|
61
|
+
|
|
62
|
+
- Fully Connected Neural Network (FCNN)
|
|
63
|
+
- Kriging (KRG)
|
|
64
|
+
- Gaussian Process (GP)
|
|
65
|
+
- Linear Regression (LR)
|
|
66
|
+
- Polynomial Regression (PR)
|
|
67
|
+
- Radial Basis Function (RBF)
|
|
68
|
+
- Support Vector Machine (SVM)
|
|
69
|
+
- Multivariate Adaptive Regression Splines (MARS)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Installation
|
|
74
|
+
|
|
75
|
+
Recommended (PyPi or Conda):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install UQPyL
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
conda install UQPyL
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Alternatively:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git clone https://github.com/smasky/UQPyL.git
|
|
89
|
+
cd UQPyL
|
|
90
|
+
pip install .
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Quick Start
|
|
96
|
+
|
|
97
|
+
To use UQPyL, define the problem you want to solve. The problem usually contains three important properties:
|
|
98
|
+
1. `func` (the mapping from X to Y)
|
|
99
|
+
2. The dimensions of decisions and outputs
|
|
100
|
+
3. The bounds of decisions (ub, lb)
|
|
101
|
+
|
|
102
|
+
### Benchmark Problems
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from UQPyL.problems.single_objective import Sphere
|
|
106
|
+
|
|
107
|
+
problem = Sphere(nInput=10, ub=100, lb=-100)
|
|
108
|
+
problem = Sphere(nInput=10, ub=np.ones(10)*100, lb=np.ones(10)*-100)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Practical Problems
|
|
112
|
+
|
|
113
|
+
Define the evaluation function:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from UQPyL.problems import PracticalProblem
|
|
117
|
+
|
|
118
|
+
def func(X):
|
|
119
|
+
Y = np.sum(X, axis=1).reshape(-1, 1)
|
|
120
|
+
return Y
|
|
121
|
+
|
|
122
|
+
problem = PracticalProblem(func=func, nInput=10, nOutput=1, ub=100, lb=-100, name="Sphere")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Note:** The `func` needs to accept a matrix of X and return a matrix of Y, with columns equal to dimensions and rows equal to samples. X and Y should be np.ndarray.
|
|
126
|
+
|
|
127
|
+
After defining the problem, you can use any methods in UQPyL.
|
|
128
|
+
|
|
129
|
+
### Sensitivity Analysis
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from UQPyL.sensibility import Sobol
|
|
133
|
+
|
|
134
|
+
sobol = Sobol() # Instantiate and set hyper-parameters
|
|
135
|
+
sobol.analyze(problem)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Optimization
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from UQPyL.optimization.single_objective import SCE_UA
|
|
142
|
+
|
|
143
|
+
sce = SCE_UA()
|
|
144
|
+
res = sce.run(problem)
|
|
145
|
+
bestDec = res.bestDec
|
|
146
|
+
bestObj = res.bestObj
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Surrogate Modeling
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from UQPyL.DoE import LHS
|
|
153
|
+
|
|
154
|
+
lhs = LHS(problem)
|
|
155
|
+
xTrain = lhs.sample(200, problem.nInput)
|
|
156
|
+
yTrain = problem.evaluate(xTrain)
|
|
157
|
+
|
|
158
|
+
xTest = lhs.sample(50, problem.nInput)
|
|
159
|
+
yTest = problem.evaluate(xTest)
|
|
160
|
+
|
|
161
|
+
from UQPyL.surrogate.rbf import RBF
|
|
162
|
+
|
|
163
|
+
rbf = RBF()
|
|
164
|
+
rbf.fit(xTrain, yTrain)
|
|
165
|
+
yPred = rbf.predict(xTest)
|
|
166
|
+
|
|
167
|
+
from UQPyL.utility.metric import r_square
|
|
168
|
+
r2 = r_square(yTest, yPred)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
For more advanced usage, please refer to the documentation (**#TODO**).
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Call for Contributions
|
|
176
|
+
|
|
177
|
+
We welcome contributions to expand our library with more sophisticated UQ methods, optimization algorithms and engineering problems.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Contact
|
|
182
|
+
|
|
183
|
+
For any inquiries or contributions, please contact:
|
|
184
|
+
|
|
185
|
+
**wmtSky**
|
|
186
|
+
Email: [wmtsky@hhu.edu.cn](mailto:wmtsky@hhu.edu.cn), [wmtsmasky@gmail.com](mailto:wmtsmasky@gmail.com)
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
*This project is licensed under the MIT License - see the [LICENSE](https://github.com/smasky/UQPyL/LICENSE) file for details.*
|
|
191
|
+
|
|
192
|
+

|
|
193
|
+

|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
UQPyL-2.0.7/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
|
|
2
|
+
# Uncertainty Quantification Python Laboratory (UQPyL)
|
|
3
|
+
|
|
4
|
+
**UQPyL:** The **Uncertainty Quantification Python Laboratory** provides comprehensive workflows tailored for **Uncertainty Quantification** and **Optimization** of computational models and their associated applications (e.g., model calibration, resource scheduling, product design).
|
|
5
|
+
|
|
6
|
+
## Main Characteristics
|
|
7
|
+
|
|
8
|
+
1. **Comprehensive Sensitivity Analysis and Optimization Algorithm**: Implements widely used sensitivity analysis methodologies and optimization algorithms.
|
|
9
|
+
2. **Advanced Surrogate Modeling**: Integrates diverse surrogate models equipped to solve computationally expensive problems.
|
|
10
|
+
3. **Rich Application Resources**: Provides a comprehensive suite of benchmark problems and practical case studies, enabling users to get started quickly.
|
|
11
|
+
4. **Modular and Extensible Architecture**: 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**)
|
|
12
|
+
|
|
13
|
+
## Quick Links
|
|
14
|
+
|
|
15
|
+
- **Website**: [UQPyL Official Site](http://www.uq-pyl.com) (**#TODO**: Needs update)
|
|
16
|
+
- **Source Code**: [GitHub Repository](https://github.com/smasky/UQPyL/)
|
|
17
|
+
- **Documentation**: [ReadTheDocs](https://uqpyl.readthedocs.io/en/latest/)(**#TODO**: Being updating )
|
|
18
|
+
- **Citation Info**: [UQPyL 2.0](**#TODO**: Needs update), [UQPyL 1.0](https://www.sciencedirect.com/science/article/pii/S1364815215300955)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Included Methods and Algorithms
|
|
23
|
+
|
|
24
|
+
### Sensitivity Analysis
|
|
25
|
+
|
|
26
|
+
(All methods support surrogate models)
|
|
27
|
+
- Sobol'
|
|
28
|
+
- Delta Test (DT)
|
|
29
|
+
- Extended Fourier Amplitude Sensitivity Test (eFAST)
|
|
30
|
+
- Random Balance Designs - Fourier Amplitude Sensitivity Test (RBD-FAST)
|
|
31
|
+
- Multivariate Adaptive Regression Splines-Sensitivity Analysis (MARS-SA)
|
|
32
|
+
- Morris
|
|
33
|
+
- Regional Sensitivity Analysis (RSA)
|
|
34
|
+
|
|
35
|
+
### Optimization Algorithms
|
|
36
|
+
|
|
37
|
+
(* indicates solving computational expensive optimization problem)
|
|
38
|
+
- **Single Objective Optimization**: SCE-UA, ML-SCE-UA, GA, CSA, PSO, DE, ABC, ASMO*, EGO*
|
|
39
|
+
- **Multi-Objective Optimization**: MOEA/D, NSGA-II, RVEA, MOASMO*
|
|
40
|
+
|
|
41
|
+
*Note: The library is still being updated. If you need other algorithms, please contact us.*
|
|
42
|
+
|
|
43
|
+
### Surrogate Models
|
|
44
|
+
|
|
45
|
+
- Fully Connected Neural Network (FCNN)
|
|
46
|
+
- Kriging (KRG)
|
|
47
|
+
- Gaussian Process (GP)
|
|
48
|
+
- Linear Regression (LR)
|
|
49
|
+
- Polynomial Regression (PR)
|
|
50
|
+
- Radial Basis Function (RBF)
|
|
51
|
+
- Support Vector Machine (SVM)
|
|
52
|
+
- Multivariate Adaptive Regression Splines (MARS)
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
Recommended (PyPi or Conda):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install UQPyL
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
conda install UQPyL
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Alternatively:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/smasky/UQPyL.git
|
|
72
|
+
cd UQPyL
|
|
73
|
+
pip install .
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Quick Start
|
|
79
|
+
|
|
80
|
+
To use UQPyL, define the problem you want to solve. The problem usually contains three important properties:
|
|
81
|
+
1. `func` (the mapping from X to Y)
|
|
82
|
+
2. The dimensions of decisions and outputs
|
|
83
|
+
3. The bounds of decisions (ub, lb)
|
|
84
|
+
|
|
85
|
+
### Benchmark Problems
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from UQPyL.problems.single_objective import Sphere
|
|
89
|
+
|
|
90
|
+
problem = Sphere(nInput=10, ub=100, lb=-100)
|
|
91
|
+
problem = Sphere(nInput=10, ub=np.ones(10)*100, lb=np.ones(10)*-100)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Practical Problems
|
|
95
|
+
|
|
96
|
+
Define the evaluation function:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from UQPyL.problems import PracticalProblem
|
|
100
|
+
|
|
101
|
+
def func(X):
|
|
102
|
+
Y = np.sum(X, axis=1).reshape(-1, 1)
|
|
103
|
+
return Y
|
|
104
|
+
|
|
105
|
+
problem = PracticalProblem(func=func, nInput=10, nOutput=1, ub=100, lb=-100, name="Sphere")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Note:** The `func` needs to accept a matrix of X and return a matrix of Y, with columns equal to dimensions and rows equal to samples. X and Y should be np.ndarray.
|
|
109
|
+
|
|
110
|
+
After defining the problem, you can use any methods in UQPyL.
|
|
111
|
+
|
|
112
|
+
### Sensitivity Analysis
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from UQPyL.sensibility import Sobol
|
|
116
|
+
|
|
117
|
+
sobol = Sobol() # Instantiate and set hyper-parameters
|
|
118
|
+
sobol.analyze(problem)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Optimization
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from UQPyL.optimization.single_objective import SCE_UA
|
|
125
|
+
|
|
126
|
+
sce = SCE_UA()
|
|
127
|
+
res = sce.run(problem)
|
|
128
|
+
bestDec = res.bestDec
|
|
129
|
+
bestObj = res.bestObj
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Surrogate Modeling
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from UQPyL.DoE import LHS
|
|
136
|
+
|
|
137
|
+
lhs = LHS(problem)
|
|
138
|
+
xTrain = lhs.sample(200, problem.nInput)
|
|
139
|
+
yTrain = problem.evaluate(xTrain)
|
|
140
|
+
|
|
141
|
+
xTest = lhs.sample(50, problem.nInput)
|
|
142
|
+
yTest = problem.evaluate(xTest)
|
|
143
|
+
|
|
144
|
+
from UQPyL.surrogate.rbf import RBF
|
|
145
|
+
|
|
146
|
+
rbf = RBF()
|
|
147
|
+
rbf.fit(xTrain, yTrain)
|
|
148
|
+
yPred = rbf.predict(xTest)
|
|
149
|
+
|
|
150
|
+
from UQPyL.utility.metric import r_square
|
|
151
|
+
r2 = r_square(yTest, yPred)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
For more advanced usage, please refer to the documentation (**#TODO**).
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Call for Contributions
|
|
159
|
+
|
|
160
|
+
We welcome contributions to expand our library with more sophisticated UQ methods, optimization algorithms and engineering problems.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Contact
|
|
165
|
+
|
|
166
|
+
For any inquiries or contributions, please contact:
|
|
167
|
+
|
|
168
|
+
**wmtSky**
|
|
169
|
+
Email: [wmtsky@hhu.edu.cn](mailto:wmtsky@hhu.edu.cn), [wmtsmasky@gmail.com](mailto:wmtsmasky@gmail.com)
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
*This project is licensed under the MIT License - see the [LICENSE](https://github.com/smasky/UQPyL/LICENSE) file for details.*
|
|
174
|
+
|
|
175
|
+

|
|
176
|
+

|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
+
from typing import Union, Optional
|
|
2
3
|
|
|
3
|
-
from .samplerABC import Sampler
|
|
4
|
-
|
|
4
|
+
from .samplerABC import Sampler, decoratorRescale
|
|
5
|
+
from ..problems import ProblemABC as Problem
|
|
5
6
|
class FAST_Sequence(Sampler):
|
|
6
7
|
'''
|
|
7
8
|
The sample technique for FAST(Fourier Amplitude Sensitivity Test) method
|
|
@@ -15,17 +16,14 @@ class FAST_Sequence(Sampler):
|
|
|
15
16
|
Methods:
|
|
16
17
|
__call__ or sample: Generate a sample for FAST method
|
|
17
18
|
|
|
18
|
-
Examples:
|
|
19
|
-
>>> fast_seq=FAST_Sequence()
|
|
20
|
-
>>> samples=fast_seq(5, 4) or fast_seq.sample(5,4)
|
|
21
|
-
|
|
22
19
|
'''
|
|
23
20
|
def __init__(self, M: int=4):
|
|
24
21
|
|
|
25
22
|
super().__init__()
|
|
23
|
+
|
|
26
24
|
self.M=M
|
|
27
25
|
|
|
28
|
-
def _generate(self, nt: int, nx: int)
|
|
26
|
+
def _generate(self, nt: int, nx: int):
|
|
29
27
|
'''
|
|
30
28
|
Generate a shape of (nt*nx, nx) sample for FAST
|
|
31
29
|
|
|
@@ -70,7 +68,21 @@ class FAST_Sequence(Sampler):
|
|
|
70
68
|
|
|
71
69
|
return xInit
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
@decoratorRescale
|
|
72
|
+
def sample(self, nt: int, nx: Optional[int] = None, problem: Optional[Problem] = None, random_seed: Optional[int] = None):
|
|
73
|
+
|
|
74
|
+
if random_seed is not None:
|
|
75
|
+
self.random_state = np.random.RandomState(random_seed)
|
|
76
|
+
else:
|
|
77
|
+
self.random_state = np.random.RandomState()
|
|
78
|
+
|
|
79
|
+
if problem is not None and nx is not None:
|
|
80
|
+
if(problem.nInput!=nx):
|
|
81
|
+
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
82
|
+
elif problem is None and nx is None:
|
|
83
|
+
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
84
|
+
|
|
85
|
+
nx=problem.nInput if problem is not None else nx
|
|
74
86
|
|
|
75
87
|
return self._generate(nt, nx)
|
|
76
88
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from typing import Union, Optional
|
|
3
|
+
from itertools import product
|
|
4
|
+
|
|
5
|
+
from .samplerABC import Sampler, decoratorRescale
|
|
6
|
+
from ..problems import ProblemABC as Problem
|
|
7
|
+
|
|
8
|
+
class FFD(Sampler):
|
|
9
|
+
'''
|
|
10
|
+
Full Factorial Design
|
|
11
|
+
|
|
12
|
+
Methods:
|
|
13
|
+
__call__ or sample: Generate a Latin-hypercube design
|
|
14
|
+
|
|
15
|
+
'''
|
|
16
|
+
|
|
17
|
+
#Abandon
|
|
18
|
+
# def __call__(self, nx: int, levels: Union[np.ndarray, int, list]) -> np.ndarray:
|
|
19
|
+
|
|
20
|
+
# return self._generate(nx, levels)
|
|
21
|
+
|
|
22
|
+
def _generate(self, levels: Union[np.ndarray, int, list], nx: int):
|
|
23
|
+
|
|
24
|
+
if isinstance(levels, int):
|
|
25
|
+
levels = [levels]*nx
|
|
26
|
+
elif isinstance(levels, np.ndarray):
|
|
27
|
+
levels = levels.ravel().tolist()
|
|
28
|
+
|
|
29
|
+
if len(levels)!=nx:
|
|
30
|
+
raise ValueError('The length of levels should be equal to nx or 1')
|
|
31
|
+
|
|
32
|
+
factor_levels = [np.linspace(0, 1, num=level)[:level] for level in levels]
|
|
33
|
+
|
|
34
|
+
factor_combinations = list(product(*factor_levels))
|
|
35
|
+
|
|
36
|
+
H = np.array(factor_combinations)
|
|
37
|
+
|
|
38
|
+
return H
|
|
39
|
+
|
|
40
|
+
@decoratorRescale
|
|
41
|
+
def sample(self, levels: Union[np.ndarray, int, list], nx: Optional[int] = None, problem: Optional[Problem] = None, random_seed: Optional[int] = None):
|
|
42
|
+
'''
|
|
43
|
+
Parameters:
|
|
44
|
+
nx: int
|
|
45
|
+
The number of input dimensions
|
|
46
|
+
|
|
47
|
+
levels: Union[np.ndarray, int, list]
|
|
48
|
+
The levels for each input dimension
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
H: 2d-array
|
|
52
|
+
An n-by-samples design matrix between zero and one.
|
|
53
|
+
'''
|
|
54
|
+
|
|
55
|
+
if random_seed is not None:
|
|
56
|
+
self.random_state = np.random.RandomState(random_seed)
|
|
57
|
+
else:
|
|
58
|
+
self.random_state = np.random.RandomState()
|
|
59
|
+
|
|
60
|
+
if problem is not None and nx is not None:
|
|
61
|
+
if(problem.nInput!=nx):
|
|
62
|
+
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
63
|
+
elif problem is None and nx is None:
|
|
64
|
+
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
65
|
+
|
|
66
|
+
nx=problem.nInput if problem is not None else nx
|
|
67
|
+
|
|
68
|
+
return self._generate(levels, nx)
|
|
@@ -136,23 +136,17 @@ class LHS(Sampler):
|
|
|
136
136
|
|
|
137
137
|
Methods:
|
|
138
138
|
__call__ or sample: Generate a Latin-hypercube design
|
|
139
|
-
|
|
140
|
-
Examples:
|
|
141
|
-
>>>lhs=LHS('classic')
|
|
142
|
-
>>>samples=lhs(5,10) or samples=lhs.sample(5,10)
|
|
143
|
-
|
|
139
|
+
|
|
144
140
|
'''
|
|
145
|
-
def __init__(self, criterion: Criterion ='classic', iterations: int=5
|
|
141
|
+
def __init__(self, criterion: Criterion ='classic', iterations: int=5):
|
|
146
142
|
|
|
147
143
|
self.criterion=criterion
|
|
148
144
|
self.iterations=iterations
|
|
149
|
-
self.problem=problem
|
|
150
145
|
|
|
151
146
|
#initial random state
|
|
152
|
-
|
|
147
|
+
super().__init__()
|
|
153
148
|
|
|
154
|
-
|
|
155
|
-
def _generate(self, nt: int, nx: int) -> np.ndarray:
|
|
149
|
+
def _generate(self, nt: int, nx:int=None):
|
|
156
150
|
'''
|
|
157
151
|
Generate a Latin-hypercube design
|
|
158
152
|
|
|
@@ -168,10 +162,6 @@ class LHS(Sampler):
|
|
|
168
162
|
are uniformly spaced between zero and one.
|
|
169
163
|
'''
|
|
170
164
|
|
|
171
|
-
if self.problem is not None:
|
|
172
|
-
if(self.problem.nInput!=nx):
|
|
173
|
-
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
174
|
-
|
|
175
165
|
if self.criterion not in LHS_METHOD:
|
|
176
166
|
raise ValueError('The criterion must be one of {}'.format(LHS_METHOD.keys()))
|
|
177
167
|
|
|
@@ -185,7 +175,7 @@ class LHS(Sampler):
|
|
|
185
175
|
return xInit
|
|
186
176
|
|
|
187
177
|
@decoratorRescale
|
|
188
|
-
def sample(self, nt: int, nx:int, random_seed: Optional[int]=None) -> np.ndarray:
|
|
178
|
+
def sample(self, nt: int, nx:int = None, problem: Problem = None, random_seed: Optional[int] = None) -> np.ndarray:
|
|
189
179
|
'''
|
|
190
180
|
Generate a Latin-hypercube design
|
|
191
181
|
|
|
@@ -210,4 +200,12 @@ class LHS(Sampler):
|
|
|
210
200
|
else:
|
|
211
201
|
self.random_state = np.random.RandomState()
|
|
212
202
|
|
|
203
|
+
if problem is not None and nx is not None:
|
|
204
|
+
if(problem.nInput!=nx):
|
|
205
|
+
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
206
|
+
elif problem is None and nx is None:
|
|
207
|
+
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
208
|
+
|
|
209
|
+
nx=problem.nInput if problem is not None else nx
|
|
210
|
+
|
|
213
211
|
return self._generate(nt, nx)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
+
from typing import Optional
|
|
2
3
|
|
|
3
|
-
from .samplerABC import Sampler
|
|
4
|
+
from .samplerABC import Sampler, decoratorRescale
|
|
5
|
+
from ..problems import ProblemABC as Problem
|
|
4
6
|
|
|
5
7
|
class Morris_Sequence(Sampler):
|
|
6
8
|
'''
|
|
@@ -25,7 +27,7 @@ class Morris_Sequence(Sampler):
|
|
|
25
27
|
super().__init__()
|
|
26
28
|
self.num_levels=num_levels
|
|
27
29
|
|
|
28
|
-
def _generate(self, nt: int, nx: int)
|
|
30
|
+
def _generate(self, nt: int, nx: int):
|
|
29
31
|
'''
|
|
30
32
|
Generate a shape of (nt*nx, nx) sample for FAST
|
|
31
33
|
|
|
@@ -47,10 +49,26 @@ class Morris_Sequence(Sampler):
|
|
|
47
49
|
|
|
48
50
|
return xInit
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
@decoratorRescale
|
|
53
|
+
def sample(self, nt: int, nx: Optional[int]=None, problem: Optional[Problem]=None, random_seed: Optional[int] = None):
|
|
54
|
+
|
|
55
|
+
if random_seed is not None:
|
|
56
|
+
self.random_state = np.random.RandomState(random_seed)
|
|
57
|
+
else:
|
|
58
|
+
self.random_state = np.random.RandomState()
|
|
59
|
+
|
|
60
|
+
if problem is not None and nx is not None:
|
|
61
|
+
if(problem.nInput!=nx):
|
|
62
|
+
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
63
|
+
elif problem is None and nx is None:
|
|
64
|
+
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
65
|
+
|
|
66
|
+
nx=problem.nInput if problem is not None else nx
|
|
67
|
+
|
|
68
|
+
self._generate(nt, nx)
|
|
69
|
+
|
|
70
|
+
def _generate_trajectory(self, nx: int):
|
|
52
71
|
|
|
53
|
-
'''
|
|
54
72
|
delta=self.num_levels/(2*(self.num_levels-1))
|
|
55
73
|
|
|
56
74
|
B=np.tril(np.ones([nx + 1, nx], dtype=int), -1)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from .samplerABC import Sampler, decoratorRescale
|
|
5
|
+
from ..problems import ProblemABC as Problem
|
|
6
|
+
|
|
7
|
+
class Random(Sampler):
|
|
8
|
+
'''
|
|
9
|
+
Random Design
|
|
10
|
+
|
|
11
|
+
Method:
|
|
12
|
+
__call__ or sample: Generate a random design
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
>>> random=RANDOM()
|
|
16
|
+
>>> random(10,10) or random.sample(10,10)
|
|
17
|
+
'''
|
|
18
|
+
def _generate(self,nt: int, nx: int):
|
|
19
|
+
|
|
20
|
+
H=np.random.random((nt,nx))
|
|
21
|
+
|
|
22
|
+
return H
|
|
23
|
+
|
|
24
|
+
@decoratorRescale
|
|
25
|
+
def sample(self, nt: int, nx: Optional[int] = None, problem: Optional[Problem] = None, random_seed: Optional[int] = None):
|
|
26
|
+
'''
|
|
27
|
+
Generate a sample with random values between zero and one
|
|
28
|
+
'''
|
|
29
|
+
|
|
30
|
+
if random_seed is not None:
|
|
31
|
+
self.random_state = np.random.RandomState(random_seed)
|
|
32
|
+
else:
|
|
33
|
+
self.random_state = np.random.RandomState()
|
|
34
|
+
|
|
35
|
+
if problem is not None and nx is not None:
|
|
36
|
+
if(problem.nInput!=nx):
|
|
37
|
+
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
38
|
+
elif problem is None and nx is None:
|
|
39
|
+
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
40
|
+
|
|
41
|
+
nx=problem.nInput if problem is not None else nx
|
|
42
|
+
|
|
43
|
+
return self._generate(nt, nx)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from ..problems import ProblemABC as Problem
|
|
5
|
+
|
|
6
|
+
def decoratorRescale(func):
|
|
7
|
+
def wrapper(self, *args, **kwargs):
|
|
8
|
+
result=func(self, *args, **kwargs)
|
|
9
|
+
|
|
10
|
+
for arg in args:
|
|
11
|
+
if isinstance(arg, Problem):
|
|
12
|
+
return arg._unit_X_transform_to_bound(result)
|
|
13
|
+
|
|
14
|
+
for key, value in kwargs.items():
|
|
15
|
+
if isinstance(value, Problem):
|
|
16
|
+
return value._unit_X_transform_to_bound(result)
|
|
17
|
+
|
|
18
|
+
return result
|
|
19
|
+
return wrapper
|
|
20
|
+
class Sampler(metaclass=abc.ABCMeta):
|
|
21
|
+
|
|
22
|
+
def __init__(self):
|
|
23
|
+
|
|
24
|
+
self.random_state=np.random.RandomState()
|
|
25
|
+
|
|
26
|
+
#Abandon
|
|
27
|
+
# def __call__(self, nt:int, nx: int) -> np.ndarray:
|
|
28
|
+
# return self._generate(nt, nx)
|
|
29
|
+
|
|
30
|
+
# def sample(self, nt:int, nx:int) -> np.ndarray:
|
|
31
|
+
# return self._generate(nt, nx)
|
|
32
|
+
|
|
33
|
+
# def rescale_to_problem(self, xInit:np.ndarray):
|
|
34
|
+
|
|
35
|
+
# if self.problem is not None:
|
|
36
|
+
# xInit=self.problem._unit_xInit_transform_to_bound(xInit)
|
|
37
|
+
|
|
38
|
+
# return xInit
|
|
39
|
+
|
|
40
|
+
def _generate(self, nt: int, nx: int):
|
|
41
|
+
'''
|
|
42
|
+
nt: the number of sampled points
|
|
43
|
+
nx: the dimensions of decision variables
|
|
44
|
+
|
|
45
|
+
return:
|
|
46
|
+
ndarry[nt,nx]
|
|
47
|
+
|
|
48
|
+
'''
|
|
49
|
+
pass
|
|
50
|
+
|