File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -175,3 +175,28 @@ def constraint_function(a, b):
175175 init_points = 2 ,
176176 n_iter = 10 ,
177177 )
178+
179+ def test_lower_less_than_upper ():
180+ def target_function (x , y ):
181+ return np .cos (2 * x ) * np .cos (y ) + np .sin (x )
182+
183+ def constraint_function_2_dim (x , y ):
184+ return np .array ([
185+ - np .cos (x ) * np .cos (y ) + np .sin (x ) * np .sin (y ),
186+ - np .cos (x ) * np .cos (- y ) + np .sin (x ) * np .sin (- y )
187+ ])
188+
189+ constraint_limit_lower = np .array ([0.6 , - np .inf ])
190+ constraint_limit_upper = np .array ([0.3 , 0.6 ])
191+
192+ conmod = NonlinearConstraint (constraint_function_2_dim , constraint_limit_lower , constraint_limit_upper )
193+ pbounds = {'x' : (0 , 6 ), 'y' : (0 , 6 )}
194+
195+ with raises (ValueError ):
196+ optimizer = BayesianOptimization (
197+ f = target_function ,
198+ constraint = conmod ,
199+ pbounds = pbounds ,
200+ verbose = 0 ,
201+ random_state = 1 ,
202+ )
You can’t perform that action at this time.
0 commit comments