Skip to content

Commit ebbc427

Browse files
Enhanced Kriging Model Options
Kriging arguments exhanced: p_val for varying p, min_Lamba, max_Lambda, max_theta=2
1 parent 03d0aa7 commit ebbc427

4 files changed

Lines changed: 60 additions & 59 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotPython"
10-
version = "0.10.10"
10+
version = "0.10.11"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/build/kriging.py

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,6 @@
4343

4444
class 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

src/spotPython/spot/spot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,11 @@ def __init__(
311311
max_theta=self.surrogate_control["max_theta"],
312312
n_theta=self.surrogate_control["n_theta"],
313313
theta_init_zero=self.surrogate_control["theta_init_zero"],
314+
p_val=self.surrogate_control["p_val"],
314315
n_p=self.surrogate_control["n_p"],
315316
optim_p=self.surrogate_control["optim_p"],
317+
min_Lambda=self.surrogate_control["min_Lambda"],
318+
max_Lambda=self.surrogate_control["max_Lambda"],
316319
var_type=self.surrogate_control["var_type"],
317320
spot_writer=self.spot_writer,
318321
counter=self.design_control["init_size"] * self.design_control["repeats"] - 1,

src/spotPython/utils/init.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,13 @@ def surrogate_control_init(
359359
model_optimizer=differential_evolution,
360360
model_fun_evals=10000,
361361
min_theta=-3,
362-
max_theta=3,
362+
max_theta=2,
363363
n_theta=1,
364+
p_val=2,
364365
n_p=1,
365366
optim_p=False,
367+
min_Lambda=1e-9,
368+
max_Lambda=1,
366369
seed=124,
367370
theta_init_zero=True,
368371
var_type=None,
@@ -387,10 +390,16 @@ def surrogate_control_init(
387390
n_theta (int):
388391
The number of theta values. If larger than 1, then the k theta values are
389392
used, where k is the problem dimension. Default is 1.
393+
p_val (float):
394+
p value. Used as an initial value if optim_p = True. Otherwise as a constant. Defaults to 2.
390395
n_p (int):
391396
The number of p values. Number of p values to be used. Default is 1.
392397
optim_p (bool):
393398
Whether to optimize p or not.
399+
min_Lambda (float):
400+
The minimum value of lambda. Default is 1e-9.
401+
max_Lambda (float):
402+
The maximum value of lambda. Default is 1.
394403
seed (int):
395404
The seed to use for the random number generator.
396405
theta_init_zero (bool):
@@ -433,8 +442,11 @@ def surrogate_control_init(
433442
"min_theta": min_theta,
434443
"max_theta": max_theta,
435444
"n_theta": n_theta,
445+
"p_val": p_val,
436446
"n_p": n_p,
437447
"optim_p": optim_p,
448+
"min_Lambda": min_Lambda,
449+
"max_Lambda": max_Lambda,
438450
"seed": seed,
439451
"theta_init_zero": theta_init_zero,
440452
"var_type": var_type,

0 commit comments

Comments
 (0)