@bound_constraints_optimizable

bound_constraints_optimizable(l=None, u=None)

A decorator for adding bound constraints to an optimizable object.

Usage:

python
@bound_constraints_optimizable(l,u)
class Problem(Optimizable):  
     def x0(self):   
         #x0 
     #...

This decorator appends bound constraints l<=x<=u to an Optimizable object of the form

\[\begin{aligned} \min_{x\in \R^n}& \quad J(x)\\ \textrm{s.t.} & \left\{\begin{aligned} g(x)&=0,\\ h(x)&\leqslant 0, \end{aligned}\right. \end{aligned}\]

The optimization variable x can be:

  • a numpy array, in that case l and u need to be either:

    • a floating number (will implement l<=x<=u)

    • a numpy arrays of the same size of x. (will implement l[i]<=x[i]<=u[i] for all i)

    • None in order to prescribe only a lower or an upper bound (for instance, if l is None, then the decorator implements x<=u).

  • a tuple of numpy arrays: x = (x_1, x_2, ..., x_n) with fixed dimension n. In that case, l and u need to tuples of lower and upper bounds:

    python
    l = (l_1, l_2, ..., l_n) # lower bounds 
    u = (u_1, u_2, ..., u_n) # upper bounds
    

    The decorator implements then the bound constraints l_i<=x_i<=u_i for every 1<=i<=n with the rule above if l_i and u_i are floating numbers or numpy arrays.

Note

If both l_i and u_i are None, then no restriction applies to the optimization variable x_i which needs not be a numpy array.