#NEWLINE# def make_strictly_feasible( x , lb , ub , rstep = 1e-10 ) : #NEWLINE# #INDENT# 'Shift a point to the interior of a feasible region.\n    \n    Each element of the returned vector is at least at a relative distance\n    `rstep` from the closest bound. If ``rstep=0`` then `np.nextafter` is used.\n    ' #NEWLINE# x_new = x . copy ( ) #NEWLINE# active = find_active_constraints ( x , lb , ub , rstep ) #NEWLINE# lower_mask = np . equal ( active , ( - 1 ) ) #NEWLINE# upper_mask = np . equal ( active , 1 ) #NEWLINE# if ( rstep == 0 ) : #NEWLINE# #INDENT# x_new [ lower_mask ] = np . nextafter ( lb [ lower_mask ] , ub [ lower_mask ] ) #NEWLINE# x_new [ upper_mask ] = np . nextafter ( ub [ upper_mask ] , lb [ upper_mask ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# x_new [ lower_mask ] = ( lb [ lower_mask ] + ( x_new * np . maximum ( 1 , np . abs ( lb [ lower_mask ] ) ) ) ) #NEWLINE# x_new [ upper_mask ] = ( ub [ upper_mask ] - ( rstep * np . maximum ( 1 , np . abs ( ub [ upper_mask ] ) ) ) ) #NEWLINE# #UNINDENT# tight_bounds = ( ( x_new < lb ) | ( x_new > ub ) ) #NEWLINE# x_new [ tight_bounds ] = ( 0.5 * ( lb [ tight_bounds ] + ub [ tight_bounds ] ) ) #NEWLINE# return x_new