Skip to content

Commit 08860c0

Browse files
authored
Merge branch 'master' into dependabot/github_actions/pypa/cibuildwheel-2.16.4
2 parents 69d1fdf + be831f5 commit 08860c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+82
-55
lines changed

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
This package is distributed under New BSD license.
99
"""
10+
1011
from setuptools import setup, Extension
1112
import sys
1213
import numpy as np

smt/applications/mfkpls.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import numpy as np
1313

1414
from sklearn.cross_decomposition import PLSRegression as pls
15-
from sklearn.metrics.pairwise import manhattan_distances
15+
from sklearn.metrics.pairwise import check_pairwise_arrays
1616

1717
from smt.applications import MFK
1818
from smt.utils.kriging import componentwise_distance_PLS
@@ -42,7 +42,10 @@ def _differences(self, X, Y):
4242
Overrides differences function for MFK
4343
Compute the manhattan_distances
4444
"""
45-
return manhattan_distances(X, Y, sum_over_features=False)
45+
X, Y = check_pairwise_arrays(X, Y)
46+
D = X[:, np.newaxis, :] - Y[np.newaxis, :, :]
47+
D = np.abs(D, D)
48+
return D.reshape((-1, X.shape[1]))
4649

4750
def _componentwise_distance(self, dx, opt=0):
4851
d = componentwise_distance_PLS(

smt/applications/mixed_integer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ def __init__(
215215
)
216216
and self._surrogate.options["categorical_kernel"] is None
217217
):
218-
self._surrogate.options[
219-
"categorical_kernel"
220-
] = MixIntKernelType.HOMO_HSPHERE
218+
self._surrogate.options["categorical_kernel"] = (
219+
MixIntKernelType.HOMO_HSPHERE
220+
)
221221
warnings.warn(
222222
"Using MixedIntegerSurrogateModel integer model with Continuous Relaxation is not supported. Switched to homoscedastic hypersphere kernel instead."
223223
)

smt/applications/moe.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Mixture of Experts
77
"""
8+
89
# TODO : support for best number of clusters
910
# TODO : implement verbosity 'print_global'
1011
# TODO : documentation

smt/examples/multi_modal/run_genn_demo.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
This package is distributed under New BSD license.
1111
"""
12+
1213
from smt.surrogate_models.genn import GENN, load_smt_data
1314

1415
import numpy as np

smt/problems/branin.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Branin function.
77
"""
8+
89
import numpy as np
910

1011
from smt.problems.problem import Problem

smt/problems/cantilever_beam.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Liu, H., Xu, S., & Wang, X. Sampling strategies and metamodeling techniques for engineering design: comparison and application. In ASME Turbo Expo 2016: Turbomachinery Technical Conference and Exposition. American Society of Mechanical Engineers. June, 2016.
88
Cheng, G. H., Younis, A., Hajikolaei, K. H., and Wang, G. G. Trust Region Based Mode Pursuing Sampling Method for Global Optimization of High Dimensional Design Problems. Journal of Mechanical Design, 137(2). 2015.
99
"""
10+
1011
import numpy as np
1112

1213
from smt.problems.problem import Problem
@@ -75,16 +76,10 @@ def _evaluate(self, x, kx):
7576
b = x[:, 3 * kelem + 0]
7677
h = x[:, 3 * kelem + 1]
7778
y[:, 0] += (
78-
-12.0
79-
/ b**2
80-
/ h**3
81-
* np.sum(x[:, 2 + 3 * kelem :: 3], axis=1) ** 3
79+
-12.0 / b**2 / h**3 * np.sum(x[:, 2 + 3 * kelem :: 3], axis=1) ** 3
8280
)
8381
y[:, 0] -= (
84-
-12.0
85-
/ b**2
86-
/ h**3
87-
* np.sum(x[:, 5 + 3 * kelem :: 3], axis=1) ** 3
82+
-12.0 / b**2 / h**3 * np.sum(x[:, 5 + 3 * kelem :: 3], axis=1) ** 3
8883
)
8984

