Skip to content

Commit 21e7431

Browse files
v0.40.0
1 parent 452f6c1 commit 21e7431

5 files changed

Lines changed: 74 additions & 4 deletions

File tree

notebooks/00_spot_doc.ipynb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,46 @@
14921492
"return_conf_list_from_var_dict(var_dict, fun_control)[0]"
14931493
]
14941494
},
1495+
{
1496+
"attachments": {},
1497+
"cell_type": "markdown",
1498+
"metadata": {},
1499+
"source": [
1500+
"# Test Designs"
1501+
]
1502+
},
1503+
{
1504+
"cell_type": "code",
1505+
"execution_count": 5,
1506+
"metadata": {},
1507+
"outputs": [
1508+
{
1509+
"data": {
1510+
"text/plain": [
1511+
"array([[0.66352963, 0.5892358 ],\n",
1512+
" [0.66352963, 0.5892358 ],\n",
1513+
" [0.55592803, 0.96312564],\n",
1514+
" [0.55592803, 0.96312564],\n",
1515+
" [0.16481882, 0.0375811 ],\n",
1516+
" [0.16481882, 0.0375811 ],\n",
1517+
" [0.215331 , 0.34468512],\n",
1518+
" [0.215331 , 0.34468512],\n",
1519+
" [0.83604909, 0.62202146],\n",
1520+
" [0.83604909, 0.62202146]])"
1521+
]
1522+
},
1523+
"execution_count": 5,
1524+
"metadata": {},
1525+
"output_type": "execute_result"
1526+
}
1527+
],
1528+
"source": [
1529+
"import numpy as np\n",
1530+
"from spotPython.design.spacefilling import spacefilling\n",
1531+
"lhd = spacefilling(k=2, seed=123)\n",
1532+
"lhd.scipy_lhd(n=5, repeats=2, lower=np.array([0,0]), upper=np.array([1,1]))"
1533+
]
1534+
},
14951535
{
14961536
"cell_type": "code",
14971537
"execution_count": null,

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.0.39"
10+
version = "0.0.40"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/design/spacefilling.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ def scipy_lhd(
3838
3939
Returns:
4040
(numpy.ndarray): Latin hypercube design.
41+
Examples:
42+
>>> from spotPython.design.spacefilling import spacefilling
43+
import numpy as np
44+
lhd = spacefilling(k=2, seed=123)
45+
lhd.scipy_lhd(n=5, repeats=2, lower=np.array([0,0]), upper=np.array([1,1]))
46+
array([[0.66352963, 0.5892358 ],
47+
[0.66352963, 0.5892358 ],
48+
[0.55592803, 0.96312564],
49+
[0.55592803, 0.96312564],
50+
[0.16481882, 0.0375811 ],
51+
[0.16481882, 0.0375811 ],
52+
[0.215331 , 0.34468512],
53+
[0.215331 , 0.34468512],
54+
[0.83604909, 0.62202146],
55+
[0.83604909, 0.62202146]])
4156
"""
4257
if lower is None:
4358
lower = zeros(self.k)

src/spotPython/spot/spot.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ def append_X_ocba(self, X_ocba, X0):
316316
else:
317317
return X0
318318

319-
def run(self):
320-
self.initialize_design()
319+
def run(self, X_start=None):
320+
self.initialize_design(X_start)
321321
# (S-5) Calling the spotLoop Function
322322
# and
323323
# (S-9) Termination Criteria, Conditions:
@@ -334,14 +334,19 @@ def run(self):
334334
self.show_progress_if_needed(timeout_start)
335335
return self
336336

337-
def initialize_design(self):
337+
def initialize_design(self, X_start=None):
338338
# (S-2) Initial Design:
339339
X0 = self.generate_design(
340340
size=self.design_control["init_size"],
341341
repeats=self.design_control["repeats"],
342342
lower=self.lower,
343343
upper=self.upper,
344344
)
345+
if X_start is not None:
346+
try:
347+
X0 = append(X_start, X0, axis=0)
348+
except ValueError:
349+
logger.warning("X_start has wrong shape. Ignoring it.")
345350
X0 = repair_non_numeric(X0, self.var_type)
346351
self.X = X0
347352
# (S-3): Eval initial design:

src/spotPython/utils/eda.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,13 @@ def gen_design_table(fun_control: dict, spot: object = None, tablefmt="github")
7878
tablefmt=tablefmt,
7979
)
8080
return tab
81+
82+
83+
def compare_two_tree_models(model1, model2, headers=["Parameter", "Default", "Spot"]):
84+
keys = model1[1].summary.keys()
85+
values1 = model1[1].summary.values()
86+
values2 = model2[1].summary.values()
87+
tbl = []
88+
for key, value1, value2 in zip(keys, values1, values2):
89+
tbl.append([key, value1, value2])
90+
return tabulate(tbl, headers=headers, numalign="right", tablefmt="github")

0 commit comments

Comments
 (0)