UQPyL 2.1.3__tar.gz → 2.1.4__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.1.3 → uqpyl-2.1.4}/PKG-INFO +17 -5
- {UQPyL-2.1.3 → uqpyl-2.1.4}/README.md +9 -2
- uqpyl-2.1.4/UQPyL/DoE/__init__.py +12 -0
- uqpyl-2.1.4/UQPyL/DoE/base.py +22 -0
- UQPyL-2.1.3/UQPyL/DoE/fast_sequence.py → uqpyl-2.1.4/UQPyL/DoE/fast.py +13 -19
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL/DoE/full_fact.py +9 -18
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL/DoE/lhs.py +36 -60
- UQPyL-2.1.3/UQPyL/DoE/morris_sequence.py → uqpyl-2.1.4/UQPyL/DoE/morris.py +15 -21
- uqpyl-2.1.4/UQPyL/DoE/random.py +45 -0
- UQPyL-2.1.3/UQPyL/DoE/saltelli_sequence.py → uqpyl-2.1.4/UQPyL/DoE/saltelli.py +14 -21
- UQPyL-2.1.3/UQPyL/DoE/sobol_sequence.py → uqpyl-2.1.4/UQPyL/DoE/sobol.py +16 -20
- uqpyl-2.1.4/UQPyL/__init__.py +14 -0
- uqpyl-2.1.4/UQPyL/analysis/__init__.py +16 -0
- uqpyl-2.1.4/UQPyL/analysis/base.py +333 -0
- UQPyL-2.1.3/UQPyL/sensibility/delta_test.py → uqpyl-2.1.4/UQPyL/analysis/delta.py +43 -40
- {UQPyL-2.1.3/UQPyL/sensibility → uqpyl-2.1.4/UQPyL/analysis}/fast.py +48 -48
- UQPyL-2.1.3/UQPyL/sensibility/mars_sa.py → uqpyl-2.1.4/UQPyL/analysis/mars.py +48 -38
- {UQPyL-2.1.3/UQPyL/sensibility → uqpyl-2.1.4/UQPyL/analysis}/morris.py +62 -55
- {UQPyL-2.1.3/UQPyL/sensibility → uqpyl-2.1.4/UQPyL/analysis}/rbd_fast.py +51 -38
- {UQPyL-2.1.3/UQPyL/sensibility → uqpyl-2.1.4/UQPyL/analysis}/rsa.py +62 -48
- {UQPyL-2.1.3/UQPyL/sensibility → uqpyl-2.1.4/UQPyL/analysis}/sobol.py +88 -68
- uqpyl-2.1.4/UQPyL/inference/__init__.py +5 -0
- uqpyl-2.1.4/UQPyL/inference/amh.py +199 -0
- uqpyl-2.1.4/UQPyL/inference/base.py +383 -0
- uqpyl-2.1.4/UQPyL/inference/chain.py +45 -0
- uqpyl-2.1.4/UQPyL/inference/demc.py +178 -0
- uqpyl-2.1.4/UQPyL/inference/dream_zs.py +291 -0
- uqpyl-2.1.4/UQPyL/inference/mh.py +161 -0
- uqpyl-2.1.4/UQPyL/inference/mh_gibbs.py +185 -0
- uqpyl-2.1.4/UQPyL/optimization/__init__.py +7 -0
- UQPyL-2.1.3/UQPyL/optimization/algorithmABC.py → uqpyl-2.1.4/UQPyL/optimization/base.py +64 -37
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL/optimization/metric/gd.py +2 -2
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL/optimization/metric/hv.py +1 -11
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL/optimization/metric/igd.py +1 -3
- {UQPyL-2.1.3/UQPyL/optimization/multi_objective → uqpyl-2.1.4/UQPyL/optimization/moea}/moasmo.py +36 -37
- {UQPyL-2.1.3/UQPyL/optimization/multi_objective → uqpyl-2.1.4/UQPyL/optimization/moea}/moea_d.py +23 -31
- {UQPyL-2.1.3/UQPyL/optimization/multi_objective → uqpyl-2.1.4/UQPyL/optimization/moea}/nsga_ii.py +52 -54
- {UQPyL-2.1.3/UQPyL/optimization/multi_objective → uqpyl-2.1.4/UQPyL/optimization/moea}/nsga_iii.py +50 -54
- {UQPyL-2.1.3/UQPyL/optimization/multi_objective → uqpyl-2.1.4/UQPyL/optimization/moea}/rvea.py +34 -40
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL/optimization/population.py +39 -43
- uqpyl-2.1.4/UQPyL/optimization/result.py +263 -0
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/abc.py +22 -26
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/asmo.py +30 -36
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/csa.py +42 -54
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/de.py +36 -40
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/ego.py +36 -34
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/ga.py +37 -39
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/ml_sce_ua.py +29 -37
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/pso.py +44 -53
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/sce_ua.py +30 -40
- uqpyl-2.1.4/UQPyL/optimization/util/__init__.py +5 -0
- uqpyl-2.1.4/UQPyL/optimization/util/crowding_distance.py +63 -0
- UQPyL-2.1.3/UQPyL/optimization/utility_functions/operation_GA.py → uqpyl-2.1.4/UQPyL/optimization/util/ga_operator.py +7 -11
- uqpyl-2.1.4/UQPyL/optimization/util/non_dominated_sort.py +43 -0
- uqpyl-2.1.4/UQPyL/optimization/util/tournament.py +57 -0
- {UQPyL-2.1.3/UQPyL/problems → uqpyl-2.1.4/UQPyL/problem}/__init__.py +9 -9
- UQPyL-2.1.3/UQPyL/problems/problemABC.py → uqpyl-2.1.4/UQPyL/problem/base.py +12 -6
- {UQPyL-2.1.3/UQPyL/problems/multi_objective → uqpyl-2.1.4/UQPyL/problem/mop}/DTLZ.py +167 -80
- {UQPyL-2.1.3/UQPyL/problems/multi_objective → uqpyl-2.1.4/UQPyL/problem/mop}/ZDT.py +11 -11
- {UQPyL-2.1.3/UQPyL/problems → uqpyl-2.1.4/UQPyL/problem}/problem.py +1 -1
- {UQPyL-2.1.3/UQPyL/problems/single_objective → uqpyl-2.1.4/UQPyL/problem/sop}/single_constraint_problem.py +1 -1
- {UQPyL-2.1.3/UQPyL/problems/single_objective → uqpyl-2.1.4/UQPyL/problem/sop}/single_simple_problem.py +1 -1
- uqpyl-2.1.4/UQPyL/problem/util/non_dominated_sort.py +86 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/__init__.py +1 -1
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/auto_tuner.py +16 -16
- UQPyL-2.1.3/UQPyL/surrogates/surrogateABC.py → uqpyl-2.1.4/UQPyL/surrogate/base.py +9 -66
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/fnn/fully_connect_neural_network.py +7 -5
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/gaussian_process.py +10 -29
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/kriging/kriging.py +12 -12
- uqpyl-2.1.4/UQPyL/surrogate/mars/core/_basis.c +53209 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/mars/core/_forward.c +19228 -20367
- uqpyl-2.1.4/UQPyL/surrogate/mars/core/_knot_search.c +56144 -0
- uqpyl-2.1.4/UQPyL/surrogate/mars/core/_pruning.c +21153 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/mars/core/_qr.c +14568 -15539
- uqpyl-2.1.4/UQPyL/surrogate/mars/core/_record.c +28898 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/mars/core/_types.c +2995 -2538
- uqpyl-2.1.4/UQPyL/surrogate/mars/core/_util.c +15411 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/mars/mars.py +5 -5
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/radial_basis_function.py +5 -5
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/regression/lasso/lasso_fast.c +22204 -25017
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/regression/linear_regression.py +5 -5
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/regression/polynomial_regression.py +1 -2
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/svr/support_vector_machine.py +6 -5
- uqpyl-2.1.4/UQPyL/util/__init__.py +29 -0
- UQPyL-2.1.3/UQPyL/utility/metrics.py → uqpyl-2.1.4/UQPyL/util/metric.py +1 -1
- uqpyl-2.1.4/UQPyL/util/plot.py +772 -0
- UQPyL-2.1.3/UQPyL/utility/polynomial_features.py → uqpyl-2.1.4/UQPyL/util/poly.py +1 -1
- UQPyL-2.1.3/UQPyL/utility/data_selections.py → uqpyl-2.1.4/UQPyL/util/split.py +1 -0
- {UQPyL-2.1.3/UQPyL/utility → uqpyl-2.1.4/UQPyL/util}/verbose.py +202 -91
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL.egg-info/PKG-INFO +17 -5
- uqpyl-2.1.4/UQPyL.egg-info/SOURCES.txt +141 -0
- {UQPyL-2.1.3 → uqpyl-2.1.4}/pyproject.toml +2 -2
- uqpyl-2.1.4/setup.py +52 -0
- UQPyL-2.1.3/UQPyL/DoE/__init__.py +0 -10
- UQPyL-2.1.3/UQPyL/DoE/random.py +0 -54
- UQPyL-2.1.3/UQPyL/DoE/samplerABC.py +0 -54
- UQPyL-2.1.3/UQPyL/__init__.py +0 -13
- UQPyL-2.1.3/UQPyL/optimization/__init__.py +0 -5
- UQPyL-2.1.3/UQPyL/optimization/result.py +0 -241
- UQPyL-2.1.3/UQPyL/optimization/utility_functions/__init__.py +0 -4
- UQPyL-2.1.3/UQPyL/optimization/utility_functions/crowding_distance.py +0 -31
- UQPyL-2.1.3/UQPyL/optimization/utility_functions/ndsort.py +0 -50
- UQPyL-2.1.3/UQPyL/optimization/utility_functions/tournament_selection.py +0 -37
- UQPyL-2.1.3/UQPyL/problems/utility_functions/NDsort.py +0 -34
- UQPyL-2.1.3/UQPyL/sensibility/__init__.py +0 -16
- UQPyL-2.1.3/UQPyL/sensibility/saABC.py +0 -242
- UQPyL-2.1.3/UQPyL/surrogates/mars/core/_basis.c +0 -56172
- UQPyL-2.1.3/UQPyL/surrogates/mars/core/_knot_search.c +0 -57281
- UQPyL-2.1.3/UQPyL/surrogates/mars/core/_pruning.c +0 -20743
- UQPyL-2.1.3/UQPyL/surrogates/mars/core/_record.c +0 -29180
- UQPyL-2.1.3/UQPyL/surrogates/mars/core/_util.c +0 -14654
- UQPyL-2.1.3/UQPyL/utility/__init__.py +0 -19
- UQPyL-2.1.3/UQPyL.egg-info/SOURCES.txt +0 -132
- UQPyL-2.1.3/setup.py +0 -53
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL/optimization/metric/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/optimization/multi_objective → uqpyl-2.1.4/UQPyL/optimization/moea}/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/optimization/single_objective → uqpyl-2.1.4/UQPyL/optimization/soea}/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/optimization/utility_functions → uqpyl-2.1.4/UQPyL/optimization/util}/uniform_point.py +0 -0
- {UQPyL-2.1.3/UQPyL/problems/multi_objective → uqpyl-2.1.4/UQPyL/problem/mop}/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/problems/single_objective → uqpyl-2.1.4/UQPyL/problem/sop}/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/problems/utility_functions → uqpyl-2.1.4/UQPyL/problem/util}/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/problems/utility_functions → uqpyl-2.1.4/UQPyL/problem/util}/uniformPoint.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/fnn/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/fnn/_activation_funcs.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/fnn/base.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/kernel/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/kernel/base_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/kernel/c_kernel_.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/kernel/dot_kernel_.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/kernel/matern_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/kernel/rbf_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/gp/kernel/rq_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/kriging/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/kriging/kernel/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/kriging/kernel/base_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/kriging/kernel/cubic_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/kriging/kernel/exp_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/kriging/kernel/guass_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/mars/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/mars/core/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/kernel/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/kernel/base_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/kernel/cubic_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/kernel/gaussian_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/kernel/linear_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/kernel/multiquadric_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/rbf/kernel/thin_plate_spline_kernel.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/regression/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/regression/lasso/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/setting.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/svr/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/svr/core/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/svr/core/libsvm_interface.cpp +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/svr/core/svm.cpp +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/util/__init__.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/util/adam.py +0 -0
- {UQPyL-2.1.3/UQPyL/surrogates → uqpyl-2.1.4/UQPyL/surrogate}/util/boxmin.py +0 -0
- /UQPyL-2.1.3/UQPyL/utility/scalers.py → /uqpyl-2.1.4/UQPyL/util/scaler.py +0 -0
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL.egg-info/dependency_links.txt +0 -0
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL.egg-info/requires.txt +0 -0
- {UQPyL-2.1.3 → uqpyl-2.1.4}/UQPyL.egg-info/top_level.txt +0 -0
- {UQPyL-2.1.3 → uqpyl-2.1.4}/setup.cfg +0 -0
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: UQPyL
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.4
|
|
4
4
|
Summary: A python package for parameter uncertainty quantification and optimization
|
|
5
5
|
Author: wmtSky
|
|
6
6
|
Author-email: wmtSky <wmtsky@hhu.edu.cn>
|
|
7
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
8
7
|
Classifier: Programming Language :: Python :: 3.8
|
|
9
8
|
Classifier: Programming Language :: Python :: 3.9
|
|
10
9
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Requires-Dist: scipy
|
|
18
|
+
Requires-Dist: prettytable
|
|
19
|
+
Requires-Dist: h5py
|
|
20
|
+
Dynamic: author
|
|
16
21
|
|
|
17
22
|
# UQPyL: Uncertainty Quantification Python Lab
|
|
18
23
|
|
|
@@ -20,11 +25,18 @@ Description-Content-Type: text/markdown
|
|
|
20
25
|
|
|
21
26
|
[](https://badge.fury.io/py/UQPyL)     
|
|
22
27
|
|
|
23
|
-
**UQPyL** is a Python package for **Uncertainty Quantification** and **Optimization** of computational models and their associated problems (e.g., model calibration, resource scheduling, product design). It includes a wide range of methods and algorithms for Design of Experiments, Sensitivity Analysis, Optimization (Single- and Multi-objective). Additionally, **Surrogate Models** are built-in for solving computationally expensive problems.
|
|
28
|
+
**UQPyL** is a Python package for **Uncertainty Quantification** and **Optimization** of computational models and their associated problems (e.g., model calibration, resource scheduling, product design). It includes a wide range of methods and algorithms for Design of Experiments, Sensitivity Analysis, Bayesian Inference, Optimization (Single- and Multi-objective). Additionally, **Surrogate Models** are built-in for solving computationally expensive problems.
|
|
24
29
|
|
|
25
30
|
👉[中文简介](https://github.com/smasky/UQPyL/blob/dev/README_CN.md)
|
|
26
31
|
|
|
27
|
-
👉[
|
|
32
|
+
👉[中文文档](https://swat-uq.readthedocs.io/en/latest/zh/index.html)
|
|
33
|
+
|
|
34
|
+
👉[Documentation](https://uqpyl.readthedocs.io)
|
|
35
|
+
|
|
36
|
+
## Changelog
|
|
37
|
+
|
|
38
|
+
- 2025.12.14: Added the **inference** module. And results are now saved in **NetCDF** format, replacing the previous HDF output.
|
|
39
|
+
|
|
28
40
|
|
|
29
41
|
## Contents
|
|
30
42
|
|
|
@@ -4,11 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/py/UQPyL)     
|
|
6
6
|
|
|
7
|
-
**UQPyL** is a Python package for **Uncertainty Quantification** and **Optimization** of computational models and their associated problems (e.g., model calibration, resource scheduling, product design). It includes a wide range of methods and algorithms for Design of Experiments, Sensitivity Analysis, Optimization (Single- and Multi-objective). Additionally, **Surrogate Models** are built-in for solving computationally expensive problems.
|
|
7
|
+
**UQPyL** is a Python package for **Uncertainty Quantification** and **Optimization** of computational models and their associated problems (e.g., model calibration, resource scheduling, product design). It includes a wide range of methods and algorithms for Design of Experiments, Sensitivity Analysis, Bayesian Inference, Optimization (Single- and Multi-objective). Additionally, **Surrogate Models** are built-in for solving computationally expensive problems.
|
|
8
8
|
|
|
9
9
|
👉[中文简介](https://github.com/smasky/UQPyL/blob/dev/README_CN.md)
|
|
10
10
|
|
|
11
|
-
👉[
|
|
11
|
+
👉[中文文档](https://swat-uq.readthedocs.io/en/latest/zh/index.html)
|
|
12
|
+
|
|
13
|
+
👉[Documentation](https://uqpyl.readthedocs.io)
|
|
14
|
+
|
|
15
|
+
## Changelog
|
|
16
|
+
|
|
17
|
+
- 2025.12.14: Added the **inference** module. And results are now saved in **NetCDF** format, replacing the previous HDF output.
|
|
18
|
+
|
|
12
19
|
|
|
13
20
|
## Contents
|
|
14
21
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .lhs import LHS
|
|
2
|
+
from .full_fact import FFD
|
|
3
|
+
from .random import Random
|
|
4
|
+
from .base import Sampler
|
|
5
|
+
from .sobol import SobolSequence
|
|
6
|
+
from .fast import FASTSequence
|
|
7
|
+
from .morris import MorrisSequence
|
|
8
|
+
from .saltelli import SaltelliSequence
|
|
9
|
+
|
|
10
|
+
__all__ = ['LHS', 'FFD', 'Random', 'SaltelliSequence','SobolSequence',
|
|
11
|
+
'MorrisSequence', 'FASTSequence', 'Sampler']
|
|
12
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from ..problem import ProblemABC as Problem
|
|
5
|
+
|
|
6
|
+
class Sampler(metaclass = abc.ABCMeta):
|
|
7
|
+
|
|
8
|
+
def __init__(self):
|
|
9
|
+
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
def _generate(self, nt: int, nx: int, seed = None):
|
|
13
|
+
'''
|
|
14
|
+
nt: the number of sampled points
|
|
15
|
+
nx: the dimensions of decision variables
|
|
16
|
+
|
|
17
|
+
return:
|
|
18
|
+
ndarry[nt,nx]
|
|
19
|
+
'''
|
|
20
|
+
|
|
21
|
+
pass
|
|
22
|
+
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from typing import Union, Optional
|
|
3
3
|
|
|
4
|
-
from .
|
|
5
|
-
from ..
|
|
4
|
+
from .base import Sampler
|
|
5
|
+
from ..problem import ProblemABC as Problem
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class FASTSequence(Sampler):
|
|
8
8
|
"""
|
|
9
|
-
The sample
|
|
9
|
+
The sample method for FAST (Fourier Amplitude Sensitivity Test) method.
|
|
10
10
|
|
|
11
11
|
This class generates samples for the FAST method, which is used for sensitivity analysis
|
|
12
12
|
by decomposing the output variance into contributions from each input variable.
|
|
@@ -31,8 +31,10 @@ class FAST_Sequence(Sampler):
|
|
|
31
31
|
|
|
32
32
|
:param nt: Number of sample points.
|
|
33
33
|
:param nx: Input dimensions of sampled points.
|
|
34
|
+
|
|
34
35
|
:return: A 2D array of samples, normalized so factor values are uniformly spaced between zero and one.
|
|
35
36
|
"""
|
|
37
|
+
|
|
36
38
|
if nt <= 4 * self.M**2:
|
|
37
39
|
raise ValueError("The number of samples must be greater than 4 * M^2!")
|
|
38
40
|
|
|
@@ -55,37 +57,29 @@ class FAST_Sequence(Sampler):
|
|
|
55
57
|
idx = list(range(i)) + list(range(i + 1, nx))
|
|
56
58
|
w_tmp[idx] = w[1:]
|
|
57
59
|
idx = range(i * nt, (i + 1) * nt)
|
|
58
|
-
phi = 2 * np.pi *
|
|
60
|
+
phi = 2 * np.pi * self.rng.random()
|
|
59
61
|
sin_result = np.sin(w_tmp[:, None] * s + phi)
|
|
60
62
|
arsin_result = (1 / np.pi) * np.arcsin(sin_result) # Saltelli's formula
|
|
61
63
|
xInit[idx, :] = 0.5 + arsin_result.transpose()
|
|
62
64
|
|
|
63
65
|
return xInit
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
def sample(self, nt: int, nx: Optional[int] = None, problem: Optional[Problem] = None, random_seed: Optional[int] = None):
|
|
67
|
+
def sample(self, problem: Problem, nt: int, seed: int = None):
|
|
67
68
|
"""
|
|
68
69
|
Generate a sample for the FAST method.
|
|
69
70
|
|
|
71
|
+
:param problem: Problem instance to use bounds for sampling.
|
|
70
72
|
:param nt: Number of sample points.
|
|
71
73
|
:param nx: Input dimensions of sampled points.
|
|
72
|
-
:param problem: Problem instance to use bounds for sampling.
|
|
73
74
|
:param random_seed: Random seed for reproducibility.
|
|
75
|
+
|
|
74
76
|
:return: A 2D array of FAST samples.
|
|
75
77
|
"""
|
|
76
|
-
if random_seed is not None:
|
|
77
|
-
self.random_state = np.random.RandomState(random_seed)
|
|
78
|
-
else:
|
|
79
|
-
self.random_state = np.random.RandomState()
|
|
80
78
|
|
|
81
|
-
if
|
|
82
|
-
if problem.nInput != nx:
|
|
83
|
-
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
84
|
-
elif problem is None and nx is None:
|
|
85
|
-
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
79
|
+
self.rng = np.random.default_rng(seed) if seed is not None else np.random.default_rng()
|
|
86
80
|
|
|
87
|
-
nx = problem.nInput
|
|
81
|
+
nx = problem.nInput
|
|
88
82
|
|
|
89
|
-
return self._generate(nt, nx)
|
|
83
|
+
return problem._transform_unit_X(self._generate(nt, nx))
|
|
90
84
|
|
|
91
85
|
|
|
@@ -2,8 +2,8 @@ import numpy as np
|
|
|
2
2
|
from typing import Union, Optional
|
|
3
3
|
from itertools import product
|
|
4
4
|
|
|
5
|
-
from .
|
|
6
|
-
from ..
|
|
5
|
+
from .base import Sampler
|
|
6
|
+
from ..problem import ProblemABC as Problem
|
|
7
7
|
|
|
8
8
|
class FFD(Sampler):
|
|
9
9
|
"""
|
|
@@ -39,28 +39,19 @@ class FFD(Sampler):
|
|
|
39
39
|
|
|
40
40
|
return H
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
def sample(self, levels: Union[np.ndarray, int, list], nx: Optional[int] = None, problem: Optional[Problem] = None, random_seed: Optional[int] = None):
|
|
42
|
+
def sample(self, problem: Problem, levels: Union[np.ndarray, int, list], seed: Optional[int] = None):
|
|
44
43
|
"""
|
|
45
44
|
Generate a full factorial design sample.
|
|
46
45
|
|
|
47
|
-
:param levels: Levels for each input dimension. Can be an integer, list, or ndarray.
|
|
48
|
-
:param nx: Number of input dimensions.
|
|
49
46
|
:param problem: Problem instance to use bounds for sampling.
|
|
47
|
+
:param levels: Levels for each input dimension. Can be an integer, list, or ndarray.
|
|
50
48
|
:param random_seed: Random seed for reproducibility.
|
|
49
|
+
|
|
51
50
|
:return: A 2D array of full factorial design samples.
|
|
52
51
|
"""
|
|
53
|
-
if random_seed is not None:
|
|
54
|
-
self.random_state = np.random.RandomState(random_seed)
|
|
55
|
-
else:
|
|
56
|
-
self.random_state = np.random.RandomState()
|
|
57
|
-
|
|
58
|
-
if problem is not None and nx is not None:
|
|
59
|
-
if problem.nInput != nx:
|
|
60
|
-
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
61
|
-
elif problem is None and nx is None:
|
|
62
|
-
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
63
52
|
|
|
64
|
-
|
|
53
|
+
self.rng = np.random.default_rng(seed) if seed is not None else np.random.default_rng()
|
|
54
|
+
|
|
55
|
+
nx = problem.nInput
|
|
65
56
|
|
|
66
|
-
return self._generate(levels, nx)
|
|
57
|
+
return problem._transform_unit_X(self._generate(levels, nx))
|
|
@@ -2,26 +2,24 @@ from typing import Literal, Optional
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
from scipy.spatial.distance import pdist
|
|
4
4
|
|
|
5
|
-
from .
|
|
6
|
-
from ..
|
|
5
|
+
from .base import Sampler
|
|
6
|
+
from ..problem import ProblemABC as Problem
|
|
7
7
|
|
|
8
|
-
def _lhs_classic(nt: int, nx: int,
|
|
8
|
+
def _lhs_classic(nt: int, nx: int, rng):
|
|
9
9
|
"""
|
|
10
10
|
Generate a classic Latin Hypercube Sampling (LHS) design.
|
|
11
11
|
|
|
12
12
|
:param nt: Number of samples.
|
|
13
13
|
:param nx: Number of dimensions.
|
|
14
|
-
:param
|
|
14
|
+
:param rng: Random state for reproducibility.
|
|
15
15
|
:return: A 2D array of LHS samples.
|
|
16
16
|
"""
|
|
17
|
-
|
|
18
|
-
random_state = np.random.RandomState()
|
|
19
|
-
|
|
17
|
+
|
|
20
18
|
# Generate the intervals
|
|
21
19
|
cut = np.linspace(0, 1, nt + 1)
|
|
22
20
|
|
|
23
21
|
# Fill points uniformly in each interval
|
|
24
|
-
u =
|
|
22
|
+
u = rng.random((nt, nx))
|
|
25
23
|
a = cut[:nt]
|
|
26
24
|
b = cut[1:nt + 1]
|
|
27
25
|
rdpoints = np.zeros_like(u)
|
|
@@ -31,30 +29,26 @@ def _lhs_classic(nt: int, nx: int, random_state=None) -> np.ndarray:
|
|
|
31
29
|
# Make the random pairings
|
|
32
30
|
H = np.zeros_like(rdpoints)
|
|
33
31
|
for j in range(nx):
|
|
34
|
-
order =
|
|
32
|
+
order = rng.permutation(range(nt))
|
|
35
33
|
H[:, j] = rdpoints[order, j]
|
|
36
34
|
|
|
37
35
|
return H
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def _lhs_centered(nt: int, nx: int, random_state=None) -> np.ndarray:
|
|
37
|
+
def _lhs_centered(nt: int, nx: int, rng):
|
|
42
38
|
"""
|
|
43
39
|
Generate a centered Latin Hypercube Sampling (LHS) design.
|
|
44
40
|
|
|
45
41
|
:param nt: Number of samples.
|
|
46
42
|
:param nx: Number of dimensions.
|
|
47
|
-
:param
|
|
43
|
+
:param rng: Random state for reproducibility.
|
|
48
44
|
:return: A 2D array of centered LHS samples.
|
|
49
45
|
"""
|
|
50
|
-
|
|
51
|
-
random_state = np.random.RandomState()
|
|
52
|
-
|
|
46
|
+
|
|
53
47
|
# Generate the intervals
|
|
54
48
|
cut = np.linspace(0, 1, nt + 1)
|
|
55
49
|
|
|
56
50
|
# Fill points uniformly in each interval
|
|
57
|
-
u =
|
|
51
|
+
u = rng.random(nt, nx)
|
|
58
52
|
a = cut[:nt]
|
|
59
53
|
b = cut[1:nt + 1]
|
|
60
54
|
_center = (a + b)/2
|
|
@@ -62,31 +56,27 @@ def _lhs_centered(nt: int, nx: int, random_state=None) -> np.ndarray:
|
|
|
62
56
|
# Make the random pairings
|
|
63
57
|
H = np.zeros_like(u)
|
|
64
58
|
for j in range(nx):
|
|
65
|
-
H[:, j] =
|
|
59
|
+
H[:, j] = rng.permutation(_center)
|
|
66
60
|
|
|
67
61
|
return H
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def _lhs_maximin(nt: int, nx: int, iterations: int, random_state=None)-> np.ndarray:
|
|
63
|
+
def _lhs_maximin(nt: int, nx: int, iterations: int, rng):
|
|
72
64
|
"""
|
|
73
65
|
Generate a maximin Latin Hypercube Sampling (LHS) design.
|
|
74
66
|
|
|
75
67
|
:param nt: Number of samples.
|
|
76
68
|
:param nx: Number of dimensions.
|
|
77
69
|
:param iterations: Number of iterations to maximize the minimum distance.
|
|
78
|
-
:param
|
|
70
|
+
:param rng: Random state for reproducibility.
|
|
79
71
|
:return: A 2D array of maximin LHS samples.
|
|
80
72
|
"""
|
|
81
|
-
|
|
82
|
-
random_state=np.random.RandomState()
|
|
83
|
-
|
|
73
|
+
|
|
84
74
|
maxdist = 0
|
|
85
75
|
|
|
86
76
|
# Maximize the minimum distance between points
|
|
87
77
|
for i in range(iterations):
|
|
88
78
|
|
|
89
|
-
H_candidate = _lhs_classic(nt, nx,
|
|
79
|
+
H_candidate = _lhs_classic(nt, nx, rng)
|
|
90
80
|
|
|
91
81
|
d = pdist(H_candidate,'euclidean')
|
|
92
82
|
if maxdist<np.min(d):
|
|
@@ -95,25 +85,23 @@ def _lhs_maximin(nt: int, nx: int, iterations: int, random_state=None)-> np.ndar
|
|
|
95
85
|
|
|
96
86
|
return H
|
|
97
87
|
|
|
98
|
-
def _lhs_centered_maximin(nt: int, nx: int, iterations: int,
|
|
88
|
+
def _lhs_centered_maximin(nt: int, nx: int, iterations: int, rng):
|
|
99
89
|
"""
|
|
100
90
|
Generate a centered maximin Latin Hypercube Sampling (LHS) design.
|
|
101
91
|
|
|
102
92
|
:param nt: Number of samples.
|
|
103
93
|
:param nx: Number of dimensions.
|
|
104
94
|
:param iterations: Number of iterations to maximize the minimum distance.
|
|
105
|
-
:param
|
|
95
|
+
:param rng: Random state for reproducibility.
|
|
106
96
|
:return: A 2D array of centered maximin LHS samples.
|
|
107
97
|
"""
|
|
108
|
-
|
|
109
|
-
random_state=np.random.RandomState()
|
|
110
|
-
|
|
98
|
+
|
|
111
99
|
maxdist = 0
|
|
112
100
|
|
|
113
101
|
# Maximize the minimum distance between points
|
|
114
102
|
for i in range(iterations):
|
|
115
103
|
|
|
116
|
-
H_candidate = _lhs_centered(nt, nx,
|
|
104
|
+
H_candidate = _lhs_centered(nt, nx, rng)
|
|
117
105
|
d = pdist(H_candidate,'euclidean')
|
|
118
106
|
if maxdist<np.min(d):
|
|
119
107
|
maxdist = np.min(d)
|
|
@@ -122,25 +110,23 @@ def _lhs_centered_maximin(nt: int, nx: int, iterations: int, random_state=None)-
|
|
|
122
110
|
return H
|
|
123
111
|
################################################################################
|
|
124
112
|
|
|
125
|
-
def _lhs_correlate(nt: int, nx: int, iterations: int,
|
|
113
|
+
def _lhs_correlate(nt: int, nx: int, iterations: int, rng = None):
|
|
126
114
|
"""
|
|
127
115
|
Generate a correlation-optimized Latin Hypercube Sampling (LHS) design.
|
|
128
116
|
|
|
129
117
|
:param nt: Number of samples.
|
|
130
118
|
:param nx: Number of dimensions.
|
|
131
119
|
:param iterations: Number of iterations to minimize correlation.
|
|
132
|
-
:param
|
|
120
|
+
:param rng: Random state for reproducibility.
|
|
133
121
|
:return: A 2D array of correlation-optimized LHS samples.
|
|
134
122
|
"""
|
|
135
|
-
if random_state is None:
|
|
136
|
-
random_state=np.random.RandomState()
|
|
137
123
|
|
|
138
124
|
mincorr = np.inf
|
|
139
125
|
|
|
140
126
|
# Minimize the components correlation coefficients
|
|
141
127
|
for _ in range(iterations):
|
|
142
128
|
# Generate a random LHS
|
|
143
|
-
H_candidate = _lhs_classic(nt, nx,
|
|
129
|
+
H_candidate = _lhs_classic(nt, nx, rng)
|
|
144
130
|
R = np.corrcoef(H_candidate)
|
|
145
131
|
if np.max(np.abs(R[R!=1]))<mincorr:
|
|
146
132
|
mincorr = np.max(np.abs(R-np.eye(R.shape[0])))
|
|
@@ -149,8 +135,8 @@ def _lhs_correlate(nt: int, nx: int, iterations: int, random_state=None) -> np.n
|
|
|
149
135
|
|
|
150
136
|
return H
|
|
151
137
|
|
|
152
|
-
Criterion=Literal['classic','center','maximin','center_maximin','correlation']
|
|
153
|
-
LHS_METHOD={'classic': _lhs_classic, 'center': _lhs_centered, 'maximin': _lhs_maximin,
|
|
138
|
+
Criterion = Literal['classic','center','maximin','center_maximin','correlation']
|
|
139
|
+
LHS_METHOD = {'classic': _lhs_classic, 'center': _lhs_centered, 'maximin': _lhs_maximin,
|
|
154
140
|
'center_maximin': _lhs_centered_maximin, 'correlation': _lhs_correlate}
|
|
155
141
|
|
|
156
142
|
class LHS(Sampler):
|
|
@@ -162,16 +148,16 @@ class LHS(Sampler):
|
|
|
162
148
|
|
|
163
149
|
|
|
164
150
|
"""
|
|
165
|
-
def __init__(self, criterion: Criterion ='classic', iterations
|
|
151
|
+
def __init__(self, criterion: Criterion ='classic', iterations = 5):
|
|
166
152
|
"""
|
|
167
153
|
Initialize the LHS sampler with a specified criterion and number of iterations.
|
|
168
154
|
|
|
169
155
|
:param criterion: The LHS criterion to use.
|
|
170
156
|
:param iterations: Number of iterations for optimization methods.
|
|
171
157
|
"""
|
|
172
|
-
|
|
173
|
-
self.
|
|
174
|
-
|
|
158
|
+
|
|
159
|
+
self.criterion = criterion
|
|
160
|
+
self.iterations = iterations
|
|
175
161
|
#initial random state
|
|
176
162
|
super().__init__()
|
|
177
163
|
|
|
@@ -190,35 +176,25 @@ class LHS(Sampler):
|
|
|
190
176
|
Sampling_method = LHS_METHOD[self.criterion]
|
|
191
177
|
|
|
192
178
|
if self.criterion in ['maximin', 'center_maximin', 'correlation']:
|
|
193
|
-
xInit = Sampling_method(nt, nx, self.iterations, self.
|
|
179
|
+
xInit = Sampling_method(nt, nx, self.iterations, self.rng)
|
|
194
180
|
else:
|
|
195
|
-
xInit = Sampling_method(nt, nx, self.
|
|
181
|
+
xInit = Sampling_method(nt, nx, self.rng)
|
|
196
182
|
|
|
197
183
|
return xInit
|
|
198
184
|
|
|
199
|
-
|
|
200
|
-
def sample(self, nt: int, nx: int = None, problem: Problem = None, random_seed: Optional[int] = None) -> np.ndarray:
|
|
185
|
+
def sample(self, problem: Problem, nt: int, seed: Optional[int] = None):
|
|
201
186
|
"""
|
|
202
187
|
Generate a Latin-hypercube design.
|
|
203
188
|
|
|
204
189
|
:param nt: Number of sampled points.
|
|
205
190
|
:param nx: Input dimensions of sampled points.
|
|
206
191
|
:param problem: Problem instance to use bounds for sampling.
|
|
207
|
-
:param
|
|
192
|
+
:param seed: Random seed for reproducibility.
|
|
208
193
|
:return: A 2D array of LHS samples.
|
|
209
194
|
"""
|
|
210
195
|
|
|
211
|
-
if
|
|
212
|
-
self.random_state = np.random.RandomState(random_seed)
|
|
213
|
-
else:
|
|
214
|
-
self.random_state = np.random.RandomState()
|
|
215
|
-
|
|
216
|
-
if problem is not None and nx is not None:
|
|
217
|
-
if problem.nInput != nx:
|
|
218
|
-
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
219
|
-
elif problem is None and nx is None:
|
|
220
|
-
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
196
|
+
self.rng = np.random.default_rng(seed) if seed is not None else np.random.default_rng()
|
|
221
197
|
|
|
222
|
-
nx = problem.nInput
|
|
198
|
+
nx = problem.nInput
|
|
223
199
|
|
|
224
|
-
return self._generate(nt, nx)
|
|
200
|
+
return problem._transform_unit_X(self._generate(nt, nx))
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from typing import Optional
|
|
3
3
|
|
|
4
|
-
from .
|
|
5
|
-
from ..
|
|
4
|
+
from .base import Sampler
|
|
5
|
+
from ..problem import ProblemABC as Problem
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class MorrisSequence(Sampler):
|
|
8
8
|
"""
|
|
9
9
|
The sample technique for Morris analysis.
|
|
10
10
|
|
|
@@ -18,6 +18,7 @@ class Morris_Sequence(Sampler):
|
|
|
18
18
|
Reference:
|
|
19
19
|
[1] Max D. Morris (1991) Factorial Sampling Plans for Preliminary Computational Experiments, Technometrics, 33:2, 161-174
|
|
20
20
|
"""
|
|
21
|
+
|
|
21
22
|
def __init__(self, numLevels: int = 4):
|
|
22
23
|
"""
|
|
23
24
|
Initialize the Morris Sequence sampler with a specified number of levels.
|
|
@@ -25,6 +26,7 @@ class Morris_Sequence(Sampler):
|
|
|
25
26
|
:param numLevels: Number of levels for the Morris method.
|
|
26
27
|
"""
|
|
27
28
|
super().__init__()
|
|
29
|
+
|
|
28
30
|
self.numLevels = numLevels
|
|
29
31
|
|
|
30
32
|
def _generate(self, nt: int, nx: int):
|
|
@@ -38,35 +40,27 @@ class Morris_Sequence(Sampler):
|
|
|
38
40
|
xInit = np.zeros((nt * (nx + 1), nx))
|
|
39
41
|
|
|
40
42
|
for i in range(nt):
|
|
43
|
+
|
|
41
44
|
xInit[i * (nx + 1):(i + 1) * (nx + 1), :] = self._generate_trajectory(nx)
|
|
42
45
|
|
|
43
46
|
return xInit
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
def sample(self, nt: int, nx: Optional[int] = None, problem: Optional[Problem] = None, random_seed: Optional[int] = None):
|
|
48
|
+
def sample(self, problem: Problem, nt: int, seed: Optional[int] = None):
|
|
47
49
|
"""
|
|
48
50
|
Generate a sample for the Morris method.
|
|
49
51
|
|
|
50
|
-
:param nt: Number of trajectories.
|
|
51
|
-
:param nx: Input dimensions of sampled points.
|
|
52
52
|
:param problem: Problem instance to use bounds for sampling.
|
|
53
|
+
:param nt: Number of trajectories.
|
|
53
54
|
:param random_seed: Random seed for reproducibility.
|
|
55
|
+
|
|
54
56
|
:return: A 2D array of samples.
|
|
55
57
|
"""
|
|
56
|
-
if random_seed is not None:
|
|
57
|
-
self.random_state = np.random.RandomState(random_seed)
|
|
58
|
-
else:
|
|
59
|
-
self.random_state = np.random.RandomState()
|
|
60
58
|
|
|
61
|
-
if
|
|
62
|
-
if problem.nInput != nx:
|
|
63
|
-
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
64
|
-
elif problem is None and nx is None:
|
|
65
|
-
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
59
|
+
self.rng = np.random.default_rng(seed) if seed is not None else np.random.default_rng()
|
|
66
60
|
|
|
67
|
-
nx = problem.nInput
|
|
61
|
+
nx = problem.nInput
|
|
68
62
|
|
|
69
|
-
return self._generate(nt, nx)
|
|
63
|
+
return problem._transform_unit_X(self._generate(nt, nx))
|
|
70
64
|
|
|
71
65
|
def _generate_trajectory(self, nx: int):
|
|
72
66
|
"""
|
|
@@ -80,14 +74,14 @@ class Morris_Sequence(Sampler):
|
|
|
80
74
|
B = np.tril(np.ones([nx + 1, nx], dtype=int), -1)
|
|
81
75
|
|
|
82
76
|
# From paper[1] page 164
|
|
83
|
-
D_star = np.diag(
|
|
77
|
+
D_star = np.diag(self.rng.choice([-1, 1], nx)) # Step 1
|
|
84
78
|
J = np.ones((nx + 1, nx))
|
|
85
79
|
|
|
86
80
|
levels_grids = np.linspace(0, 1 - delta, int(self.numLevels / 2))
|
|
87
|
-
x_star =
|
|
81
|
+
x_star = self.rng.choice(levels_grids, nx).reshape(1, -1) # Step 2
|
|
88
82
|
|
|
89
83
|
P_star = np.zeros((nx, nx))
|
|
90
|
-
cols =
|
|
84
|
+
cols = self.rng.choice(nx, nx, replace=False)
|
|
91
85
|
P_star[np.arange(nx), cols] = 1 # Step 3
|
|
92
86
|
|
|
93
87
|
element_a = J[0, :] * x_star
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from .base import Sampler
|
|
5
|
+
from ..problem import ProblemABC as Problem
|
|
6
|
+
|
|
7
|
+
class Random(Sampler):
|
|
8
|
+
"""
|
|
9
|
+
Random Design
|
|
10
|
+
|
|
11
|
+
Methods:
|
|
12
|
+
sample: Generate a random design.
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
>>> random = Random()
|
|
16
|
+
>>> random.sample(10, 10) or random(10, 10)
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def _generate(self, nt: int, nx: int):
|
|
20
|
+
"""
|
|
21
|
+
Generate a random sample.
|
|
22
|
+
|
|
23
|
+
:param nt: Number of sampled points.
|
|
24
|
+
:param nx: Input dimensions of sampled points.
|
|
25
|
+
:return: A 2D array of random samples.
|
|
26
|
+
"""
|
|
27
|
+
H = self.rng.random((nt, nx))
|
|
28
|
+
|
|
29
|
+
return H
|
|
30
|
+
|
|
31
|
+
def sample(self, problem: Problem, nt: int, seed: Optional[int] = None):
|
|
32
|
+
"""
|
|
33
|
+
Generate a sample with random values between zero and one.
|
|
34
|
+
|
|
35
|
+
:param problem: Problem instance to use bounds for sampling.
|
|
36
|
+
:param nt: Number of sampled points.
|
|
37
|
+
:param random_seed: Random seed for reproducibility.
|
|
38
|
+
:return: A 2D array of random samples.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
self.rng = np.random.default_rng(seed) if seed is not None else np.random.default_rng()
|
|
42
|
+
|
|
43
|
+
nx = problem.nInput
|
|
44
|
+
|
|
45
|
+
return problem._transform_unit_X(self._generate(nt, nx))
|