HGDL

The HGDL package is a high-performance, distributed, asynchronous optimizer that can be used for fvGP and therefore gpCAM training and the acquisition function optimization. However, it is its own python API which can be installed via "pip install hgdl". We present the API below.

Installation: pip install hgdl

To see the code and the tests: git clone -b v-m1.0 https://MarcusMichaelNoack@bitbucket.org/berkeleylab/hgdl.git

current version 1.3.3

class HGDL(func, grad, bounds,

hess = None, num_epochs=100000,

global_optimizer = "genetic",

local_optimizer = "dNewton",

number_of_optima = 1000000,

radius = None,

local_max_iter = 100,

args = (), constr = ())

Class Methods:


optimize(dask_client = None, x0 = None)

Starts the optimization using the specified dask client and optional starting locations.


result = get_latest(n = None)

Gets the latest n result while hgdl is running. n = None will give you all found solutions.


result = get_final(n = None)

Blocks the main thread until hgdl is done and returns the end n results. n = None will give you all found solutions.


result = cancel_tasks(n = None)

Cancels all tasks but leaves the client alive. Returns the best n results. n = None will give you all found solutions.


result = kill_client(n = None)

Cancels all tasks and kills the client. Returns the best n results. n = None will give you all found solutions.


Example: Find the minimum of the Rosenbrock function

def main():

from scipy.optimize import rosen, rosen_der, rosen_hess

import numpy as np

from hgdl.hgdl import HGDL

from time import sleep, perf_counter

print('this will create an hgdl object, sleep for 3'

' seconds, get the best result, sleep for 3 seconds,'

'then get the final result.\n'

'working on the epochs should happend even during sleeping\n'

)

a = HGDL(rosen, rosen_der,[[-2,2],[-2,2]], hess = rosen_hess, radius = 0.1, num_epochs = 10000)

a.optimize()



print("main thread submitted HGDL and will now sleep for 10 seconds")

sleep(5)

print("main thread asks for 10 best solutions:")

print(a.get_latest(10))

print("main sleeps for another 10 seconds")

sleep(3)

print("main thread kills optimization")

res = a.kill_client()

print("hgdl was killed but I am waiting 2s")

sleep(2)

print("")

print("")

print("")

print("")

print(res)


if __name__ == "__main__":

main()