88from numpy import zeros , square , sqrt , full , around
99
1010
11- def get_ocba (means , vars , delta ):
11+ def get_ocba (means , vars , delta ) -> int32 :
1212 """
1313 Optimal Computer Budget Allocation (OCBA)
1414
15+ This function calculates the budget recommendations for a given set of means,
16+ variances, and incremental budget using the OCBA algorithm.
17+
1518 References:
1619 Chun-Hung Chen and Loo Hay Lee:
1720 Stochastic Simulation Optimization: An Optimal Computer Budget Allocation,
@@ -24,6 +27,17 @@ def get_ocba(means, vars, delta):
2427 and
2528 https://github.com/TomMonks/sim-tools
2629
30+ Args:
31+ means (numpy.array): An array of means.
32+ vars (numpy.array): An array of variances.
33+ delta (int): The incremental budget.
34+
35+ Returns:
36+ numpy.array: An array of budget recommendations.
37+
38+ Note:
39+ The implementation is based on the pseudo-code in the Chen et al. book (p. 49).
40+
2741 Examples:
2842
2943 From the Chen et al. book (p. 49):
@@ -32,18 +46,6 @@ def get_ocba(means, vars, delta):
3246 get_ocba(mean_y, var_y, 50)
3347
3448 [11 9 19 9 2]
35-
36- Args:
37- means (numpy.array):
38- means
39- vars (numpy.array):
40- variances
41- delta (int):
42- incremental budget
43-
44- Returns:
45- (numpy.array):
46- budget recommendations. `(n,)` numpy.array
4749 """
4850 n_designs = means .shape [0 ]
4951 allocations = zeros (n_designs , int32 )
@@ -79,6 +81,19 @@ def get_ocba(means, vars, delta):
7981 return add_budget - allocations
8082
8183
82- def get_ocba_X (X , means , vars , delta ):
84+ def get_ocba_X (X , means , vars , delta ) -> float64 :
85+ """
86+ This function calculates the OCBA allocation and repeats the input array X along the specified axis.
87+
88+ Args:
89+ X (numpy.ndarray): Input array to be repeated.
90+ means (list): List of means for each alternative.
91+ vars (list): List of variances for each alternative.
92+ delta (float): Indifference zone parameter.
93+
94+ Returns:
95+ numpy.ndarray: Repeated array of X along the specified axis based on the OCBA allocation.
96+
97+ """
8398 o = get_ocba (means = means , vars = vars , delta = delta )
8499 return repeat (X , o , axis = 0 )
0 commit comments