def handle_constraint(observation, NUM_NODES):
    observation_original = observation.copy()
    mapping_index = []
    list_check = (observation[:, :].sum(1) > (params['container_limitation per node'] - 1))
    if (sum(list_check) == NUM_NODES):
        return ([], [])
    good_index = np.where((list_check == False))[0]
    length = len(good_index)
    index_replace = 0
    for node in range(NUM_NODES):
        if list_check[node]:
            index_this_replace = good_index[(index_replace % length)]
            index_replace += 1
            observation[node] = observation_original[index_this_replace]
            mapping_index.append(index_this_replace)
        else:
            mapping_index.append(node)
            observation[node] = observation_original[node]
    return (observation, mapping_index)
def handle_constraint(observation, NUM_NODES):
    observation_original = observation.copy()
    mapping_index = []
    list_check = (observation[:, :].sum(1) > (params['container_limitation per node'] - 1))
    if (sum(list_check) == NUM_NODES):
        return ([], [])
    good_index = np.where((list_check == False))[0]
    length = len(good_index)
    index_replace = 0
    for node in range(NUM_NODES):
        if list_check[node]:
            index_this_replace = good_index[(index_replace % length)]
            index_replace += 1
            observation[node] = observation_original[index_this_replace]
            mapping_index.append(index_this_replace)
        else:
            mapping_index.append(node)
            observation[node] = observation_original[node]
    return (observation, mapping_index)