def get_task_runner(self, param, **kw): blackbox = BraninConstrained(noise_std=param.noise_std) bounds = Tensor(blackbox._bounds) objective = ClassicAugmentedLagrangianMCObjective( objective=lambda y: y[..., 0], constraints=list(lambda y, i=j: y[..., i] for j in range(1, blackbox.out_dim)), r=param['r'] ) sampler = SobolQMCNormalSampler( num_samples=param.num_mc_samples, seed=param.get('seed', None) ) acqfopt = qEiAcqfOptimizer(sampler=sampler) optimizer = AlboOptimizer( blackbox=blackbox, objective=objective, acqfopt=acqfopt, sampler=sampler, bounds=bounds ) run = partial( optimizer.optimize, niter=param.num_iter, init_samples=param.num_init_samples, al_iter=param.num_al_iter, seed=param.get('seed', None) ) return run
def main(): function = GardnerTestFunction() for j in range(25): x, y = generate_initial_data() for i in range(50): mll, model = initialize_model(x, y) fit_gpytorch_model(mll) augmented_objective = ClassicAugmentedLagrangianMCObjective( objective=lambda y: y[..., 0], constraints=[lambda y: y[..., 1]]) x_new = fit_augmented_objective(model, augmented_objective, x, y) y_new = function(x_new) x = torch.cat([x, x_new], dim=0) y = torch.cat([y, y_new], dim=0) np.save(f'results/x_{j}.bin', x) np.save(f'results/y_{j}.bin', y)