| import numpy as np
|
| import dlib
|
|
|
| def minimizer_monitor(func):
|
| current_opt = np.inf
|
| def wrapped(*args, **kwargs):
|
| nonlocal current_opt
|
| result = func(*args, **kwargs)
|
| if result < current_opt:
|
| current_opt = result
|
| print(f"New min: {result}\t{args=}\t{kwargs=}")
|
| return result
|
| return wrapped
|
|
|
| @minimizer_monitor
|
| def rosen_f(*x):
|
| return rosen((x))
|
|
|
| x0 = np.ones(5)*0.25
|
| res = dlib.find_min_global(rosen_f, [0]*5, [0.5]*5, 100)
|