hackingmaterials / rocketsled

plug-n-play black box optimizer for high-throughput computing
Other
43 stars 11 forks source link

Batch Optimization in Rocketsled #185

Closed awahabcmu closed 2 years ago

awahabcmu commented 2 years ago

Hi @ardunn @computron

I want to run batch optimization. The functionality of batch optimization is currently not working. Please find the relevant code which is simply finding a minima of Rosenbrock test function, batch_size of anything >1 causes FW to go to sleep loop:

import numpy as np
# Setting up the FireWorks LaunchPad
launchpad = LaunchPad(name="rsled")
opt_label = "opt_default"
db_info = {"launchpad": launchpad, "opt_label": opt_label}
x_dim = [(-5.0, 5.0), (-5.0, 5.0)]

@explicit_serialize
class ROSENBROCKTask(FireTaskBase):
    _fw_name = "ROSENBROCKTask"
    def run_task(self, fw_spec):
        x = fw_spec["_x"]
        y = (1 - x[0])** 2 + 100*(x[1] - x[0] ** 2) ** 2
        return FWAction(update_spec={"_y": y})

def wf_creator_ROSENBROCK(x):
    spec = {"_x": x}
    # ObjectiveFuncTask writes _y field to the spec internally.
    firework1 = Firework([ROSENBROCKTask(), OptTask(**db_info)], spec=spec)
    return Workflow([firework1])

def execute(n_evaluation, predictor_Selected, acquisition_function):
    mc = MissionControl(**db_info)
    launchpad.reset(password=date_, require_password=True)
    mc.reset(hard=True)
    mc.configure(wf_creator=wf_creator_ROSENBROCK, dimensions=x_dim, acq=acquisition_function,
                 predictor=predictor_Selected,batch_size=2)
    launchpad.add_wf(wf_creator_ROSENBROCK([a, b]))
    rapidfire(launchpad, nlaunches=n_evaluation, sleep_time=0)
    mc.results()

if __name__ == "__main__":
    date_='2021-11-28'
    a = np.random.uniform(-5,5)
    b = np.random.uniform(-5,5)

    predictor_Selected = 'GaussianProcessRegressor'
    acquisition_function = 'lcb'
    n_evaluation = 100
    execute(n_evaluation, predictor_Selected, acquisition_function)

My objective is to use the batch optimization to run several parallel experiments based on suggestions and implement other heuristic such as Krigging Believe and compare the results. A copy of this issue can be found here

Best, Abdul Wahab

ardunn commented 2 years ago

resolved in commits leading to https://github.com/hackingmaterials/rocketsled/commit/62816b9470e9375989ba3208113d99745d1c4178