UQPyL 2.0.7__tar.gz → 2.0.9__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 → UQPyL-2.0.9}/PKG-INFO +1 -1
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/DoE/__init__.py +3 -1
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/DoE/morris_sequence.py +8 -8
- UQPyL-2.0.9/UQPyL/DoE/saltelli_sequence.py +90 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/DoE/sobol_sequence.py +4 -4
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/__init__.py +1 -1
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/algorithmABC.py +6 -2
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/fast.py +1 -1
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/morris.py +3 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/rbd_fast.py +1 -1
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/rsa.py +31 -11
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/sobol.py +5 -5
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/utility/verbose.py +41 -19
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL.egg-info/PKG-INFO +1 -1
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL.egg-info/SOURCES.txt +1 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/pyproject.toml +1 -1
- {UQPyL-2.0.7 → UQPyL-2.0.9}/setup.py +1 -1
- {UQPyL-2.0.7 → UQPyL-2.0.9}/LICENSE.md +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/README.md +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/DoE/fast_sequence.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/DoE/full_fact.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/DoE/lhs.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/DoE/random.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/DoE/samplerABC.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/mathematics/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/mathematics/adam.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/mathematics/boxmin.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/metric/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/metric/gd.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/metric/hv.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/metric/igd.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/multi_objective/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/multi_objective/moasmo.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/multi_objective/moea_d.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/multi_objective/nsga_ii.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/multi_objective/rvea.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/population.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/result.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/_binary_ga.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/abc.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/asmo.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/csa.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/de.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/ego.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/ga.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/ml_sce_ua.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/pso.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/single_objective/sce_ua.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/utility_functions/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/utility_functions/crowding_distance.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/utility_functions/ndsort.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/utility_functions/operationGA.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/utility_functions/tournament_selection.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/optimization/utility_functions/uniform_point.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/multi_objective/DTLZ.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/multi_objective/ZDT.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/multi_objective/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/pratical_problem.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/problemABC.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/single_objective/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/single_objective/single_base_problem.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/utility_functions/NDsort.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/utility_functions/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/problems/utility_functions/uniformPoint.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/delta_test.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/mars_sa.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/sensibility/saABC.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/fnn/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/fnn/_activation_funcs.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/fnn/base.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/fnn/fully_connect_neural_network.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/gaussian_process.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/kernel/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/kernel/base_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/kernel/c_kernel_.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/kernel/dot_kernel_.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/kernel/matern_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/kernel/rbf_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/gp/kernel/rq_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/kriging/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/kriging/kernel/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/kriging/kernel/base_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/kriging/kernel/cubic_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/kriging/kernel/exp_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/kriging/kernel/guass_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/kriging/kriging.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/_basis.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/_forward.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/_knot_search.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/_pruning.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/_qr.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/_record.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/_types.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/core/_util.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/mars/mars.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/kernel/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/kernel/base_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/kernel/cubic_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/kernel/gaussian_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/kernel/linear_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/kernel/multiquadric_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/kernel/thin_plate_spline_kernel.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/rbf/radial_basis_function.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/regression/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/regression/lasso/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/regression/lasso/lasso_fast.c +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/regression/linear_regression.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/regression/polynomial_regression.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/setting.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/surrogateABC.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/svr/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/svr/core/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/svr/core/libsvm_interface.cpp +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/svr/core/svm.cpp +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/surrogates/svr/support_vector_machine.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/utility/__init__.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/utility/grid_search.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/utility/metrics.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/utility/model_selections.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/utility/polynomial_features.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL/utility/scalers.py +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL.egg-info/dependency_links.txt +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL.egg-info/requires.txt +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/UQPyL.egg-info/top_level.txt +0 -0
- {UQPyL-2.0.7 → UQPyL-2.0.9}/setup.cfg +0 -0
|
@@ -5,4 +5,6 @@ from .samplerABC import Sampler
|
|
|
5
5
|
from .sobol_sequence import Sobol_Sequence
|
|
6
6
|
from .fast_sequence import FAST_Sequence
|
|
7
7
|
from .morris_sequence import Morris_Sequence
|
|
8
|
-
|
|
8
|
+
from .saltelli_sequence import Saltelli_Sequence
|
|
9
|
+
|
|
10
|
+
__all__=['LHS', 'FFD', 'Random', 'Saltelli_Sequence','Sobol_Sequence', 'Morris_Sequence','FAST_Sequence','Sampler']
|
|
@@ -9,23 +9,23 @@ class Morris_Sequence(Sampler):
|
|
|
9
9
|
The sample technique for Morris analysis
|
|
10
10
|
|
|
11
11
|
Parameters:
|
|
12
|
-
|
|
13
|
-
Morris et al[1]. recommend the
|
|
12
|
+
numLevels (p): each x_i would take value on {0, 1/(p-1), 2/(p-1), ..., 1}.
|
|
13
|
+
Morris et al[1]. recommend the numLevels to be even and range from 4 and 10.
|
|
14
14
|
|
|
15
15
|
Methods:
|
|
16
16
|
__call__ or sample: Generate a sample for FAST method
|
|
17
17
|
|
|
18
18
|
Examples:
|
|
19
|
-
>>> mor_seq=Morris_Sequence(
|
|
19
|
+
>>> mor_seq=Morris_Sequence(numLevels=4)
|
|
20
20
|
>>> mor_seq.sample(100, 4) or mor_seq(100, 4)
|
|
21
21
|
|
|
22
22
|
Reference:
|
|
23
23
|
[1] Max D. Morris (1991) Factorial Sampling Plans for Preliminary Computational Experiments, Technometrics, 33:2, 161-174
|
|
24
24
|
'''
|
|
25
|
-
def __init__(self,
|
|
25
|
+
def __init__(self, numLevels: int=4):
|
|
26
26
|
|
|
27
27
|
super().__init__()
|
|
28
|
-
self.
|
|
28
|
+
self.numLevels=numLevels
|
|
29
29
|
|
|
30
30
|
def _generate(self, nt: int, nx: int):
|
|
31
31
|
'''
|
|
@@ -65,11 +65,11 @@ class Morris_Sequence(Sampler):
|
|
|
65
65
|
|
|
66
66
|
nx=problem.nInput if problem is not None else nx
|
|
67
67
|
|
|
68
|
-
self._generate(nt, nx)
|
|
68
|
+
return self._generate(nt, nx)
|
|
69
69
|
|
|
70
70
|
def _generate_trajectory(self, nx: int):
|
|
71
71
|
|
|
72
|
-
delta=self.
|
|
72
|
+
delta=self.numLevels/(2*(self.numLevels-1))
|
|
73
73
|
|
|
74
74
|
B=np.tril(np.ones([nx + 1, nx], dtype=int), -1)
|
|
75
75
|
|
|
@@ -77,7 +77,7 @@ class Morris_Sequence(Sampler):
|
|
|
77
77
|
D_star = np.diag(np.random.choice([-1, 1], nx)) #step1
|
|
78
78
|
J=np.ones((nx+1, nx))
|
|
79
79
|
|
|
80
|
-
levels_grids=np.linspace(0, 1-delta, int(self.
|
|
80
|
+
levels_grids=np.linspace(0, 1-delta, int(self.numLevels / 2))
|
|
81
81
|
x_star=np.random.choice(levels_grids, nx).reshape(1,-1) #step2
|
|
82
82
|
|
|
83
83
|
P_star=np.zeros((nx,nx))
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from scipy.stats import qmc
|
|
4
|
+
from .samplerABC import Sampler, decoratorRescale
|
|
5
|
+
from ..problems import ProblemABC as Problem
|
|
6
|
+
|
|
7
|
+
class Saltelli_Sequence(Sampler):
|
|
8
|
+
|
|
9
|
+
def __init__(self, scramble: bool=True, skipValue: int=0, calSecondOrder: bool=False):
|
|
10
|
+
|
|
11
|
+
super().__init__()
|
|
12
|
+
|
|
13
|
+
self.scramble=scramble
|
|
14
|
+
self.skipValue=skipValue
|
|
15
|
+
self.calSecondOrder=calSecondOrder
|
|
16
|
+
|
|
17
|
+
@decoratorRescale
|
|
18
|
+
def sample(self, nt: int, nx: Optional[int] = None, problem: Optional[Problem] = None, random_seed: Optional[int] = None):
|
|
19
|
+
|
|
20
|
+
if random_seed is not None:
|
|
21
|
+
self.random_state = np.random.RandomState(random_seed)
|
|
22
|
+
else:
|
|
23
|
+
self.random_state = np.random.RandomState()
|
|
24
|
+
|
|
25
|
+
if problem is not None and nx is not None:
|
|
26
|
+
if(problem.nInput!=nx):
|
|
27
|
+
raise ValueError('The input dimensions of the problem and the samples must be the same')
|
|
28
|
+
elif problem is None and nx is None:
|
|
29
|
+
raise ValueError('Either the problem or the input dimensions must be provided')
|
|
30
|
+
|
|
31
|
+
nx=problem.nInput if problem is not None else nx
|
|
32
|
+
|
|
33
|
+
return self._generate(nt, nx)
|
|
34
|
+
|
|
35
|
+
def _generate(self, nt: int, nx: int):
|
|
36
|
+
|
|
37
|
+
N=nt
|
|
38
|
+
nInput=nx
|
|
39
|
+
skipValue=self.skipValue
|
|
40
|
+
|
|
41
|
+
calSecondOrder=self.calSecondOrder
|
|
42
|
+
|
|
43
|
+
M=None
|
|
44
|
+
if skipValue>0 and isinstance(skipValue, int):
|
|
45
|
+
|
|
46
|
+
M=skipValue
|
|
47
|
+
|
|
48
|
+
if not((M&(M-1))==0 and (M!=0 and M-1!=0)):
|
|
49
|
+
raise ValueError("skip value must be a power of 2!")
|
|
50
|
+
|
|
51
|
+
if N<M:
|
|
52
|
+
raise ValueError("N must be greater than skip value you set!")
|
|
53
|
+
|
|
54
|
+
elif skipValue<0 or not isinstance(skipValue, int):
|
|
55
|
+
raise ValueError("skip value must be a positive integer!")
|
|
56
|
+
|
|
57
|
+
sampler=qmc.Sobol(nInput*2, scramble=self.scramble, seed=1)
|
|
58
|
+
|
|
59
|
+
if M:
|
|
60
|
+
sampler.fast_forward(M)
|
|
61
|
+
|
|
62
|
+
if calSecondOrder:
|
|
63
|
+
saltelliSequence=np.zeros(((2*nInput+2)*N, nInput))
|
|
64
|
+
else:
|
|
65
|
+
saltelliSequence=np.zeros(((nInput+2)*N, nInput))
|
|
66
|
+
|
|
67
|
+
baseSequence=sampler.random(N)
|
|
68
|
+
|
|
69
|
+
index=0
|
|
70
|
+
for i in range(N):
|
|
71
|
+
|
|
72
|
+
saltelliSequence[index, :]=baseSequence[i, :nInput]
|
|
73
|
+
|
|
74
|
+
index+=1
|
|
75
|
+
|
|
76
|
+
saltelliSequence[index:index+nInput,:]=np.tile(baseSequence[i, :nInput], (nInput, 1))
|
|
77
|
+
saltelliSequence[index:index+nInput,:][np.diag_indices(nInput)]=baseSequence[i, nInput:]
|
|
78
|
+
index+=nInput
|
|
79
|
+
|
|
80
|
+
if calSecondOrder:
|
|
81
|
+
saltelliSequence[index:index+nInput,:]=np.tile(baseSequence[i, nInput:], (nInput, 1))
|
|
82
|
+
saltelliSequence[index:index+nInput,:][np.diag_indices(nInput)]=baseSequence[i, :nInput]
|
|
83
|
+
index+=nInput
|
|
84
|
+
|
|
85
|
+
saltelliSequence[index,:]=baseSequence[i, nInput:nInput*2]
|
|
86
|
+
index+=1
|
|
87
|
+
|
|
88
|
+
xSample=saltelliSequence
|
|
89
|
+
|
|
90
|
+
return xSample
|
|
@@ -19,12 +19,12 @@ class Sobol_Sequence(Sampler):
|
|
|
19
19
|
__call__ or sample: generate the shape of (nt*nx, nx) and numpy array Sobol sequence.
|
|
20
20
|
|
|
21
21
|
'''
|
|
22
|
-
def __init__(self, scramble: bool=True,
|
|
22
|
+
def __init__(self, scramble: bool=True, skipValue: int=0):
|
|
23
23
|
|
|
24
24
|
super().__init__()
|
|
25
25
|
|
|
26
26
|
self.scramble=scramble
|
|
27
|
-
self.
|
|
27
|
+
self.skipValue=skipValue
|
|
28
28
|
|
|
29
29
|
def _generate(self, nt: int, nx: int):
|
|
30
30
|
'''
|
|
@@ -32,9 +32,9 @@ class Sobol_Sequence(Sampler):
|
|
|
32
32
|
'''
|
|
33
33
|
|
|
34
34
|
sampler=Sobol(d=nx, scramble=self.scramble)
|
|
35
|
-
xInit=sampler.random(nt+self.
|
|
35
|
+
xInit=sampler.random(nt+self.skipValue)
|
|
36
36
|
|
|
37
|
-
return xInit[self.
|
|
37
|
+
return xInit[self.skipValue:, :]
|
|
38
38
|
|
|
39
39
|
@decoratorRescale
|
|
40
40
|
def sample(self, nt: int, nx: Optional[int] = None, problem: Optional[Problem] = None, random_seed: Optional[int] = None) -> np.ndarray:
|
|
@@ -58,8 +58,12 @@ class Algorithm(metaclass=abc.ABCMeta):
|
|
|
58
58
|
|
|
59
59
|
def checkTermination(self):
|
|
60
60
|
|
|
61
|
-
if
|
|
62
|
-
|
|
61
|
+
if Verbose.isStop: #TODO
|
|
62
|
+
|
|
63
|
+
return False
|
|
64
|
+
|
|
65
|
+
if self.FEs<self.maxFEs:
|
|
66
|
+
if self.maxIter is None or self.iters<self.maxIter:
|
|
63
67
|
if self.maxTolerateTimes is None or self.tolerateTimes<=self.maxTolerateTimes:
|
|
64
68
|
self.iters+=1
|
|
65
69
|
return True
|
|
@@ -146,7 +146,7 @@ class FAST(SA):
|
|
|
146
146
|
idx=np.arange(i*n, (i+1)*n)
|
|
147
147
|
Y_sub=Y[idx]
|
|
148
148
|
#fft
|
|
149
|
-
f=np.fft.fft(Y_sub
|
|
149
|
+
f=np.fft.fft(Y_sub)
|
|
150
150
|
# Sp = np.power(np.absolute(f[np.arange(1, np.ceil((self.N_within_sampler-1)/2), dtype=np.int32)-1])/self.N_within_sampler, 2) #TODO 1-(NS-1)/2
|
|
151
151
|
Sp = np.power(np.absolute(f[np.arange(1, np.ceil(n / 2), dtype=np.int32)]) / n, 2)
|
|
152
152
|
V=2.0*np.sum(Sp)
|
|
@@ -144,6 +144,9 @@ class Morris(SA):
|
|
|
144
144
|
self.record('mu_star', problem.x_labels, mu_star)
|
|
145
145
|
self.record('sigma', problem.x_labels, sigma)
|
|
146
146
|
|
|
147
|
+
self.record('S1', problem.x_labels, mu)
|
|
148
|
+
self.record('ST', problem.x_labels, sigma)
|
|
149
|
+
|
|
147
150
|
return self.result
|
|
148
151
|
|
|
149
152
|
def summary(self):
|
|
@@ -106,19 +106,39 @@ class RSA(SA):
|
|
|
106
106
|
|
|
107
107
|
X, Y=self.__check_and_scale_xy__(X, Y)
|
|
108
108
|
|
|
109
|
-
seq = np.linspace(0, 1, nRegion + 1)
|
|
109
|
+
seq = np.linspace(0.0, 1.0, nRegion + 1)
|
|
110
110
|
results = np.full((nRegion, nInput), np.nan)
|
|
111
111
|
X_di = np.empty(X.shape[0])
|
|
112
112
|
|
|
113
|
+
trr=Y.ravel()
|
|
114
|
+
mrr=X_di
|
|
115
|
+
|
|
113
116
|
for d_i in range(nInput):
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
X_di[:] = X[:, d_i]
|
|
118
|
+
|
|
119
|
+
quants=np.quantile(trr, seq)
|
|
120
|
+
|
|
121
|
+
b = (quants[0] <= trr) & (trr <= quants[1])
|
|
122
|
+
if self._has_samples(Y, b):
|
|
123
|
+
results[0, d_i] = cramervonmises_2samp(mrr[b].ravel(), mrr[~b].ravel()).statistic
|
|
124
|
+
|
|
125
|
+
for bin_index in range(1, nRegion):
|
|
126
|
+
|
|
127
|
+
b = (quants[bin_index] < trr) & (trr <= quants[bin_index+1])
|
|
128
|
+
|
|
129
|
+
if self._has_samples(Y, b):
|
|
130
|
+
results[bin_index, d_i] = cramervonmises_2samp(mrr[b].ravel(), mrr[~b].ravel()).statistic
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
self.record("S1", problem.x_labels, np.mean(results, axis=0))
|
|
134
|
+
self.record("S1_Detail", problem.x_labels, np.mean(results, axis=0))
|
|
135
|
+
|
|
136
|
+
return self.result
|
|
137
|
+
|
|
138
|
+
def _has_samples(self, y, sel):
|
|
123
139
|
|
|
124
|
-
return
|
|
140
|
+
return(
|
|
141
|
+
(np.count_nonzero(sel) !=0)
|
|
142
|
+
and (len(y[~sel])!=0 )
|
|
143
|
+
and np.unique(y[sel]).size > 1
|
|
144
|
+
)
|
|
@@ -100,8 +100,8 @@ class Sobol(SA):
|
|
|
100
100
|
if not((M&(M-1))==0 and (M!=0 and M-1!=0)):
|
|
101
101
|
raise ValueError("skip value must be a power of 2!")
|
|
102
102
|
|
|
103
|
-
if N
|
|
104
|
-
raise ValueError("
|
|
103
|
+
if N<M:
|
|
104
|
+
raise ValueError("N must be greater than skip value you set!")
|
|
105
105
|
|
|
106
106
|
elif skipValue<0 or not isinstance(skipValue, int):
|
|
107
107
|
raise ValueError("skip value must be a positive integer!")
|
|
@@ -200,10 +200,10 @@ class Sobol(SA):
|
|
|
200
200
|
S_Labels.append(f"{problem.x_labels[j]}-{problem.x_labels[k]}")
|
|
201
201
|
|
|
202
202
|
#Record Data
|
|
203
|
-
self.record('S1
|
|
203
|
+
self.record('S1', problem.x_labels, S1)
|
|
204
204
|
if calSecondOrder:
|
|
205
|
-
self.record('S2
|
|
206
|
-
self.record('ST
|
|
205
|
+
self.record('S2', S_Labels, S2)
|
|
206
|
+
self.record('ST', problem.x_labels, ST)
|
|
207
207
|
|
|
208
208
|
return self.result
|
|
209
209
|
|
|
@@ -18,6 +18,10 @@ class Verbose():
|
|
|
18
18
|
saveFlag=False
|
|
19
19
|
verbose=False
|
|
20
20
|
workDir=os.getcwd()
|
|
21
|
+
iterEmit=None
|
|
22
|
+
verboseEmit=None
|
|
23
|
+
isStop=False
|
|
24
|
+
total_width=os.get_terminal_size().columns
|
|
21
25
|
@staticmethod
|
|
22
26
|
def output(obj):
|
|
23
27
|
|
|
@@ -25,20 +29,24 @@ class Verbose():
|
|
|
25
29
|
obj=str(obj)+'\n'
|
|
26
30
|
|
|
27
31
|
if Verbose.logFlag:
|
|
32
|
+
|
|
28
33
|
Verbose.logLines.append(obj)
|
|
29
34
|
|
|
35
|
+
if Verbose.verboseEmit:
|
|
36
|
+
|
|
37
|
+
Verbose.verboseEmit.send(obj)
|
|
38
|
+
|
|
30
39
|
if Verbose.verbose:
|
|
40
|
+
|
|
31
41
|
print(obj)
|
|
32
42
|
|
|
33
43
|
@staticmethod
|
|
34
44
|
def verboseSetting(obj):
|
|
35
|
-
|
|
36
|
-
total_width=os.get_terminal_size().columns
|
|
37
45
|
|
|
38
46
|
if obj.verbose or obj.logFlag:
|
|
39
47
|
|
|
40
48
|
title=obj.name+" Setting"
|
|
41
|
-
spacing=int((total_width-len(title))/2)
|
|
49
|
+
spacing=int((Verbose.total_width-len(title))/2)
|
|
42
50
|
Verbose.output("="*spacing+title+"="*spacing)
|
|
43
51
|
keys=obj.setting.keys
|
|
44
52
|
values=obj.setting.values
|
|
@@ -126,17 +134,20 @@ class Verbose():
|
|
|
126
134
|
@functools.wraps(func)
|
|
127
135
|
def wrapper(obj, *args, **kwargs):
|
|
128
136
|
|
|
137
|
+
if Verbose.iterEmit:
|
|
138
|
+
|
|
139
|
+
Verbose.iterEmit.send()
|
|
140
|
+
|
|
129
141
|
func(obj, *args, **kwargs)
|
|
130
142
|
|
|
131
143
|
if obj.verbose and obj.iters%obj.verboseFreq==0:
|
|
132
|
-
total_width=os.get_terminal_size().columns
|
|
133
144
|
title="FEs: "+str(obj.FEs)+" | Iters: "+str(obj.iters)
|
|
134
|
-
spacing=int((total_width-len(title))/2)
|
|
145
|
+
spacing=int((Verbose.total_width-len(title))/2)
|
|
135
146
|
Verbose.output("="*spacing+title+"="*spacing)
|
|
136
147
|
if obj.problem.nOutput==1:
|
|
137
|
-
Verbose.verboseSingleSolutions(obj.result.bestDec, obj.result.bestObj, obj.problem.x_labels, obj.problem.y_labels, obj.FEs, obj.iters, total_width)
|
|
148
|
+
Verbose.verboseSingleSolutions(obj.result.bestDec, obj.result.bestObj, obj.problem.x_labels, obj.problem.y_labels, obj.FEs, obj.iters, Verbose.total_width)
|
|
138
149
|
else:
|
|
139
|
-
Verbose.verboseMultiSolutions(obj.result.bestDec, obj.result.bestMetric, obj.FEs, obj.iters, total_width)
|
|
150
|
+
Verbose.verboseMultiSolutions(obj.result.bestDec, obj.result.bestMetric, obj.FEs, obj.iters, Verbose.total_width)
|
|
140
151
|
return wrapper
|
|
141
152
|
|
|
142
153
|
@staticmethod
|
|
@@ -220,9 +231,8 @@ class Verbose():
|
|
|
220
231
|
|
|
221
232
|
if Verbose.verbose or Verbose.logFlag:
|
|
222
233
|
|
|
223
|
-
total_width=os.get_terminal_size().columns
|
|
224
234
|
title=obj.name+" Setting"
|
|
225
|
-
spacing=int((total_width-len(title))/2)
|
|
235
|
+
spacing=int((Verbose.total_width-len(title))/2)
|
|
226
236
|
Verbose.output("="*spacing+title+"="*spacing)
|
|
227
237
|
|
|
228
238
|
keys=obj.setting.keys
|
|
@@ -231,6 +241,11 @@ class Verbose():
|
|
|
231
241
|
table.add_row(values)
|
|
232
242
|
Verbose.output(table)
|
|
233
243
|
|
|
244
|
+
#TODO
|
|
245
|
+
if Verbose.iterEmit:
|
|
246
|
+
|
|
247
|
+
Verbose.iterEmit.send()
|
|
248
|
+
|
|
234
249
|
startTime=time.time()
|
|
235
250
|
res=func(obj, *args, **kwargs)
|
|
236
251
|
endTime=time.time()
|
|
@@ -239,16 +254,16 @@ class Verbose():
|
|
|
239
254
|
if Verbose.verbose:
|
|
240
255
|
|
|
241
256
|
title="Conclusion"
|
|
242
|
-
spacing=int((total_width-len(title))/2)
|
|
257
|
+
spacing=int((Verbose.total_width-len(title))/2)
|
|
243
258
|
Verbose.output("="*spacing+title+"="*spacing)
|
|
244
259
|
Verbose.output("Time: "+Verbose.formatTime(totalTime))
|
|
245
260
|
Verbose.output(f"Used FEs: {obj.FEs} | Iters: {obj.iters}")
|
|
246
261
|
Verbose.output(f"Best Objs and Best Decision with the FEs")
|
|
247
262
|
|
|
248
263
|
if obj.problem.nOutput==1:
|
|
249
|
-
Verbose.verboseSingleSolutions(res.bestDec, res.bestObj, obj.problem.x_labels, obj.problem.y_labels, res.appearFEs, res.appearIters, total_width)
|
|
264
|
+
Verbose.verboseSingleSolutions(res.bestDec, res.bestObj, obj.problem.x_labels, obj.problem.y_labels, res.appearFEs, res.appearIters, Verbose.total_width)
|
|
250
265
|
else:
|
|
251
|
-
Verbose.verboseMultiSolutions(res.bestDec, res.bestMetric, res.appearFEs, res.appearIters, total_width)
|
|
266
|
+
Verbose.verboseMultiSolutions(res.bestDec, res.bestMetric, res.appearFEs, res.appearIters, Verbose.total_width)
|
|
252
267
|
|
|
253
268
|
if Verbose.saveFlag:
|
|
254
269
|
|
|
@@ -258,6 +273,13 @@ class Verbose():
|
|
|
258
273
|
|
|
259
274
|
Verbose.saveLog(obj, folder_log)
|
|
260
275
|
|
|
276
|
+
#TODO
|
|
277
|
+
if Verbose.isStop:
|
|
278
|
+
Verbose.iterEmit.unfinished()
|
|
279
|
+
else:
|
|
280
|
+
Verbose.iterEmit.finished()
|
|
281
|
+
|
|
282
|
+
|
|
261
283
|
Verbose.logFlag, Verbose.verbose, Verbose.saveFlag=record
|
|
262
284
|
|
|
263
285
|
return res
|
|
@@ -297,9 +319,9 @@ class Verbose():
|
|
|
297
319
|
folder_data, folder_log=Verbose.checkDir()
|
|
298
320
|
|
|
299
321
|
if Verbose.verbose or Verbose.logFlag:
|
|
300
|
-
|
|
322
|
+
|
|
301
323
|
title=obj.name+" Setting"
|
|
302
|
-
spacing=int((total_width-len(title))/2)
|
|
324
|
+
spacing=int((Verbose.total_width-len(title))/2)
|
|
303
325
|
Verbose.output("="*spacing+title+"="*spacing)
|
|
304
326
|
|
|
305
327
|
keys=obj.setting.keys()
|
|
@@ -310,7 +332,7 @@ class Verbose():
|
|
|
310
332
|
Verbose.output(table)
|
|
311
333
|
|
|
312
334
|
title="Attribute"
|
|
313
|
-
spacing=int((total_width-len(title))/2)
|
|
335
|
+
spacing=int((Verbose.total_width-len(title))/2)
|
|
314
336
|
Verbose.output("="*spacing+title+"="*spacing)
|
|
315
337
|
|
|
316
338
|
Verbose.output(f"First Order Sensitivity: {obj.firstOrder}")
|
|
@@ -320,16 +342,16 @@ class Verbose():
|
|
|
320
342
|
res=func(obj, *args, **kwargs)
|
|
321
343
|
|
|
322
344
|
if Verbose.verbose or Verbose.logFlag:
|
|
323
|
-
|
|
345
|
+
|
|
324
346
|
title="Conclusion"
|
|
325
|
-
spacing=int((total_width-len(title))/2)
|
|
347
|
+
spacing=int((Verbose.total_width-len(title))/2)
|
|
326
348
|
Verbose.output("="*spacing+title+"="*spacing)
|
|
327
349
|
|
|
328
350
|
for key, values in obj.result.Si.items():
|
|
329
351
|
title=key
|
|
330
|
-
spacing=int((total_width-len(title))/2)
|
|
352
|
+
spacing=int((Verbose.total_width-len(title))/2)
|
|
331
353
|
Verbose.output("-"*spacing+title+"-"*spacing)
|
|
332
|
-
Verbose.verboseSi(values[0], values[1], total_width)
|
|
354
|
+
Verbose.verboseSi(values[0], values[1], Verbose.total_width)
|
|
333
355
|
|
|
334
356
|
if Verbose.logFlag:
|
|
335
357
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|