Skip to content

Commit d87dfad

Browse files
0.28.5
mo functions
1 parent b7c0d30 commit d87dfad

5 files changed

Lines changed: 97 additions & 1 deletion

File tree

30.6 KB
Loading
162 KB
Loading
174 KB
Loading

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

src/spotpython/mo/functions.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import numpy as np
2+
3+
4+
def conversion_pred(X) -> np.ndarray:
5+
"""
6+
Compute conversion predictions for each row in the input array.
7+
8+
Args:
9+
X (np.ndarray): 2D array where each row is a configuration.
10+
11+
Returns:
12+
np.ndarray: 1D array of conversion predictions.
13+
14+
Examples:
15+
>>> import numpy as np
16+
>>> from spotpython.mo.functions import conversion_pred
17+
>>> # Example input data
18+
>>> X = np.array([[1, 2, 3], [4, 5, 6]])
19+
>>> conversion_pred(X)
20+
array([ 3.5, 19.5])
21+
22+
"""
23+
return (
24+
81.09
25+
+ 1.0284 * X[:, 0]
26+
+ 4.043 * X[:, 1]
27+
+ 6.2037 * X[:, 2]
28+
- 1.8366 * X[:, 0] ** 2
29+
+ 2.9382 * X[:, 1] ** 2
30+
- 5.1915 * X[:, 2] ** 2
31+
+ 2.2150 * X[:, 0] * X[:, 1]
32+
+ 11.375 * X[:, 0] * X[:, 2]
33+
- 3.875 * X[:, 1] * X[:, 2]
34+
)
35+
36+
37+
def activity_pred(X)-> np.ndarray:
38+
"""
39+
Compute activity predictions for each row in the input array.
40+
41+
Args:
42+
X (np.ndarray): 2D array where each row is a configuration.
43+
44+
Returns:
45+
np.ndarray: 1D array of activity predictions.
46+
47+
Examples:
48+
>>> import numpy as np
49+
>>> from spotpython.mo.functions import activity_pred
50+
>>> # Example input data
51+
>>> X = np.array([[1, 2, 3], [4, 5, 6]])
52+
>>> activity_pred(X)
53+
array([ 1.5, 10.5])
54+
"""
55+
return (
56+
59.85
57+
+ 3.583 * X[:, 0]
58+
+ 0.2546 * X[:, 1]
59+
+ 2.2298 * X[:, 2]
60+
+ 0.83479 * X[:, 0] ** 2
61+
+ 0.07484 * X[:, 1] ** 2
62+
+ 0.05716 * X[:, 2] ** 2
63+
- 0.3875 * X[:, 0] * X[:, 1]
64+
- 0.375 * X[:, 0] * X[:, 2]
65+
+ 0.3125 * X[:, 1] * X[:, 2]
66+
)
67+
68+
69+
def fun_myer16a(X, fun_control=None)-> np.ndarray:
70+
"""
71+
Compute both conversion and activity predictions for each row in the input array.
72+
73+
Notes:
74+
Implements a response surface experiment described by Myers, Montgomery, and Anderson-Cook (2016). The function computes two objectives: conversion and activity.
75+
76+
References:
77+
- Myers, R. H., Montgomery, D. C., and Anderson-Cook, C. M. Response surface methodology: process and product optimization using designed experiments. John Wiley & Sons, 2016.
78+
- Kuhn, M. desirability: Function optimization and ranking via desirability functions. Tech. rep., 9 2016.
79+
80+
Args:
81+
X (np.ndarray): 2D array where each row is a configuration.
82+
fun_control (dict, optional): Additional control parameters (not used here).
83+
84+
Returns:
85+
np.ndarray: 2D array where each row contains [conversion_pred, activity_pred].
86+
87+
Examples:
88+
>>> import numpy as np
89+
>>> from spotpython.mo.functions import fun_myer16a
90+
>>> # Example input data
91+
>>> X = np.array([[1, 2, 3], [4, 5, 6]])
92+
>>> fun_myer16a(X)
93+
array([[ 3.5, 1.5],
94+
[ 19.5, 10.5]])
95+
"""
96+
return np.column_stack((conversion_pred(X), activity_pred(X)))

0 commit comments

Comments
 (0)