Skip to content
New issue

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

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

Already on GitHub? # to your account

Selection minor refactoring #918

Merged
merged 8 commits into from
Oct 14, 2022
Merged

Selection minor refactoring #918

merged 8 commits into from
Oct 14, 2022

Conversation

MorrisNein
Copy link
Collaborator

@MorrisNein MorrisNein commented Sep 29, 2022

  • Made all selection types significantly faster.
  • Made all selection types maintain default behavior: remove duplicate individuals and return a multiple instances of a single individual if only one individual was passed as a population.
  • Made inheritance use one of competitive selection algorithms at a time, instead of their mixture.

@nicl-nno
Copy link
Collaborator

Replaced while -> for, as it is significantly faster.

А почему он faster?

@codecov
Copy link

codecov bot commented Sep 29, 2022

Codecov Report

Merging #918 (b89185a) into master (530a066) will decrease coverage by 0.02%.
The diff coverage is 94.28%.

@@            Coverage Diff             @@
##           master     #918      +/-   ##
==========================================
- Coverage   88.32%   88.29%   -0.03%     
==========================================
  Files         203      203              
  Lines       13380    13374       -6     
==========================================
- Hits        11818    11809       -9     
- Misses       1562     1565       +3     
Impacted Files Coverage Δ
...dot/core/optimisers/gp_comp/operators/selection.py 72.22% <93.93%> (-2.78%) ⬇️
...edot/core/optimisers/gp_comp/operators/operator.py 90.90% <100.00%> (ø)
...on_implementations/models/discriminant_analysis.py 92.59% <0.00%> (-1.86%) ⬇️
...edot/core/optimisers/gp_comp/operators/mutation.py 93.80% <0.00%> (+0.44%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@MorrisNein
Copy link
Collaborator Author

MorrisNein commented Sep 29, 2022

А почему он faster?

Потому что в случае for инкрементирование и проверка числа итераций в заголовке на самом деле выполняется на C, а в случае while - на Python. Прочие действия в теле цикла примерно уравнивают время выполнения, но разница бывает заметной.

image

@MorrisNein MorrisNein force-pushed the minor_refactor_selection branch from faeaad1 to 501a98a Compare October 2, 2022 12:08
@MorrisNein
Copy link
Collaborator Author

Ускорил в 10 раз tournament_selection (по сравнению с предыдущей версией с for). Кроме того, при увеличении числа индивидов стабильно воспроизводилась ошибка, когда не удавалось набрать достаточно индивидов по достижении лимита итераций, поскольку раз за разом в выборку попадали лучшие индивиды, которые отсеивались как дубли. Ошибка была заметна при выборке 30 из 40 индивидов и более.

Исправил удалением выбранных индивидов из копии первоначальной выборки (которая теперь уникальный список), а также увеличил численность поколений в тесте tournament_selection.

@YamLyubov YamLyubov self-requested a review October 3, 2022 09:36
@MorrisNein MorrisNein force-pushed the minor_refactor_selection branch from 2c7d835 to e33eb3b Compare October 12, 2022 15:13
@MorrisNein MorrisNein force-pushed the minor_refactor_selection branch from 213f1a3 to 0eb198b Compare October 14, 2022 12:12
@MorrisNein MorrisNein force-pushed the minor_refactor_selection branch from 0eb198b to 4ced3a3 Compare October 14, 2022 12:21
@MorrisNein MorrisNein force-pushed the minor_refactor_selection branch from 4ced3a3 to b89185a Compare October 14, 2022 14:10
@MorrisNein MorrisNein merged commit fd468bc into master Oct 14, 2022
@MorrisNein MorrisNein deleted the minor_refactor_selection branch October 14, 2022 14:33
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants