def run_test(): print('===== Test Start =====') # Define Search Space space = sp.Space() x1 = sp.Real("x1", -5, 10, default_value=0) x2 = sp.Real("x2", 0, 15, default_value=0) space.add_variables([x1, x2]) # Run try: max_runs = 10 opt = Optimizer( branin, space, max_runs=max_runs, time_limit_per_trial=30, task_id='test_install', ) history = opt.run() except Exception: print(traceback.format_exc()) print('===== Exception in run_test()! Please check. =====') else: cnt = history.trial_states.count(SUCCESS) if cnt == max_runs: print('===== Congratulations! All trials succeeded. =====') else: print('===== %d/%d trials failed! Please check. =====' % (max_runs - cnt, max_runs))
t2 = np.cos(x) * np.exp((1 - np.sin(y))**2) t3 = (x - y)**2 result = dict() result['objs'] = [ t1 + t2 + t3, ] result['constraints'] = [ np.sum((X + 5)**2) - 25, ] return result if __name__ == "__main__": params = {'float': {'x0': (-10, 0, -5), 'x1': (-6.5, 0, -3.25)}} space = sp.Space() space.add_variables( [sp.Real(name, *para) for name, para in params['float'].items()]) opt = Optimizer( mishra, space, num_constraints=1, num_objs=1, surrogate_type='gp', acq_optimizer_type='random_scipy', max_runs=50, time_limit_per_trial=10, task_id='soc', ) history = opt.run()