def make_strictly_feasible(x, lb, ub, rstep=1e-10):
 x_new = x.copy()
 active = find_active_constraints(x, lb, ub, rstep)
 lower_mask = np.equal(active, (-1))
 upper_mask = np.equal(active, 1)
 if (rstep == 0):
  x_new[lower_mask] = np.nextafter(lb[lower_mask], ub[lower_mask])
  x_new[upper_mask] = np.nextafter(ub[upper_mask], lb[upper_mask])
 else:
  x_new[lower_mask] = (lb[lower_mask] + (rstep * np.maximum(1, np.abs(lb[lower_mask]))))
  x_new[upper_mask] = (ub[upper_mask] - (rstep * np.maximum(1, np.abs(ub[upper_mask]))))
 tight_bounds = ((x_new < lb) | (x_new > ub))
 x_new[tight_bounds] = (0.5 * (lb[tight_bounds] + ub[tight_bounds]))
 return x_new

def make_strictly_feasible ( x , lb , ub , rstep = 1e-10 ) : x_new = x . copy ( ) active = find_active_constraints ( x , lb , ub , rstep ) lower_mask = np . equal ( active , ( - 1 ) ) upper_mask = np . equal ( active , 1 ) if ( rstep == 0 ) : x_new [ lower_mask ] = np . nextafter ( lb [ lower_mask ] , ub [ lower_mask ] ) x_new [ upper_mask ] = np . nextafter ( ub [ upper_mask ] , lb [ upper_mask ] ) else : x_new [ lower_mask ] = ( lb [ lower_mask ] + ( rstep * np . maximum ( 1 , np . abs ( lb [ lower_mask ] ) ) ) ) x_new [ upper_mask ] = ( ub [ upper_mask ] - ( rstep * np . maximum ( 1 , np . abs ( ub [ upper_mask ] ) ) ) ) tight_bounds = ( ( x_new < lb ) | ( x_new > ub ) ) x_new [ tight_bounds ] = ( 0.5 * ( lb [ tight_bounds ] + ub [ tight_bounds ] ) ) return x_new
shift a point to the interior of a feasible region .