@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<=uto anOptimizableobject 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
xcan be:a numpy array, in that case
landuneed to be either:a floating number (will implement
l<=x<=u)a numpy arrays of the same size of
x. (will implementl[i]<=x[i]<=u[i]for alli)Nonein order to prescribe only a lower or an upper bound (for instance, iflisNone, then the decorator implementsx<=u).
a tuple of numpy arrays:
x = (x_1, x_2, ..., x_n)with fixed dimensionn. In that case,landuneed to tuples of lower and upper bounds:pythonl = (l_1, l_2, ..., l_n) # lower bounds u = (u_1, u_2, ..., u_n) # upper boundsThe decorator implements then the bound constraints
l_i<=x_i<=u_ifor every1<=i<=nwith the rule above ifl_iandu_iare floating numbers or numpy arrays.
Note
If both
l_iandu_iareNone, then no restriction applies to the optimization variablex_iwhich needs not be a numpy array.