def find_active_constraints(x, lb, ub, rtol=1e-10):
 active = np.zeros_like(x, dtype=int)
 if (rtol == 0):
  active[(x <= lb)] = (-1)
  active[(x >= ub)] = 1
  return active
 lower_dist = (x - lb)
 upper_dist = (ub - x)
 lower_threshold = (rtol * np.maximum(1, np.abs(lb)))
 upper_threshold = (rtol * np.maximum(1, np.abs(ub)))
 lower_active = (np.isfinite(lb) & (lower_dist <= np.minimum(upper_dist, lower_threshold)))
 active[lower_active] = (-1)
 upper_active = (np.isfinite(ub) & (upper_dist <= np.minimum(lower_dist, upper_threshold)))
 active[upper_active] = 1
 return active

def find_active_constraints ( x , lb , ub , rtol = 1e-10 ) : active = np . zeros_like ( x , dtype = int ) if ( rtol == 0 ) : active [ ( x <= lb ) ] = ( - 1 ) active [ ( x >= ub ) ] = 1 return active lower_dist = ( x - lb ) upper_dist = ( ub - x ) lower_threshold = ( rtol * np . maximum ( 1 , np . abs ( lb ) ) ) upper_threshold = ( rtol * np . maximum ( 1 , np . abs ( ub ) ) ) lower_active = ( np . isfinite ( lb ) & ( lower_dist <= np . minimum ( upper_dist , lower_threshold ) ) ) active [ lower_active ] = ( - 1 ) upper_active = ( np . isfinite ( ub ) & ( upper_dist <= np . minimum ( lower_dist , upper_threshold ) ) ) active [ upper_active ] = 1 return active
determine which constraints are active in a given point .