haris989 / NSGA-II

This is a python implementation of NSGA-II algorithm. NSGA is a popular non-domination based genetic algorithm for multi-objective optimization. It is a very effective algorithm but has been generally criticized for its computational complexity, lack of elitism and for choosing the optimal parameter value for sharing parameter σshare. A modified version, NSGA II was developed, which has a better sorting algorithm , incorporates elitism and no sharing parameter needs to be chosen a priori.
MIT License
380 stars 158 forks source link

Why do you calculate the index of the minimum value of a list to calculate three times? #3

Open harrylyx opened 5 years ago

harrylyx commented 5 years ago
#Function to sort by values
def sort_by_values(list1, values):
    sorted_list = []
    while(len(sorted_list)!=len(list1)):
        if index_of(min(values),values) in list1:
            sorted_list.append(index_of(min(values),values))
        values[index_of(min(values),values)] = math.inf
    return sorted_list

Why do you calculate the index of the minimum value of a list to calculate three times? And does this function not generate a return value the same as list1?

NimishVerma commented 3 years ago

I am wondering the same, plus why is there a function for index_of when we already have list.index()?