Esempio n. 1
0
def trust_region_constr_nonlinear_constraint():
    constraint_function = lambda x: (x[0] + x[1])**2
    constraints = [
        NonlinearInequalityConstraint(constraint_function, np.array([2.]),
                                      np.array([np.inf]))
    ]
    return OptTrustRegionConstrained([(-1, 1), (-1, 1)], constraints, 1000)
Esempio n. 2
0
def test_invalid_constraint_object():
    constraint_function = lambda x: (x[0] + x[1])**2
    with pytest.raises(ValueError):
        return OptTrustRegionConstrained([(-1, 1), (-1, 1)],
                                         [constraint_function], 1000)
Esempio n. 3
0
def trust_region_constr_linear_constraint():
    constraints = [
        LinearInequalityConstraint(np.array([[0, 1]]), np.array([0.5]),
                                   np.array([np.inf]))
    ]
    return OptTrustRegionConstrained([(-1, 1), (-1, 1)], constraints, 1000)
Esempio n. 4
0
 def _get_optimizer(self, context_manager):
     if len(self.space.constraints) == 0:
         return OptLbfgs(context_manager.contextfree_space.get_bounds())
     else:
         return OptTrustRegionConstrained(context_manager.contextfree_space.get_bounds(), self.space.constraints)