Skip to content

Commit 5caf4e3

Browse files
committed
black
1 parent 03b87a5 commit 5caf4e3

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

libensemble/tests/unit_tests/test_aposmm_starting_point_finder.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from libensemble.gen_funcs.persistent_aposmm import (
33
initialize_APOSMM,
44
update_history_dist,
5-
decide_where_to_start_localopt
5+
decide_where_to_start_localopt,
66
)
77
from libensemble.sim_funcs.six_hump_camel import six_hump_camel_func
88

@@ -11,14 +11,14 @@ def setup_history_and_find_rk(n_s, num_to_start, lb, ub, f_vals, x_points):
1111
"""
1212
Populate the history array H with n_s points and bisect over r_k to find a value
1313
producing num_to_start local optimization start points using decide_where_to_start_localopt.
14-
14+
1515
Parameters:
1616
- n_s (int): Number of initial sample points.
1717
- num_to_start (int): Desired number of starting points for local optimization.
1818
- lb, ub (np.ndarray): Lower and upper bounds of the domain.
1919
- f_vals (np.ndarray): Function values at each x_point.
2020
- x_points (np.ndarray): n_s x d array of sample points.
21-
21+
2222
Returns:
2323
- H (np structured array): Updated history array.
2424
- rk_final (float): Value of r_k yielding num_to_start local opt starts.
@@ -30,21 +30,31 @@ def setup_history_and_find_rk(n_s, num_to_start, lb, ub, f_vals, x_points):
3030

3131
n = x_points.shape[1]
3232

33-
H = np.zeros(n_s,dtype=[("sim_id",int), ("x",float,n),("x_on_cube",float,n),("f",float),("local_pt",bool),("sim_ended",bool)])
34-
33+
H = np.zeros(
34+
n_s,
35+
dtype=[
36+
("sim_id", int),
37+
("x", float, n),
38+
("x_on_cube", float, n),
39+
("f", float),
40+
("local_pt", bool),
41+
("sim_ended", bool),
42+
],
43+
)
44+
3545
# Setup history
3646
for i in range(n_s):
37-
H[i]['x'] = x_points[i]
38-
H[i]['sim_id'] = i
39-
H[i]['x_on_cube'] = (x_points[i] - lb) / (ub - lb)
40-
H[i]['f'] = f_vals[i]
41-
H[i]['local_pt'] = False
42-
H[i]['sim_ended'] = True # Ensure point is considered by distance function
43-
44-
local_H = initialize_APOSMM(H,{"lb": lb, "ub": ub,"initial_sample_size": n_s, "localopt_method":None},{"comm": None})[-1]
47+
H[i]["x"] = x_points[i]
48+
H[i]["sim_id"] = i
49+
H[i]["x_on_cube"] = (x_points[i] - lb) / (ub - lb)
50+
H[i]["f"] = f_vals[i]
51+
H[i]["local_pt"] = False
52+
H[i]["sim_ended"] = True # Ensure point is considered by distance function
53+
54+
local_H = initialize_APOSMM(H, {"lb": lb, "ub": ub, "initial_sample_size": n_s, "localopt_method": None}, {"comm": None})[-1]
4555
local_H = local_H[:n_s] # Use only the required number of entries
4656

47-
update_history_dist(local_H,n)
57+
update_history_dist(local_H, n)
4858

4959
# Search to find r_k that yields exactly num_to_start start points
5060
r_low, r_high = 1e-5, 2.0 # Conservative initial bounds

0 commit comments

Comments
 (0)