Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some questions hoping for answering #11

Open
Hermione-2020 opened this issue May 28, 2022 · 1 comment
Open

Some questions hoping for answering #11

Hermione-2020 opened this issue May 28, 2022 · 1 comment

Comments

@Hermione-2020
Copy link

Hermione-2020 commented May 28, 2022

Hello Haris,
First of all thank you very much for sharing your work! I have some questions regarding the code.

  1. In line 136, the output of non_dominated_sorted_solution2_1 will always be 0,1,2... for every i, so it seems that the code is meaningless. I think what we should do is to align crowding distance and front order, which seems not to appear in the code.

The code below is the original code which seems not to achieve the target aligning crowding distance and front order.

for i in range(0,len(non_dominated_sorted_solution2)):
non_dominated_sorted_solution2_1 = [index_of(non_dominated_sorted_solution2[i][j], non_dominated_sorted_solution2[i] ) for j in range(0,len(non_dominated_sorted_solution2[i]))]
  1. In line 22, the definition of index_of(a,list) is not rigorous. If there are two same values which equal to a in the list, the function only outputs the first position. Thus, using the list.index(a) perhaps is a better choice.
def index_of(a,list):
    for i in range(0,len(list)):
        if list[i] == a:
            return i
    return -1
  1. The operations of mutation and crossover are strange, because it seems the parent is not correlated with children at all. From the code, we can see no matter which the selected individuals a, b are, the crossover will give a new random solution.
def crossover(a,b):
    r=random.random()
    if r>0.5:
        return mutation((a+b)/2)
    else:
        return mutation((a-b)/2)

def mutation(solution):
    mutation_prob = random.random()
    if mutation_prob <1:
        solution = min_x+(max_x-min_x)*random.random()
    return solution
  1. The crowding distance was also miscalculated and should have been calculated for each target and then added up, which has mentioned by other many times.
@Aaron2Woo
Copy link

great job, maybe you can adjust this code and share it with your page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants