paulknysh / blackbox

A Python module for parallel optimization of expensive black-box functions
MIT License
439 stars 60 forks source link

Parameters constraints #16

Closed ludovicdmt closed 5 years ago

ludovicdmt commented 5 years ago

I'm looking for an adaptation of your method to allow joint constraints on parameters, not individually (i.e. range of value for each params). For instance: param1 + param2 + param3 <1
0<param1<1
0<param2<1
0<param3<1 I can constraint range values of param1, param2 and param3 in [0, 1] but not the sum ?

Thank you

paulknysh commented 5 years ago

The method doesn't support such constraints.

You can still try running method in the whole domain (0<p1,p2,p3<1), but actually evaluating function only when p1+p2+p3 < 1 (otherwise returning some high value).

ludovicdmt commented 5 years ago

Thank you.

laepl commented 3 years ago

I tried your recommodation and it works fine for me, but I'm wondering why such constrains aren't supported. I guess this is because of the generation of sample points? Shouldn't it be possible to test if a generated point fulfills the boundary condition and to generate a new one if it isn't.

paulknysh commented 3 years ago

I guess it should be possible to provide some interface for constraints (initial sample generation can be adjusted I believe). I just couldn't think of a good way to specify them so far. If you have some thoughts that let me know.

laepl commented 3 years ago

Okay. Thank you for your answer! I will give some thought to it and if I have a promising idea, I will let you know.

laepl commented 3 years ago

I wrote a function for myself, that takes n, d and functions that are the boundary conditions (BC) as inputs. The function updates the number of points iteratively until enough points, that fulfill the BC, are generated. This is done by calculating the factor of points that fulfill the BC and points that don't. For my problem this works very well, as I work in 2D and my BC is of the kind x[0] > x[1], which cuts the accepted area in half. If the accepted area is very small and the number of requested points is quite high, I noticed some problems, because the updated number gets very large and the generation of points in the next iteration takes quite a while.

I still have to think about a good way to transform the boundary conditions to the unit cube, but I feel confident that that's possible.

If you're interested in the code, just let me know.