Skip to content
Draft
2 changes: 2 additions & 0 deletions libensemble/gen_classes/aposmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def __init__(
("local_pt", bool),
]
gen_specs["persis_in"] = ["x", "f", "local_pt", "sim_id", "sim_ended", "x_on_cube", "local_min"]
if "components" in kwargs or "components" in gen_specs.get("user", {}):
gen_specs["persis_in"].append("fvec")
super().__init__(variables, objectives, History, persis_info, gen_specs, libE_info, **kwargs)
if not self.persis_info.get("nworkers"):
self.persis_info["nworkers"] = kwargs.get("nworkers", gen_specs["user"]["max_active_runs"])
Expand Down
32 changes: 18 additions & 14 deletions libensemble/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ def __init__(
self._internal_variable = "x" # need to figure these out dynamically
self._internal_objective = "f"

if self.variables:

self.n = len(self.variables)
# build our own lb and ub
lb = []
ub = []
for i, v in enumerate(self.variables.values()):
if isinstance(v, list) and (isinstance(v[0], int) or isinstance(v[0], float)):
lb.append(v[0])
ub.append(v[1])
kwargs["lb"] = np.array(lb)
kwargs["ub"] = np.array(ub)
# if self.variables:

# self.n = len(self.variables)
# # build our own lb and ub
# lb = []
# ub = []
# for i, v in enumerate(self.variables.values()):
# if isinstance(v, list) and (isinstance(v[0], int) or isinstance(v[0], float)):
# lb.append(v[0])
# ub.append(v[1])
# kwargs["lb"] = np.array(lb)
# kwargs["ub"] = np.array(ub)

if len(kwargs) > 0: # so user can specify gen-specific parameters as kwargs to constructor
if not self.gen_specs.get("user"):
Expand Down Expand Up @@ -208,8 +208,12 @@ def setup(self) -> None:
self.libE_info["comm"] = self.running_gen_f.comm

def _set_sim_ended(self, results: npt.NDArray) -> npt.NDArray:
new_results = np.zeros(len(results), dtype=self.gen_specs["out"] + [("sim_ended", bool), ("f", float)])
for field in results.dtype.names:
filtered_dtype = [
(name, results.dtype[name]) for name in results.dtype.names if name in self.gen_specs["persis_in"]
]
new_dtype = filtered_dtype + [("sim_ended", bool)]
new_results = np.zeros(len(results), dtype=new_dtype)
for field in new_results.dtype.names: # only copy over fields that generator explicitly wants
try:
new_results[field] = results[field]
except ValueError: # lets not slot in data that the gen doesnt need?
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ psutil = ">=5.9.4,<7"

[tool.pixi.target.osx-arm64.dependencies]
clang_osx-arm64 = ">=19.1.2,<20"
libgfortran5 = ">=14.2.0,<15"

[tool.black]
line-length = 120
Expand Down