def compute_kkt_optimality(g, on_bound):
 g_kkt = (g * on_bound)
 free_set = (on_bound == 0)
 g_kkt[free_set] = np.abs(g[free_set])
 return np.max(g_kkt)

def compute_kkt_optimality ( g , on_bound ) : g_kkt = ( g * on_bound ) free_set = ( on_bound == 0 ) g_kkt [ free_set ] = np . abs ( g [ free_set ] ) return np . max ( g_kkt )
compute the maximum violation of kkt conditions .