Exemple #1
0
 def test_abstract_raises(self):
     with self.assertRaises(TypeError):
         MCAcquisitionFunction()
     # raise if model is multi-output, but no objective is given
     no = "botorch.utils.testing.MockModel.num_outputs"
     with mock.patch(no, new_callable=mock.PropertyMock) as mock_num_outputs:
         mock_num_outputs.return_value = 2
         mm = MockModel(MockPosterior())
         with self.assertRaises(UnsupportedError):
             DummyMCAcquisitionFunction(model=mm)
    def __init__(self, model_list: List[Model], options: dict) -> None:

        # AnalyticAcquisitionFunction.__init__(self, model=ModelListGP(model_list[0],model_list[1]), objective=ScalarizedObjective(weights=torch.Tensor([1.0])))
        MCAcquisitionFunction.__init__(self,
                                       model=ModelListGP(
                                           model_list[0], model_list[1]),
                                       objective=constrained_obj)

        AcquisitionBaseToolsConstrained.__init__(
            self,
            model_list=model_list,
            iden="XsearchFailures",
            Nrestarts_eta_c=options["Nrestarts_eta_c"],
            budget_failures=options["budget_failures"])

        self.dim = model_list[0].dim
        self.u_vec = None
        self.Nsamples_fmin = options["Nsamples_fmin"]
        self.Nrestarts_safe = options["Nrestarts_safe"]
        assert self.Nrestarts_safe > 1, "Choose at least 2 restart points."
        self.Nrestarts_risky = options["Nrestarts_risky"]
        assert self.Nrestarts_risky > 1, "Choose at least 2 restart points."
        self.which_mode = "risky"
        self.NBOiters = options["NBOiters"]
        self.rho_conserv = options["rho_safe"]
        self.method_safe = options["method_safe"]
        self.method_risky = options["method_risky"]
        self.constrained_opt = ConstrainedOptimizationNonLinearConstraints(
            self.dim, self.forward, self.probabilistic_constraint)
        self.use_nlopt = False
        self.disp_info_scipy_opti = options["disp_info_scipy_opti"]
        self.decision_boundary = options["decision_boundary"]

        # Initialize rho latent process:
        if float(self.budget_failures) / self.NBOiters == 1.0:
            self.zk = norm.ppf(self.rho_conserv)
        else:
            self.zk = norm.ppf(float(self.budget_failures) / self.NBOiters)
        self.zrisk = norm.ppf(1.0 - self.rho_conserv)
        self.zsafe = norm.ppf(self.rho_conserv)
 def test_abstract_raises(self):
     with self.assertRaises(TypeError):
         MCAcquisitionFunction()
     # raise if model is multi-output, but no outcome transform or objective
     # are given
     no = "botorch.utils.testing.MockModel.num_outputs"
     with mock.patch(no,
                     new_callable=mock.PropertyMock) as mock_num_outputs:
         mock_num_outputs.return_value = 2
         mm = MockModel(MockPosterior())
         with self.assertRaises(UnsupportedError):
             DummyMCAcquisitionFunction(model=mm)
     # raise if model is multi-output, but outcome transform does not
     # scalarize and no objetive is given
     with mock.patch(no,
                     new_callable=mock.PropertyMock) as mock_num_outputs:
         mock_num_outputs.return_value = 2
         mm = MockModel(MockPosterior())
         ptf = DummyNonScalarizingPosteriorTransform()
         with self.assertRaises(UnsupportedError):
             DummyMCAcquisitionFunction(model=mm, posterior_transform=ptf)
Exemple #4
0
 def test_abstract_raises(self):
     with self.assertRaises(TypeError):
         MCAcquisitionFunction()