diff --git a/doc/_src_docs/applications/Mixed_Hier_surr.rst b/doc/_src_docs/applications/Mixed_Hier_surr.rst index cee084db1..2478da150 100644 --- a/doc/_src_docs/applications/Mixed_Hier_surr.rst +++ b/doc/_src_docs/applications/Mixed_Hier_surr.rst @@ -27,7 +27,7 @@ Example of mixed integer Polynomial (QP) surrogate from smt.applications.mixed_integer import MixedIntegerSurrogateModel from smt.surrogate_models import QP - from smt.utils.design_space import DesignSpace, IntegerVariable + from smt.design_space import DesignSpace, IntegerVariable xt = np.array([0.0, 1.0, 2.0, 3.0, 4.0]) yt = np.array([0.0, 1.0, 1.5, 0.5, 1.0]) @@ -94,7 +94,7 @@ Example of mixed integer Gower Distance model MixedIntegerKrigingModel, ) from smt.surrogate_models import KRG, MixIntKernelType - from smt.utils.design_space import ( + from smt.design_space import ( CategoricalVariable, DesignSpace, FloatVariable, @@ -219,6 +219,21 @@ Example of mixed integer Gower Distance model :: + ___________________________________________________________________________ + + MixedIntegerKriging + ___________________________________________________________________________ + + Problem size + + # training points. : 9 + + ___________________________________________________________________________ + + Training + + Training ... + Training - done. Time (sec): 0.2469125 ___________________________________________________________________________ Evaluation @@ -226,9 +241,9 @@ Example of mixed integer Gower Distance model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0104737 + Predicting - done. Time (sec): 0.0059998 - Prediction time/pt. (sec) : 0.0001047 + Prediction time/pt. (sec) : 0.0000600 ___________________________________________________________________________ @@ -237,9 +252,9 @@ Example of mixed integer Gower Distance model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0108113 + Predicting - done. Time (sec): 0.0070035 - Prediction time/pt. (sec) : 0.0001081 + Prediction time/pt. (sec) : 0.0000700 ___________________________________________________________________________ @@ -248,9 +263,9 @@ Example of mixed integer Gower Distance model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0088882 + Predicting - done. Time (sec): 0.0059967 - Prediction time/pt. (sec) : 0.0000889 + Prediction time/pt. (sec) : 0.0000600 .. figure:: Mixed_Hier_surr_TestMixedInteger_run_mixed_gower_example.png @@ -274,7 +289,7 @@ Example of mixed integer Compound Symmetry model MixedIntegerKrigingModel, ) from smt.surrogate_models import KRG, MixIntKernelType - from smt.utils.design_space import ( + from smt.design_space import ( CategoricalVariable, DesignSpace, FloatVariable, @@ -399,14 +414,29 @@ Example of mixed integer Compound Symmetry model :: + ___________________________________________________________________________ + + MixedIntegerKriging + ___________________________________________________________________________ + + Problem size + + # training points. : 9 + + ___________________________________________________________________________ + + Training + + Training ... exception : 4-th leading minor of the array is not positive definite [ 3.28121902e+01 -1.19061651e+01 -1.19062304e+01 7.34202209e-04 - -3.09582545e-04 -2.19341599e-04 3.49847452e-09 -1.67389408e-09 - -7.15698500e-10] + -3.09582545e-04 -2.19341599e-04 3.49847458e-09 -1.67389635e-09 + -7.15698428e-10] exception : 4-th leading minor of the array is not positive definite [ 9.09297095e+00 -4.69851668e-02 -4.69502417e-02 9.74106925e-04 - -5.62905232e-06 -4.04511718e-06 2.47447277e-08 -1.26347028e-10 - -6.20962310e-11] + -5.62905232e-06 -4.04511718e-06 2.47447274e-08 -1.26347122e-10 + -6.20962697e-11] + Training - done. Time (sec): 0.2162046 ___________________________________________________________________________ Evaluation @@ -414,9 +444,9 @@ Example of mixed integer Compound Symmetry model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0080307 + Predicting - done. Time (sec): 0.0070002 - Prediction time/pt. (sec) : 0.0000803 + Prediction time/pt. (sec) : 0.0000700 ___________________________________________________________________________ @@ -425,9 +455,9 @@ Example of mixed integer Compound Symmetry model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0080523 + Predicting - done. Time (sec): 0.0060003 - Prediction time/pt. (sec) : 0.0000805 + Prediction time/pt. (sec) : 0.0000600 ___________________________________________________________________________ @@ -436,9 +466,9 @@ Example of mixed integer Compound Symmetry model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0020521 + Predicting - done. Time (sec): 0.0069995 - Prediction time/pt. (sec) : 0.0000205 + Prediction time/pt. (sec) : 0.0000700 .. figure:: Mixed_Hier_surr_TestMixedInteger_run_mixed_cs_example.png @@ -461,7 +491,7 @@ Example of mixed integer Homoscedastic Hypersphere model from smt.applications.mixed_integer import MixedIntegerKrigingModel from smt.surrogate_models import KRG, MixIntKernelType - from smt.utils.design_space import ( + from smt.design_space import ( CategoricalVariable, DesignSpace, FloatVariable, @@ -586,6 +616,21 @@ Example of mixed integer Homoscedastic Hypersphere model :: + ___________________________________________________________________________ + + MixedIntegerKriging + ___________________________________________________________________________ + + Problem size + + # training points. : 9 + + ___________________________________________________________________________ + + Training + + Training ... + Training - done. Time (sec): 0.3829696 ___________________________________________________________________________ Evaluation @@ -593,9 +638,9 @@ Example of mixed integer Homoscedastic Hypersphere model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0036688 + Predicting - done. Time (sec): 0.0060334 - Prediction time/pt. (sec) : 0.0000367 + Prediction time/pt. (sec) : 0.0000603 ___________________________________________________________________________ @@ -604,9 +649,9 @@ Example of mixed integer Homoscedastic Hypersphere model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0159636 + Predicting - done. Time (sec): 0.0059993 - Prediction time/pt. (sec) : 0.0001596 + Prediction time/pt. (sec) : 0.0000600 ___________________________________________________________________________ @@ -615,9 +660,9 @@ Example of mixed integer Homoscedastic Hypersphere model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0000000 + Predicting - done. Time (sec): 0.0059984 - Prediction time/pt. (sec) : 0.0000000 + Prediction time/pt. (sec) : 0.0000600 .. figure:: Mixed_Hier_surr_TestMixedInteger_run_mixed_homo_hyp_example.png @@ -640,7 +685,7 @@ Example of mixed integer Exponential Homoscedastic Hypersphere model from smt.applications.mixed_integer import MixedIntegerKrigingModel from smt.surrogate_models import KRG, MixIntKernelType - from smt.utils.design_space import ( + from smt.design_space import ( CategoricalVariable, DesignSpace, FloatVariable, @@ -765,6 +810,21 @@ Example of mixed integer Exponential Homoscedastic Hypersphere model :: + ___________________________________________________________________________ + + MixedIntegerKriging + ___________________________________________________________________________ + + Problem size + + # training points. : 9 + + ___________________________________________________________________________ + + Training + + Training ... + Training - done. Time (sec): 0.4382472 ___________________________________________________________________________ Evaluation @@ -772,9 +832,9 @@ Example of mixed integer Exponential Homoscedastic Hypersphere model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0104895 + Predicting - done. Time (sec): 0.0069728 - Prediction time/pt. (sec) : 0.0001049 + Prediction time/pt. (sec) : 0.0000697 ___________________________________________________________________________ @@ -783,9 +843,9 @@ Example of mixed integer Exponential Homoscedastic Hypersphere model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0104358 + Predicting - done. Time (sec): 0.0070000 - Prediction time/pt. (sec) : 0.0001044 + Prediction time/pt. (sec) : 0.0000700 ___________________________________________________________________________ @@ -794,9 +854,9 @@ Example of mixed integer Exponential Homoscedastic Hypersphere model # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0080771 + Predicting - done. Time (sec): 0.0080030 - Prediction time/pt. (sec) : 0.0000808 + Prediction time/pt. (sec) : 0.0000800 .. figure:: Mixed_Hier_surr_TestMixedInteger_run_mixed_homo_gaussian_example.png @@ -824,7 +884,7 @@ Example of mixed integer Kriging with hierarchical variables ) from smt.sampling_methods import LHS from smt.surrogate_models import KRG, MixHrcKernelType, MixIntKernelType - from smt.utils.design_space import ( + from smt.design_space import ( CategoricalVariable, DesignSpace, FloatVariable, @@ -993,6 +1053,21 @@ Example of mixed integer Kriging with hierarchical variables :: + ___________________________________________________________________________ + + MixedIntegerKriging + ___________________________________________________________________________ + + Problem size + + # training points. : 15 + + ___________________________________________________________________________ + + Training + + Training ... + Training - done. Time (sec): 0.6228259 ___________________________________________________________________________ Evaluation @@ -1000,9 +1075,9 @@ Example of mixed integer Kriging with hierarchical variables # eval points. : 15 Predicting ... - Predicting - done. Time (sec): 0.0105028 + Predicting - done. Time (sec): 0.0081153 - Prediction time/pt. (sec) : 0.0007002 + Prediction time/pt. (sec) : 0.0005410 diff --git a/doc/_src_docs/applications/Mixed_Hier_usage.rst b/doc/_src_docs/applications/Mixed_Hier_usage.rst index c8fa22522..1a516512b 100644 --- a/doc/_src_docs/applications/Mixed_Hier_usage.rst +++ b/doc/_src_docs/applications/Mixed_Hier_usage.rst @@ -26,7 +26,7 @@ some set. The main differences between these types is the question whether dista More details can be found in [1]_ . -Variables are specified using the ``DesignVariable`` classes in ``smt.utils.design_space``: +Variables are specified using the ``DesignVariable`` classes in ``smt.design_space``: - ``FloatVariable(lower_bound, upper_bound)``, upper should be greater than lower bound - ``IntegerVariable(lower_bound, upper_bound)``, bounds should be integers - ``OrdinalVariable(values)``, values is a list of int, float or str, encoded as integers from 0 to len(values)-1 @@ -249,7 +249,7 @@ The hierarchy relationships are specified after instantiating the design space: Training Training ... - Training - done. Time (sec): 2.9558113 + Training - done. Time (sec): 2.1491070 ___________________________________________________________________________ Evaluation @@ -257,11 +257,11 @@ The hierarchy relationships are specified after instantiating the design space: # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.2929027 + Predicting - done. Time (sec): 0.2126026 - Prediction time/pt. (sec) : 0.0029290 + Prediction time/pt. (sec) : 0.0021260 - Pred_RMSE 4.0000324624835547e-13 + Pred_RMSE 4.03450105320861e-13 Design space and variable class references @@ -269,19 +269,19 @@ Design space and variable class references The ``DesignSpace`` class and design variable classes implement the relevant functionality. - .. autoclass:: smt.utils.design_space.FloatVariable + .. autoclass:: smt.design_space.FloatVariable :exclude-members: get_limits - .. autoclass:: smt.utils.design_space.IntegerVariable + .. autoclass:: smt.design_space.IntegerVariable :exclude-members: get_limits - .. autoclass:: smt.utils.design_space.OrdinalVariable + .. autoclass:: smt.design_space.OrdinalVariable :exclude-members: get_limits - .. autoclass:: smt.utils.design_space.CategoricalVariable + .. autoclass:: smt.design_space.CategoricalVariable :exclude-members: get_limits - .. autoclass:: smt.utils.design_space.DesignSpace + .. autoclass:: smt.design_space.DesignSpace :members: :inherited-members: :exclude-members: get_unfolded_num_bounds, fold_x, unfold_x, get_num_bounds, get_x_limits @@ -414,7 +414,7 @@ Example of mixed integer context usage Training Training ... - Training - done. Time (sec): 0.4647245 + Training - done. Time (sec): 0.3023846 ___________________________________________________________________________ Evaluation @@ -422,9 +422,9 @@ Example of mixed integer context usage # eval points. : 50 Predicting ... - Predicting - done. Time (sec): 0.0116608 + Predicting - done. Time (sec): 0.0101750 - Prediction time/pt. (sec) : 0.0002332 + Prediction time/pt. (sec) : 0.0002035 .. figure:: Mixed_Hier_usage_TestMixedInteger_run_mixed_integer_context_example.png diff --git a/doc/_src_docs/applications/Mixed_Hier_usage.rstx b/doc/_src_docs/applications/Mixed_Hier_usage.rstx index 253b96f61..6eaf18929 100644 --- a/doc/_src_docs/applications/Mixed_Hier_usage.rstx +++ b/doc/_src_docs/applications/Mixed_Hier_usage.rstx @@ -26,7 +26,7 @@ some set. The main differences between these types is the question whether dista More details can be found in [1]_ . -Variables are specified using the ``DesignVariable`` classes in ``smt.utils.design_space``: +Variables are specified using the ``DesignVariable`` classes in ``smt.design_space``: - ``FloatVariable(lower_bound, upper_bound)``, upper should be greater than lower bound - ``IntegerVariable(lower_bound, upper_bound)``, bounds should be integers - ``OrdinalVariable(values)``, values is a list of int, float or str, encoded as integers from 0 to len(values)-1 @@ -60,19 +60,19 @@ Design space and variable class references The ``DesignSpace`` class and design variable classes implement the relevant functionality. - .. autoclass:: smt.utils.design_space.FloatVariable + .. autoclass:: smt.design_space.FloatVariable :exclude-members: get_limits - .. autoclass:: smt.utils.design_space.IntegerVariable + .. autoclass:: smt.design_space.IntegerVariable :exclude-members: get_limits - .. autoclass:: smt.utils.design_space.OrdinalVariable + .. autoclass:: smt.design_space.OrdinalVariable :exclude-members: get_limits - .. autoclass:: smt.utils.design_space.CategoricalVariable + .. autoclass:: smt.design_space.CategoricalVariable :exclude-members: get_limits - .. autoclass:: smt.utils.design_space.DesignSpace + .. autoclass:: smt.design_space.DesignSpace :members: :inherited-members: :exclude-members: get_unfolded_num_bounds, fold_x, unfold_x, get_num_bounds, get_x_limits diff --git a/doc/_src_docs/applications/cckrg.rst b/doc/_src_docs/applications/cckrg.rst index 60664418e..7b4ecca59 100644 --- a/doc/_src_docs/applications/cckrg.rst +++ b/doc/_src_docs/applications/cckrg.rst @@ -1,7 +1,7 @@ .. _cckrg-ref-label: Cooperative Components Kriging (CoopCompKRG) -================================ +============================================ Cooperative Components Kriging is a way of fitting a high-dimensional ordinary Kriging model by sequential lower-dimensional component model fits. For each component, only the associated hyperparameters are optimized. All other hyperparameters are set to a so-called cooperative context vector, which contains the current best hyperparameter values. @@ -82,7 +82,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.1147861 + Training - done. Time (sec): 0.1211066 ___________________________________________________________________________ Cooperative Components Kriging @@ -97,7 +97,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.1003253 + Training - done. Time (sec): 0.1113083 ___________________________________________________________________________ Cooperative Components Kriging @@ -112,7 +112,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.1636684 + Training - done. Time (sec): 0.1437654 ___________________________________________________________________________ Evaluation @@ -124,8 +124,8 @@ Usage Prediction time/pt. (sec) : 0.0000000 - [[5.01799698]] - [[5.74486667]] + [[-0.49752687]] + [[72.00594081]] Options @@ -245,7 +245,7 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds * - is_ri - False - None diff --git a/doc/_src_docs/applications/cckrg.rstx b/doc/_src_docs/applications/cckrg.rstx index be8a6025a..bf329b079 100644 --- a/doc/_src_docs/applications/cckrg.rstx +++ b/doc/_src_docs/applications/cckrg.rstx @@ -1,7 +1,7 @@ .. _cckrg-ref-label: Cooperative Components Kriging (CoopCompKRG) -================================ +============================================ Cooperative Components Kriging is a way of fitting a high-dimensional ordinary Kriging model by sequential lower-dimensional component model fits. For each component, only the associated hyperparameters are optimized. All other hyperparameters are set to a so-called cooperative context vector, which contains the current best hyperparameter values. diff --git a/doc/_src_docs/applications/ego.rst b/doc/_src_docs/applications/ego.rst index 40109be5f..a6049006b 100644 --- a/doc/_src_docs/applications/ego.rst +++ b/doc/_src_docs/applications/ego.rst @@ -202,7 +202,7 @@ Usage from smt.applications import EGO from smt.surrogate_models import KRG - from smt.utils.design_space import DesignSpace + from smt.design_space import DesignSpace def function_test_1d(x): # function xsinx @@ -456,7 +456,7 @@ Usage with mixed variable from smt.applications import EGO from smt.applications.mixed_integer import MixedIntegerContext from smt.surrogate_models import KRG, MixIntKernelType - from smt.utils.design_space import ( + from smt.design_space import ( CategoricalVariable, DesignSpace, FloatVariable, @@ -548,7 +548,7 @@ Usage with mixed variable :: - Minimum in x=[-5. 2. 1. 0.] with f(x)=-14.2 + Minimum in x=[-4.96251421 2. 0. 1. ] with f(x)=-13.9 .. figure:: ego_TestEGO_run_ego_mixed_integer_example.png :scale: 80 % @@ -604,7 +604,7 @@ Options - ['str'] - Approximated q-EI maximization strategy * - evaluator - - + - - None - ['Evaluator'] - Object used to run function fun to optimize at x points (nsamples, nxdim) @@ -633,8 +633,13 @@ Options - None - ['bool'] - Enable the penalization of points that have been already evaluated in EI criterion + * - is_ri + - False + - None + - ['bool'] + - Enable to re interpolate the variance for training points * - surrogate - - + - - None - ['KRG', 'KPLS', 'KPLSK', 'GEKPLS', 'MGP', 'GPX'] - SMT kriging-based surrogate model used internaly diff --git a/doc/_src_docs/applications/mfk.rst b/doc/_src_docs/applications/mfk.rst index c9ba2ad78..6c61ecaa5 100644 --- a/doc/_src_docs/applications/mfk.rst +++ b/doc/_src_docs/applications/mfk.rst @@ -104,7 +104,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.9782782 + Training - done. Time (sec): 1.5782199 ___________________________________________________________________________ Evaluation @@ -112,9 +112,9 @@ Usage # eval points. : 101 Predicting ... - Predicting - done. Time (sec): 0.0000000 + Predicting - done. Time (sec): 0.0009999 - Prediction time/pt. (sec) : 0.0000000 + Prediction time/pt. (sec) : 0.0000099 ___________________________________________________________________________ @@ -178,7 +178,7 @@ Options * - corr - squar_exp - ['pow_exp', 'abs_exp', 'squar_exp', 'act_exp', 'matern52', 'matern32'] - - None + - ['str', 'Kernel'] - Correlation function type * - pow_exp_power - 1.9 @@ -249,7 +249,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None diff --git a/doc/_src_docs/applications/mfkpls.rst b/doc/_src_docs/applications/mfkpls.rst index 724961db8..5e8fa49e9 100644 --- a/doc/_src_docs/applications/mfkpls.rst +++ b/doc/_src_docs/applications/mfkpls.rst @@ -109,7 +109,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.1518815 + Training - done. Time (sec): 0.1539667 ___________________________________________________________________________ Evaluation @@ -117,9 +117,9 @@ Usage # eval points. : 101 Predicting ... - Predicting - done. Time (sec): 0.0000000 + Predicting - done. Time (sec): 0.0010004 - Prediction time/pt. (sec) : 0.0000000 + Prediction time/pt. (sec) : 0.0000099 ___________________________________________________________________________ @@ -254,7 +254,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None diff --git a/doc/_src_docs/applications/mfkplsk.rst b/doc/_src_docs/applications/mfkplsk.rst index c30c9a3b3..572d16114 100644 --- a/doc/_src_docs/applications/mfkplsk.rst +++ b/doc/_src_docs/applications/mfkplsk.rst @@ -109,7 +109,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.2673016 + Training - done. Time (sec): 0.2271116 ___________________________________________________________________________ Evaluation @@ -117,9 +117,9 @@ Usage # eval points. : 101 Predicting ... - Predicting - done. Time (sec): 0.0000000 + Predicting - done. Time (sec): 0.0009999 - Prediction time/pt. (sec) : 0.0000000 + Prediction time/pt. (sec) : 0.0000099 ___________________________________________________________________________ @@ -254,7 +254,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None diff --git a/doc/_src_docs/applications/podi.rst b/doc/_src_docs/applications/podi.rst index c2a3c838e..f15ec4c96 100644 --- a/doc/_src_docs/applications/podi.rst +++ b/doc/_src_docs/applications/podi.rst @@ -65,7 +65,7 @@ where :math:`\phi_i` is the local POD basis at input point :math:`\mathbf{x_1}`. Singular Values Decomposition (SVD) -------------------------------------- +----------------------------------- To perform the POD, the SVD of the snapshot matrix :math:`S` is used: .. math :: @@ -109,7 +109,7 @@ The :math:`\alpha_i` coefficients of the :math:`A` matrix can be deduced: \end{equation} Use of Surrogate models ---------------------------------- +----------------------- To compute :math:`u` at a new value :math:`\mathbf{x}_*`, the values of :math:`\alpha_i(\mathbf{x}_*)` at each mode :math:`i` are needed. @@ -147,11 +147,10 @@ NB: The variance equation takes in consideration that: - the models are pairwise independent, so are the coefficients :math:`\hat\alpha_i(\mathbf{x}_*)`. - Usage ----- Example 1: global POD case for 1D function -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python import matplotlib.pyplot as plt @@ -508,8 +507,6 @@ Example 2: local POD case for 2D function :scale: 80 % :align: center - - PODI class API -------------- @@ -527,7 +524,7 @@ PODI class API .. automethod:: smt.applications.podi.PODI.get_singular_values - .. automethod:: mst.applications.podi.PODI.get_ev_list + .. automethod:: smt.applications.podi.PODI.get_ev_list .. automethod:: smt.applications.podi.PODI.get_ev_ratio @@ -547,4 +544,4 @@ PODI class API .. automethod:: smt.applications.podi.PODI.predict_derivatives - .. automethod:: smt.applications.podi.PODI.predict_variance_derivativess \ No newline at end of file + .. automethod:: smt.applications.podi.PODI.predict_variance_derivatives \ No newline at end of file diff --git a/doc/_src_docs/applications/podi.rstx b/doc/_src_docs/applications/podi.rstx index 0c2a593b7..0f427b4cd 100644 --- a/doc/_src_docs/applications/podi.rstx +++ b/doc/_src_docs/applications/podi.rstx @@ -65,7 +65,7 @@ where :math:`\phi_i` is the local POD basis at input point :math:`\mathbf{x_1}`. Singular Values Decomposition (SVD) -------------------------------------- +----------------------------------- To perform the POD, the SVD of the snapshot matrix :math:`S` is used: .. math :: @@ -109,7 +109,7 @@ The :math:`\alpha_i` coefficients of the :math:`A` matrix can be deduced: \end{equation} Use of Surrogate models ---------------------------------- +----------------------- To compute :math:`u` at a new value :math:`\mathbf{x}_*`, the values of :math:`\alpha_i(\mathbf{x}_*)` at each mode :math:`i` are needed. @@ -150,7 +150,7 @@ NB: The variance equation takes in consideration that: Usage ----- Example 1: global POD case for 1D function -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. embed-test-print-plot :: smt.applications.tests.test_podi , Test , run_podi_example_1d_global , 80 Example 2: local POD case for 2D function @@ -174,7 +174,7 @@ PODI class API .. automethod:: smt.applications.podi.PODI.get_singular_values - .. automethod:: mst.applications.podi.PODI.get_ev_list + .. automethod:: smt.applications.podi.PODI.get_ev_list .. automethod:: smt.applications.podi.PODI.get_ev_ratio @@ -194,4 +194,4 @@ PODI class API .. automethod:: smt.applications.podi.PODI.predict_derivatives - .. automethod:: smt.applications.podi.PODI.predict_variance_derivativess \ No newline at end of file + .. automethod:: smt.applications.podi.PODI.predict_variance_derivatives \ No newline at end of file diff --git a/doc/_src_docs/dev_docs/dev_design_space.rst b/doc/_src_docs/dev_docs/dev_design_space.rst index 590a259de..9d11e174c 100644 --- a/doc/_src_docs/dev_docs/dev_design_space.rst +++ b/doc/_src_docs/dev_docs/dev_design_space.rst @@ -3,12 +3,12 @@ Developer API for design spaces =============================== -.. autoclass:: smt.utils.design_space.BaseDesignSpace +.. autoclass:: smt.design_space.BaseDesignSpace - .. automethod:: smt.utils.design_space.BaseDesignSpace._get_design_variables + .. automethod:: smt.design_space.BaseDesignSpace._get_design_variables - .. automethod:: smt.utils.design_space.BaseDesignSpace._is_conditionally_acting + .. automethod:: smt.design_space.BaseDesignSpace._is_conditionally_acting - .. automethod:: smt.utils.design_space.BaseDesignSpace._correct_get_acting + .. automethod:: smt.design_space.BaseDesignSpace._correct_get_acting - .. automethod:: smt.utils.design_space.BaseDesignSpace._sample_valid_x + .. automethod:: smt.design_space.BaseDesignSpace._sample_valid_x diff --git a/doc/_src_docs/dev_docs/dev_design_space.rstx b/doc/_src_docs/dev_docs/dev_design_space.rstx index 590a259de..9d11e174c 100644 --- a/doc/_src_docs/dev_docs/dev_design_space.rstx +++ b/doc/_src_docs/dev_docs/dev_design_space.rstx @@ -3,12 +3,12 @@ Developer API for design spaces =============================== -.. autoclass:: smt.utils.design_space.BaseDesignSpace +.. autoclass:: smt.design_space.BaseDesignSpace - .. automethod:: smt.utils.design_space.BaseDesignSpace._get_design_variables + .. automethod:: smt.design_space.BaseDesignSpace._get_design_variables - .. automethod:: smt.utils.design_space.BaseDesignSpace._is_conditionally_acting + .. automethod:: smt.design_space.BaseDesignSpace._is_conditionally_acting - .. automethod:: smt.utils.design_space.BaseDesignSpace._correct_get_acting + .. automethod:: smt.design_space.BaseDesignSpace._correct_get_acting - .. automethod:: smt.utils.design_space.BaseDesignSpace._sample_valid_x + .. automethod:: smt.design_space.BaseDesignSpace._sample_valid_x diff --git a/doc/_src_docs/surrogate_models.rst b/doc/_src_docs/surrogate_models.rst index 3395a113c..dd8b20733 100644 --- a/doc/_src_docs/surrogate_models.rst +++ b/doc/_src_docs/surrogate_models.rst @@ -112,62 +112,38 @@ All surrogate modeling methods implement the following API, though some of the f .. automethod:: smt.surrogate_models.surrogate_model.SurrogateModel.predict_variance_gradient + .. automethod:: smt.surrogate_models.surrogate_model.SurrogateModel.save -How to save and load trained surrogate models ---------------------------------------------- + .. automethod:: smt.surrogate_models.surrogate_model.SurrogateModel.load -The SurrogateModel API does not contain any save/load interface. -Therefore the user has to handle these operations by him/herself. Below some tips to implement save and load. -For models written in pure Python -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +How to save and load trained surrogate models +--------------------------------------------- -These operations can be implemented using the `pickle `_ module. +As of SMT 2.9, the surrogate API offers save/load methods which can be used as below. Saving the model """""""""""""""" +The instance method ``save()`` is used to save the trained model (here ``KRG``) +in a binary file named ``kriging.bin``. + .. code-block:: python sm = KRG() sm.set_training_values(xtrain, ytrain) sm.train() - filename = "kriging.pkl" - with open(filename, "wb") as f: - pickle.dump(sm, f) + sm.save("kriging.bin ") Loading the model """"""""""""""""" -.. code-block:: python - - sm2 = None - filename = "kriging.pkl" - with open(filename, "rb") as f: - sm2 = pickle.load(f) - -For models written in C++ (namely IDW, RBF, RMTB and RMTC) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -These models can be cached using their `data_dir` option. Provided the user gives the same training values -the model is not retrained but reloaded from cache directory. So by saving the cache directory and the training data, -one is able to avoid the training cost and reload the model from cached data. - -Saving the model -"""""""""""""""" +The previous model can be reloaded knowing the type of surrogate being saved (ie. ``KRG``) +from the binary file with: .. code-block:: python - sm = RBF(data_dir="./cache") - sm.set_training_values(xtrain, ytrain) - sm.train() - -Loading the model -""""""""""""""""" - -.. code-block:: python + sm2 = KRG.load("kriging.bin") + ytest = sm2.predict_values(xtest) - sm2 = RBF(data_dir="./cache") - sm2.set_training_values(xtrain, ytrain) # same training data as above! - sm2.train() # actual training is skipped, cached data model is loaded diff --git a/doc/_src_docs/surrogate_models.rstx b/doc/_src_docs/surrogate_models.rstx index 3b70bbee6..fe1e89b50 100644 --- a/doc/_src_docs/surrogate_models.rstx +++ b/doc/_src_docs/surrogate_models.rstx @@ -48,62 +48,38 @@ All surrogate modeling methods implement the following API, though some of the f .. automethod:: smt.surrogate_models.surrogate_model.SurrogateModel.predict_variance_gradient + .. automethod:: smt.surrogate_models.surrogate_model.SurrogateModel.save -How to save and load trained surrogate models ---------------------------------------------- + .. automethod:: smt.surrogate_models.surrogate_model.SurrogateModel.load -The SurrogateModel API does not contain any save/load interface. -Therefore the user has to handle these operations by him/herself. Below some tips to implement save and load. -For models written in pure Python -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +How to save and load trained surrogate models +--------------------------------------------- -These operations can be implemented using the `pickle `_ module. +As of SMT 2.9, the surrogate API offers save/load methods which can be used as below. Saving the model """""""""""""""" +The instance method ``save()`` is used to save the trained model (here ``KRG``) +in a binary file named ``kriging.bin``. + .. code-block:: python sm = KRG() sm.set_training_values(xtrain, ytrain) sm.train() - filename = "kriging.pkl" - with open(filename, "wb") as f: - pickle.dump(sm, f) + sm.save("kriging.bin ") Loading the model """"""""""""""""" -.. code-block:: python - - sm2 = None - filename = "kriging.pkl" - with open(filename, "rb") as f: - sm2 = pickle.load(f) - -For models written in C++ (namely IDW, RBF, RMTB and RMTC) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -These models can be cached using their `data_dir` option. Provided the user gives the same training values -the model is not retrained but reloaded from cache directory. So by saving the cache directory and the training data, -one is able to avoid the training cost and reload the model from cached data. - -Saving the model -"""""""""""""""" +The previous model can be reloaded knowing the type of surrogate being saved (ie. ``KRG``) +from the binary file with: .. code-block:: python - sm = RBF(data_dir="./cache") - sm.set_training_values(xtrain, ytrain) - sm.train() - -Loading the model -""""""""""""""""" - -.. code-block:: python + sm2 = KRG.load("kriging.bin") + ytest = sm2.predict_values(xtest) - sm2 = RBF(data_dir="./cache") - sm2.set_training_values(xtrain, ytrain) # same training data as above! - sm2.train() # actual training is skipped, cached data model is loaded diff --git a/doc/_src_docs/surrogate_models/gpr/gekpls.rst b/doc/_src_docs/surrogate_models/gpr/gekpls.rst index c6516b1dc..e0c7778b3 100644 --- a/doc/_src_docs/surrogate_models/gpr/gekpls.rst +++ b/doc/_src_docs/surrogate_models/gpr/gekpls.rst @@ -97,7 +97,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.2067351 + Training - done. Time (sec): 0.1225321 .. figure:: gekpls_Test_test_gekpls.png :scale: 80 % @@ -220,7 +220,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None diff --git a/doc/_src_docs/surrogate_models/gpr/gpx.rst b/doc/_src_docs/surrogate_models/gpr/gpx.rst index 23e97fee7..59719ae00 100644 --- a/doc/_src_docs/surrogate_models/gpr/gpx.rst +++ b/doc/_src_docs/surrogate_models/gpr/gpx.rst @@ -90,7 +90,7 @@ Example Training Training ... - Training - done. Time (sec): 0.0080457 + Training - done. Time (sec): 0.0082021 ___________________________________________________________________________ Evaluation @@ -195,4 +195,4 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds diff --git a/doc/_src_docs/surrogate_models/gpr/kpls.rst b/doc/_src_docs/surrogate_models/gpr/kpls.rst index 5794f6a83..f2205d143 100644 --- a/doc/_src_docs/surrogate_models/gpr/kpls.rst +++ b/doc/_src_docs/surrogate_models/gpr/kpls.rst @@ -83,7 +83,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.0974965 + Training - done. Time (sec): 0.0937924 ___________________________________________________________________________ Evaluation @@ -140,8 +140,16 @@ Usage with an automatic number of components print("\n The model automatically choose " + str(ncomp) + " components.") ## You can predict a 10-dimension point from the 3-dimensional model - print(sm.predict_values(np.array([[-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9]]))) - print(sm.predict_variances(np.array([[-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9]]))) + print( + sm.predict_values( + np.array([[-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9]]) + ) + ) + print( + sm.predict_variances( + np.array([[-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9]]) + ) + ) :: @@ -159,7 +167,7 @@ Usage with an automatic number of components Training Training ... - Training - done. Time (sec): 32.4833167 + Training - done. Time (sec): 9.3670509 The model automatically choose 3 components. ___________________________________________________________________________ @@ -169,12 +177,12 @@ Usage with an automatic number of components # eval points. : 1 Predicting ... - Predicting - done. Time (sec): 0.0019555 + Predicting - done. Time (sec): 0.0000000 - Prediction time/pt. (sec) : 0.0019555 + Prediction time/pt. (sec) : 0.0000000 - [[7.89613102]] - [[64.47734196]] + [[7.89613133]] + [[64.47734003]] Options @@ -294,7 +302,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None diff --git a/doc/_src_docs/surrogate_models/gpr/kplsk.rst b/doc/_src_docs/surrogate_models/gpr/kplsk.rst index 1a4931e79..694ea82f4 100644 --- a/doc/_src_docs/surrogate_models/gpr/kplsk.rst +++ b/doc/_src_docs/surrogate_models/gpr/kplsk.rst @@ -85,7 +85,7 @@ Usage Training Training ... - Training - done. Time (sec): 0.1314826 + Training - done. Time (sec): 0.0715163 ___________________________________________________________________________ Evaluation @@ -230,7 +230,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None diff --git a/doc/_src_docs/surrogate_models/gpr/krg.rst b/doc/_src_docs/surrogate_models/gpr/krg.rst index 67006a5fc..c17c5d239 100644 --- a/doc/_src_docs/surrogate_models/gpr/krg.rst +++ b/doc/_src_docs/surrogate_models/gpr/krg.rst @@ -63,7 +63,7 @@ Kriging with categorical or integer variables --------------------------------------------- The goal is to be able to build a model for mixed typed variables. -This algorithm has been presented by Garrido-Merchán and Hernández-Lobato in 2020 [2]_. +This algorithm has been presented by Garrido-Merchán and Hernández-Lobato in 2020 [2]. To incorporate integer (with order relation) and categorical variables (with no order), we used continuous relaxation. For integer, we add a continuous dimension with the same bounds and then we round in the prediction to the closer integer. @@ -144,7 +144,7 @@ Example 1 Training Training ... - Training - done. Time (sec): 0.1002417 + Training - done. Time (sec): 0.0817022 ___________________________________________________________________________ Evaluation @@ -182,7 +182,10 @@ Example 2 with mixed variables from smt.applications.mixed_integer import MixedIntegerKrigingModel from smt.surrogate_models import KRG - from smt.utils.design_space import DesignSpace, IntegerVariable + from smt.design_space import ( + DesignSpace, + IntegerVariable, + ) xt = np.array([0.0, 2.0, 3.0]) yt = np.array([0.0, 1.5, 0.9]) @@ -224,6 +227,21 @@ Example 2 with mixed variables :: + ___________________________________________________________________________ + + MixedIntegerKriging + ___________________________________________________________________________ + + Problem size + + # training points. : 3 + + ___________________________________________________________________________ + + Training + + Training ... + Training - done. Time (sec): 0.0847299 ___________________________________________________________________________ Evaluation @@ -231,9 +249,9 @@ Example 2 with mixed variables # eval points. : 500 Predicting ... - Predicting - done. Time (sec): 0.0084236 + Predicting - done. Time (sec): 0.0000000 - Prediction time/pt. (sec) : 0.0000168 + Prediction time/pt. (sec) : 0.0000000 .. figure:: krg_Test_test_mixed_int_krg.png @@ -306,7 +324,7 @@ Example 3 with noisy data Training Training ... - Training - done. Time (sec): 0.1818266 + Training - done. Time (sec): 0.1817245 ___________________________________________________________________________ Evaluation @@ -314,9 +332,9 @@ Example 3 with noisy data # eval points. : 100 Predicting ... - Predicting - done. Time (sec): 0.0000000 + Predicting - done. Time (sec): 0.0081284 - Prediction time/pt. (sec) : 0.0000000 + Prediction time/pt. (sec) : 0.0000813 .. figure:: krg_Test_test_noisy_krg.png @@ -370,7 +388,7 @@ Options * - corr - squar_exp - ['pow_exp', 'abs_exp', 'squar_exp', 'squar_sin_exp', 'matern52', 'matern32'] - - ['str'] + - ['str', 'Kernel'] - Correlation function type * - pow_exp_power - 1.9 @@ -441,7 +459,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None diff --git a/doc/_src_docs/surrogate_models/gpr/krg.rstx b/doc/_src_docs/surrogate_models/gpr/krg.rstx index d9893586a..4333fad6b 100644 --- a/doc/_src_docs/surrogate_models/gpr/krg.rstx +++ b/doc/_src_docs/surrogate_models/gpr/krg.rstx @@ -63,7 +63,7 @@ Kriging with categorical or integer variables --------------------------------------------- The goal is to be able to build a model for mixed typed variables. -This algorithm has been presented by Garrido-Merchán and Hernández-Lobato in 2020 [2]_. +This algorithm has been presented by Garrido-Merchán and Hernández-Lobato in 2020 [2]. To incorporate integer (with order relation) and categorical variables (with no order), we used continuous relaxation. For integer, we add a continuous dimension with the same bounds and then we round in the prediction to the closer integer. diff --git a/doc/_src_docs/surrogate_models/gpr/mgp.rst b/doc/_src_docs/surrogate_models/gpr/mgp.rst index f7f6dc3a8..b1bb36764 100644 --- a/doc/_src_docs/surrogate_models/gpr/mgp.rst +++ b/doc/_src_docs/surrogate_models/gpr/mgp.rst @@ -129,7 +129,7 @@ Usage Training Training ... - Training - done. Time (sec): 1.0498188 + Training - done. Time (sec): 0.8740928 .. figure:: mgp_Test_test_mgp.png :scale: 80 % @@ -181,7 +181,7 @@ Options * - corr - squar_exp - ['pow_exp', 'abs_exp', 'squar_exp', 'act_exp', 'matern52', 'matern32'] - - None + - ['str', 'Kernel'] - Correlation function type * - pow_exp_power - 1.9 @@ -252,7 +252,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None diff --git a/doc/_src_docs/surrogate_models/gpr/sgp.rst b/doc/_src_docs/surrogate_models/gpr/sgp.rst index e50d7a8fb..b05d7b84a 100644 --- a/doc/_src_docs/surrogate_models/gpr/sgp.rst +++ b/doc/_src_docs/surrogate_models/gpr/sgp.rst @@ -133,7 +133,7 @@ Using FITC method Training Training ... - Training - done. Time (sec): 0.6393216 + Training - done. Time (sec): 0.3610163 ___________________________________________________________________________ Evaluation @@ -223,7 +223,7 @@ Using VFE method Training Training ... - Training - done. Time (sec): 0.5364490 + Training - done. Time (sec): 0.3749776 ___________________________________________________________________________ Evaluation @@ -357,7 +357,12 @@ Options - None - None - ['BaseDesignSpace', 'list', 'ndarray'] - - definition of the (hierarchical) design space: use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + - definition of the (hierarchical) design space: use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds + * - is_ri + - False + - None + - ['bool'] + - activate reinterpolation for noisy cases * - random_state - 41 - None @@ -372,4 +377,9 @@ Options - 10 - None - ['int'] - - Number of inducing inputs + - Number of inducing inputs when inducing_method is set + * - inducing_method + - None + - ['random', 'kmeans'] + - ['str'] + - The chosen method to induce points diff --git a/doc/requirements.txt b/doc/requirements.txt index a8e48538a..986836647 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -7,4 +7,5 @@ numpydoc matplotlib jenn >= 1.0.2, <2.0 egobox ~= 0.23.0 +smt-design-space-ext git+https://github.com/hwangjt/sphinx_auto_embed.git # for doc generation diff --git a/smt/design_space/design_space.py b/smt/design_space/design_space.py index 825b3fe64..3a58c2976 100644 --- a/smt/design_space/design_space.py +++ b/smt/design_space/design_space.py @@ -645,7 +645,7 @@ class DesignSpace(BaseDesignSpace): -------- Instantiate the design space with all its design variables: - >>> from smt.utils.design_space import * + >>> from smt.design_space import * >>> ds = DesignSpace([ >>> CategoricalVariable(['A', 'B']), # x0 categorical: A or B; order is not relevant >>> OrdinalVariable(['C', 'D', 'E']), # x1 ordinal: C, D or E; order is relevant diff --git a/smt/problems/problem.py b/smt/problems/problem.py index 799413101..228f25fe5 100644 --- a/smt/problems/problem.py +++ b/smt/problems/problem.py @@ -65,7 +65,7 @@ def _setup(self) -> None: def _set_design_space(self, design_space: BaseDesignSpace): """ - Set the design space definition (best is to use the smt.utils.design_space.DesignSpace class directly) of + Set the design space definition (best is to use the smt.design_space.DesignSpace class directly) of this problem from the _setup function. If used, there is no need to set xlimits. """ self._design_space = design_space diff --git a/smt/surrogate_models/gpx.py b/smt/surrogate_models/gpx.py index 1b5253b45..c0ffd15fe 100644 --- a/smt/surrogate_models/gpx.py +++ b/smt/surrogate_models/gpx.py @@ -92,7 +92,7 @@ def _initialize(self): None, types=(BaseDesignSpace, list, np.ndarray), desc="definition of the (hierarchical) design space: " - "use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds", + "use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds", ) supports = self.supports diff --git a/smt/surrogate_models/krg_based.py b/smt/surrogate_models/krg_based.py index aae65eee8..5989be8d7 100644 --- a/smt/surrogate_models/krg_based.py +++ b/smt/surrogate_models/krg_based.py @@ -201,7 +201,7 @@ def _initialize(self): None, types=(BaseDesignSpace, list, np.ndarray), desc="definition of the (hierarchical) design space: " - "use `smt.utils.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds", + "use `smt.design_space.DesignSpace` as the main API. Also accepts list of float variable bounds", ) declare( "is_ri", False, types=bool, desc="activate reinterpolation for noisy cases" diff --git a/smt/surrogate_models/surrogate_model.py b/smt/surrogate_models/surrogate_model.py index cecd57a65..5898c57db 100644 --- a/smt/surrogate_models/surrogate_model.py +++ b/smt/surrogate_models/surrogate_model.py @@ -390,7 +390,8 @@ def predict_variances(self, x: np.ndarray) -> np.ndarray: def predict_variance_derivatives(self, x: np.ndarray, kx: int) -> np.ndarray: """ - Provide the derivatives of the variance of the model at a set of points + Provide the derivatives of the variance of the model at a set of points. + Parameters ---------- x : np.ndarray [n_evals, dim] @@ -576,3 +577,11 @@ def save(self, filename): Implemented by surrogate models to save the surrogate object in a file """ raise NotImplementedError("save() has to be implemented by the given surrogate") + + @staticmethod + def load(filename): + """ + Static method implemented by each surrogate model type (ie class) + to load the surrogate object from a file created by using the corresponding save method + """ + raise NotImplementedError("load() has to be implemented by the given surrogate")