4343
4444class Kriging (surrogates ):
4545 """Kriging surrogate.
46-
47- Attributes:
48- nat_range_X (list):
49- List of X natural ranges.
50- nat_range_y (list):
51- List of y nat ranges.
52- noise (bool):
53- noisy objective function. Default: False. If `True`, regression kriging will be used.
54- var_type (str):
55- variable type. Can be either `"num`" (numerical) of `"factor"` (factor).
56- num_mask (array):
57- array of bool variables. `True` represent numerical (float) variables.
58- factor_mask (array):
59- array of factor variables. `True` represents factor (unordered) variables.
60- int_mask (array):
61- array of integer variables. `True` represents integers (ordered) variables.
62- ordered_mask (array):
63- array of ordered variables. `True` represents integers or float (ordered) variables.
64- Set of veriables which an order relation, i.e., they are either num (float) or int.
65- name (str):
66- Surrogate name
67- seed (int):
68- Random seed.
69- sigma (float):
70- Kriging sigma.
71- gen (method):
72- Design generator, e.g., spotPython.design.spacefilling.spacefilling.
73- min_theta (float):
74- min log10 theta value. Defaults: -6.
75- max_theta (float):
76- max log10 theta value. Defaults: 3.
77- min_p (float):
78- min p value. Default: 1.
79- max_p (float):
80- max p value. Default: 2.
81- theta_init_zero (bool):
82- Initialize theta with zero. Default: True.
8346 """
8447 def __init__ (
8548 self : object ,
@@ -89,12 +52,15 @@ def __init__(
8952 seed : int = 124 ,
9053 model_optimizer = None ,
9154 model_fun_evals : Optional [int ] = None ,
92- min_theta : float = - 3 ,
93- max_theta : float = 2 ,
55+ min_theta : float = - 3.0 ,
56+ max_theta : float = 2.0 ,
9457 n_theta : int = 1 ,
95- n_p : int = 1 ,
9658 theta_init_zero : bool = True ,
59+ p_val : float = 2.0 ,
60+ n_p : int = 1 ,
9761 optim_p : bool = False ,
62+ min_Lambda : float = 1e-9 ,
63+ max_Lambda : float = 1. ,
9864 log_level : int = 50 ,
9965 spot_writer = None ,
10066 counter = None ,
@@ -108,19 +74,38 @@ def __init__(
10874 var_type (List[str]):
10975 Variable type. Can be either "num" (numerical) or "factor" (factor).
11076 Defaults to ["num"].
111- name (str): Surrogate name. Defaults to "kriging".
112- seed (int): Random seed. Defaults to 124.
113- model_optimizer : Optimizer on the surrogate. If None, differential_evolution is selected.
114- model_fun_evals (Optional[int]): Number of iterations used by the optimizer on the surrogate.
115- min_theta (float): Min log10 theta value. Defaults to -3.
116- max_theta (float): Max log10 theta value. Defaults to 2.
117- n_theta (int): Number of theta values. Defaults to 1.
118- theta_init_zero (bool): Initialize theta with zero. Defaults to True.
119- n_p (int): Number of p values. Defaults to 1.
120- optim_p (bool): Determines whether p should be optimized.
121- log_level (int): Logging level, e.g., 20 is "INFO". Defaults to 50 ("CRITICAL").
122- spot_writer : Spot writer.
123- counter : Counter.
77+ name (str):
78+ Surrogate name. Defaults to "kriging".
79+ seed (int):
80+ Random seed. Defaults to 124.
81+ model_optimizer (Optional[object]):
82+ Optimizer on the surrogate. If None, differential_evolution is selected.
83+ model_fun_evals (Optional[int]):
84+ Number of iterations used by the optimizer on the surrogate.
85+ min_theta (float):
86+ Min log10 theta value. Defaults to -3.
87+ max_theta (float):
88+ Max log10 theta value. Defaults to 2.
89+ n_theta (int):
90+ Number of theta values. Defaults to 1.
91+ theta_init_zero (bool):
92+ Initialize theta with zero. Defaults to True.
93+ p_val (float):
94+ p value. Used as an initial value if optim_p = True. Otherwise as a constant. Defaults to 2.
95+ n_p (int):
96+ Number of p values. Defaults to 1.
97+ optim_p (bool):
98+ Determines whether p should be optimized. Deafults to False.
99+ min_Lambda (float):
100+ Min Lambda value. Defaults to 1e-9.
101+ max_Lambda (float):
102+ Max Lambda value. Defaults to 1.
103+ log_level (int):
104+ Logging level, e.g., 20 is "INFO". Defaults to 50 ("CRITICAL").
105+ spot_writer (Optional[object]):
106+ Spot writer. Defaults to None.
107+ counter (Optional[int]):
108+ Counter. Defaults to None.
124109
125110 Examples:
126111 >>> from spotPython.build.kriging import Kriging
@@ -173,9 +158,10 @@ def __init__(
173158 self .max_theta = max_theta
174159 self .min_p = 1
175160 self .max_p = 2
176- self .min_Lambda = 1e-9
177- self .max_Lambda = 1.
161+ self .min_Lambda = min_Lambda
162+ self .max_Lambda = max_Lambda
178163 self .n_theta = n_theta
164+ self .p_val = p_val
179165 self .n_p = n_p
180166 self .optim_p = optim_p
181167 self .theta_init_zero = theta_init_zero
@@ -187,7 +173,7 @@ def __init__(
187173 if self .model_optimizer is None :
188174 self .model_optimizer = differential_evolution
189175 self .model_fun_evals = model_fun_evals
190- # differential evaluation uses maxiter = 1000
176+ # differential evolution uses maxiter = 1000
191177 # and sets the number of function evaluations to
192178 # (maxiter + 1) * popsize * N, which results in
193179 # 1000 * 15 * k, because the default popsize is 15 and
@@ -683,7 +669,7 @@ def initialize_matrices(self) -> None:
683669 None
684670 """
685671 logger .debug ("In initialize_matrices(): self.n_p: %s" , self .n_p )
686- self .p = ones (self .n_p ) * 2.0
672+ self .p = ones (self .n_p ) * self . p_val
687673 logger .debug ("In initialize_matrices(): self.p: %s" , self .p )
688674 # if var(self.nat_y) is > 0, then self.pen_val = self.n * log(var(self.nat_y)) + 1e4
689675 # else self.pen_val = self.n * var(self.nat_y) + 1e4
0 commit comments