-
Notifications
You must be signed in to change notification settings - Fork 0
Nsga refactor #16
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
Nsga refactor #16
Conversation
| S = [[] for _ in range(population_size)] # Set of solutions dominated by p | ||
| n = [0 for _ in range(population_size)] # Number of solutions dominating p | ||
| front = [[]] # Final Pareto fronts | ||
| rank = [0 for _ in range(population_size)] # Rank of solution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better documentation
| # If p dominates q | ||
| if dominates(population[p], population[q]): | ||
| if q not in S[p]: | ||
| S[p].append(q) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't needed since we don't have duplicates in the population. Not sure why it was here in the first place
|
|
||
| # With this implementation the final front will be empty | ||
| del front[len(front)-1] | ||
| front.pop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nicer way to do this I think
| if obj_max != obj_min: | ||
| for i in range(1, len(sorted_front) - 1): | ||
| dist = sorted_front[i+1].metrics[m] - sorted_front[i-1].metrics[m] | ||
| # Normalize distance by objective range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More documentation for the distance function
| true_ranks = [1, 1, 1, 2, 3, 3, 3, 4, 4, 4] | ||
| obj1 = [0.15, 0.05, 0.02, 0.18, 0.83, 0.30, 0.43, 0.37, 0.73, 0.60] | ||
| obj2 = [0.15, 0.86, 0.96, 0.18, 0.21, 0.52, 0.29, 0.95, 0.59, 0.70] | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Values generated by ChatGPT, hand-verified to be correct.
Cleaned up the
fast_non_dominated_sortfunction and added a unit test to test it.