I'm trying to solve black-box optimization task using Nevergrad. And that task is specific: domain of objective function is quite small, so when suggestion point x is not in domain, f(x) returns nan or any big value like 2.72489e+19 or larger.
My code:
import nevergrad as ng
def obj_function(x):
return black_box.get_function_value(x.tolist())
def solve():
initial_point = black_box.get_initial_point()
# init optimizer
param = ng.p.Array(shape=(parametrization_val,)).set_standardized_data(initial_point)
ng_optimizer = ng.optimizers.registry['BFGS'](parametrization=param, budget=1000)
for _ in range(ng_optimizer.budget):
x = ng_optimizer.ask()
obj_v = obj_function(*x.args, **x.kwargs)
ng_optimizer.tell(x, obj_v)
recommendation = ng_optimizer.provide_recommendation()
return recommendation.value
The main problem, that nevergrad optimizer suggest the same point many times until the budget ends. So my log looks like:
Suggestion:
2.34383, 2.23239, -1.48685, 0.742839, -1.16699, 1.04315, -1.00391, 0.0158264, -0.808701, -0.876145, 0.376727, 0.323922 ...
Cost (R): 2.72489e+19
______________________________
Suggestion:
2.34383, 2.23239, -1.48685, 0.742839, -1.16699, 1.04315, -1.00391, 0.0158264, -0.808701, -0.876145, 0.376727, 0.323922 ...
Cost (R): 2.72489e+19
.... ~150 repetitions of information above...
______________________________
Suggestion:
0.784922, -0.0693755, -0.0383782, 0.652343, -0.0737021, 0.119224, 0.627094, 0.904481, 0.53831, -0.528335, 0.29518 ...
Cost (R): 2.72489e+19
.... ~150 repetitions of information above...
So it can't fins solution and recommendation just return initial point as the best result. So I can't understand why nevergrad suggest repeated points and how to avoid this? Thank you