9085
elif kx % 3 == 1:
@@ -101,10 +96,7 @@ def _evaluate(self, x, kx):
10196
b = x[:, 3 * ielem + 0]
10297
h = x[:, 3 * ielem + 1]
10398
y[:, 0] += (
104-
36.0
105-
/ b
106-
/ h**3
107-
* np.sum(x[:, 2 + 3 * ielem :: 3], axis=1) ** 2
99+
36.0 / b / h**3 * np.sum(x[:, 2 + 3 * ielem :: 3], axis=1) ** 2
108100
)
109101
if kelem > ielem:
110102
y[:, 0] -= (

smt/problems/hierarchical_goldstein.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Cantilever beam problem from:
66
P. Saves, Y. Diouane, N. Bartoli, T. Lefebvre, and J. Morlier. A mixed-categorical correlation kernel for gaussian process, 2022
77
"""
8+
89
import numpy as np
910

1011
from smt.problems.problem import Problem

smt/problems/lp_norm.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Norm function.
77
"""
8+
89
import numpy as np
910

1011
from smt.problems.problem import Problem

smt/problems/mixed_cantilever_beam.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Cantilever beam problem from:
66
P. Saves, Y. Diouane, N. Bartoli, T. Lefebvre, and J. Morlier. A mixed-categorical correlation kernel for gaussian process, 2022
77
"""
8+
89
import numpy as np
910

1011
from smt.problems.problem import Problem

smt/problems/ndim_cantilever_beam.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
N-dimensional cantilever beam problem.
77
"""
8+
89
import numpy as np
910

1011
from smt.utils.options_dictionary import OptionsDictionary

smt/problems/ndim_robot_arm.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
N-dimensional robot arm problem.
77
"""
8+
89
import numpy as np
910

1011
from smt.utils.options_dictionary import OptionsDictionary

smt/problems/ndim_rosenbrock.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
N-dimensional Rosenbrock problem.
77
"""
8+
89
import numpy as np
910

1011
from smt.utils.options_dictionary import OptionsDictionary

smt/problems/ndim_step_function.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
N-dimensional step function problem.
77
"""
8+
89
import numpy as np
910

1011
from smt.utils.options_dictionary import OptionsDictionary

smt/problems/neural_network.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
C. Audet, E. Hall e-Hannan, and S. Le Digabel. A general mathematical framework for constrained mixed-variable blackbox optimization problems with meta and categorical variables. Operations Research Forum,499
77
4:137, 2023.
88
"""
9+
910
import numpy as np
1011

1112
from smt.problems.problem import Problem

smt/problems/problem.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Base class for benchmarking/test problems.
77
"""
8+
89
from typing import Optional
910
import numpy as np
1011

smt/problems/reduced_problem.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Reduced problem class - selects a subset of input variables.
77
"""
8+
89
import numpy as np
910

1011
from smt.utils.options_dictionary import OptionsDictionary

smt/problems/robot_arm.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Liu, H., Xu, S., & Wang, X. Sampling strategies and metamodeling techniques for engineering design: comparison and application. In ASME Turbo Expo 2016: Turbomachinery Technical Conference and Exposition. American Society of Mechanical Engineers. June, 2016.
88
An, J., and Owen, A. Quasi-Regression. Journal of complexity, 17(4), pp. 588-607, 2001.
99
"""
10+
1011
import numpy as np
1112

1213
from smt.problems.problem import Problem

smt/problems/rosenbrock.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Multi-dimensional Rosenbrock function.
77
"""
8+
89
import numpy as np
910

1011
from smt.problems.problem import Problem

smt/problems/sphere.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
Sphere function.
88
"""
9+
910
import numpy as np
1011

1112
from smt.problems.problem import Problem

smt/problems/tensor_product.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Tensor-product of cos, exp, or tanh.
77
"""
8+
89
import numpy as np
910

1011
from smt.problems.problem import Problem

smt/problems/torsion_vibration.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Liu, H., Xu, S., & Wang, X. Sampling strategies and metamodeling techniques for engineering design: comparison and application. In ASME Turbo Expo 2016: Turbomachinery Technical Conference and Exposition. American Society of Mechanical Engineers. June, 2016.
99
Wang, L., Beeson, D., Wiggs, G., and Rayasam, M. A Comparison of Metamodeling Methods Using Practical Industry Requirements. In Proceedings of the 47th AIAA/ASME/ASCE/AHS/ASC structures, structural dynamics, and materials conference, Newport, RI, pp. AIAA 2006-1811.
1010
"""
11+
1112
import numpy as np
1213
from scipy.misc import derivative
1314

smt/problems/water_flow.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Liu, H., Xu, S., & Wang, X. Sampling strategies and metamodeling techniques for engineering design: comparison and application. In ASME Turbo Expo 2016: Turbomachinery Technical Conference and Exposition. American Society of Mechanical Engineers. June, 2016.
99
Morris, M. D., Mitchell, T. J., and Ylvisaker, D. Bayesian Design and Analysis of Computer Experiments: Use of Derivatives in Surface Prediction. Technometrics, 35(3), pp. 243-255. 1993.
1010
"""
11+
1112
import numpy as np
1213
from scipy.misc import derivative
1314

smt/problems/water_flow_lfidelity.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Water flow problem from:
66
Xiong, S., Qian, P. Z., & Wu, C. J. (2013). Sequential design and analysis of high-accuracy and low-accuracy computer codes. Technometrics, 55(1), 37-46.
77
"""
8+
89
import numpy as np
910
from scipy.misc import derivative
1011

smt/problems/welded_beam.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Liu, H., Xu, S., & Wang, X. Sampling strategies and metamodeling techniques for engineering design: comparison and application. In ASME Turbo Expo 2016: Turbomachinery Technical Conference and Exposition. American Society of Mechanical Engineers. June, 2016.
99
Deb, K. An Efficient Constraint Handling Method for Genetic Algorithms. Computer methods in applied mechanics and engineering, 186(2), pp. 311-338. 2000.
1010
"""
11+
1112
import numpy as np
1213
from scipy.misc import derivative
1314
from smt.problems.problem import Problem

smt/problems/wing_weight.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Forrester, A., Sobester, A., and Keane, A., 2008,
1010
Engineering Design Via Surrogate Modelling: A Practical Guide, John Wiley & Sons, United Kingdom.
1111
"""
12+
1213
import numpy as np
1314
from scipy.misc import derivative
1415

smt/sampling_methods/full_factorial.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Full-factorial sampling.
77
"""
8+
89
import numpy as np
910

1011
from smt.sampling_methods.sampling_method import ScaledSamplingMethod

smt/sampling_methods/lhs.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
LHS sampling; uses the pyDOE3 package.
77
"""
8+
89
from pyDOE3 import lhs
910
from scipy.spatial.distance import pdist, cdist
1011
import numpy as np
@@ -290,12 +291,8 @@ def _PhiP_exchange(self, X, k, PhiP_, p, fixed_index):
290291

291292
dist1 = cdist([X[i1, :]], X_)
292293
dist2 = cdist([X[i2, :]], X_)
293-
d1 = np.sqrt(
294-
dist1**2 + (X[i2, k] - X_[:, k]) ** 2 - (X[i1, k] - X_[:, k]) ** 2
295-
)
296-
d2 = np.sqrt(
297-
dist2**2 - (X[i2, k] - X_[:, k]) ** 2 + (X[i1, k] - X_[:, k]) ** 2
298-
)
294+
d1 = np.sqrt(dist1**2 + (X[i2, k] - X_[:, k]) ** 2 - (X[i1, k] - X_[:, k]) ** 2)
295+
d2 = np.sqrt(dist2**2 - (X[i2, k] - X_[:, k]) ** 2 + (X[i1, k] - X_[:, k]) ** 2)
299296

300297
res = (
301298
PhiP_**p + (d1 ** (-p) - dist1 ** (-p) + d2 ** (-p) - dist2 ** (-p)).sum()

smt/sampling_methods/pydoe.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
pyDOE3 sampling methods
77
"""
8+
89
from pyDOE3 import doe_box_behnken
910
from pyDOE3 import doe_gsd
1011
from pyDOE3 import doe_factorial

smt/sampling_methods/random.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Random sampling.
77
"""
8+
89
import numpy as np
910

1011
from smt.sampling_methods.sampling_method import ScaledSamplingMethod

smt/sampling_methods/sampling_method.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Base class for sampling algorithms.
77
"""
8+
89
from abc import ABCMeta, abstractmethod
910
import numpy as np
1011
import warnings

smt/surrogate_models/idw.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
This package is distributed under New BSD license.
66
"""
7+
78
import numpy as np
89
from scipy.sparse import csc_matrix
910
from smt.surrogate_models.surrogate_model import SurrogateModel
@@ -13,7 +14,6 @@
1314

1415

1516
class IDW(SurrogateModel):
16-
1717
"""
1818
Inverse distance weighting interpolant
1919
This model uses the inverse distance between the unknown and training

smt/surrogate_models/krg_based.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Some functions are copied from gaussian_process submodule (Scikit-learn 0.14)
44
This package is distributed under New BSD license.
55
"""
6+
67
import numpy as np
78
from enum import Enum
89
from scipy import linalg, optimize

smt/surrogate_models/ls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
TO DO:
88
- define outputs['sol'] = self.sol
99
"""
10+
1011
import numpy as np
1112

1213
from sklearn import linear_model
@@ -15,7 +16,6 @@
1516

1617

1718
class LS(SurrogateModel):
18-
1919
"""
2020
Least square model.
2121
This model uses the linear_model.LinearRegression class from scikit-learn.

smt/surrogate_models/qp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
TO DO:
88
- define outputs['sol'] = self.sol
99
"""
10+
1011
import numpy as np
1112
import scipy
1213
from smt.surrogate_models.surrogate_model import SurrogateModel
@@ -15,7 +16,6 @@
1516

1617

1718
class QP(SurrogateModel):
18-
1919
"""
2020
Square polynomial approach
2121
"""

smt/surrogate_models/rbf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
This package is distributed under New BSD license.
55
"""
6+
67
import numpy as np
78
from scipy.sparse import csc_matrix
89
from smt.surrogate_models.surrogate_model import SurrogateModel
@@ -14,7 +15,6 @@
1415

1516

1617
class RBF(SurrogateModel):
17-
1818
"""
1919
Radial basis function interpolant with global polynomial trend.
2020
"""

smt/surrogate_models/rmtb.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
This package is distributed under New BSD license.
55
"""
6+
67
import numpy as np
78
import scipy.sparse
89
from numbers import Integral

smt/surrogate_models/rmtc.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
This package is distributed under New BSD license.
55
"""
6+
67
import numpy as np
78
import scipy.sparse
89
from numbers import Integral

0 commit comments

Comments
 (0)