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

Crowding Distance #7

Open
ayushmankd opened this issue Mar 4, 2020 · 2 comments
Open

Crowding Distance #7

ayushmankd opened this issue Mar 4, 2020 · 2 comments

Comments

@ayushmankd
Copy link

There is an error in Crowding Distance function.
It should be values1[i-1] - values1[i+i]
and values2[i-1] - values2[i+1]

@Arexh
Copy link

Arexh commented Sep 29, 2020

I agree.

@XuhuaYY
Copy link

XuhuaYY commented Feb 28, 2022

I think it's not just this error
sorted1 = sort_by_values(front, values1[:])
sorted2 = sort_by_values(front, values2[:])
the obtained two ordinal lists must be opposite, because front is a non-dominated solution, then their distance calculations have been misplaced, and should be changed to:


def crowding_distance(values1, values2, front):
    distance = [0 for i in range(0,len(front))]
    sorted1 = sort_by_values(front, values1[:])
    # sorted2 = sort_by_values(front, values2[:])
    distance[0] = 4444444444444444
    distance[len(front) - 1] = 4444444444444444
    for k in range(1,len(front)-1):
        distance[k] = abs(values1[sorted1[k+1]] - values1[sorted1[k-1]])/(max(values1)-min(values1))
        distance[k] = distance[k]+ abs(values2[sorted1[k+1]] - values2[sorted1[k-1]])/(max(values2)-min(values2))
    return distance

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

3 participants