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

Fix mutation operator #238

Merged
merged 9 commits into from
Dec 27, 2023
Merged

Fix mutation operator #238

merged 9 commits into from
Dec 27, 2023

Conversation

YamLyubov
Copy link
Collaborator

@YamLyubov YamLyubov commented Nov 7, 2023

Changes:

  • If mutation will be applied is decided outside of the retry loop. Previously we were shooting ourselves in the foot trying to defenetly apply a mutation while deciding to apply it with some probability in the loop.
  • Also the choice of the mutation type is made outside the loop to collect proper experience for the agent (now the agent can know that the exact mutation type failed to apply to the specified graph).
  • Negative reward in case of unsuccesfull mutation is registered only once after several attempt. It prevents the agent of being biased.
  • Base mutations now try on different nodes to make any change which makes it possible to remove equality check in the mutation operator.

Proposed changes have shown better results on synthetic task for tree graph (random bandit).
Here is mean results for 20 launches with all implemented base mutations with 50 maximal iterations and 20 min time limit.
It can be seen that new version:

  • works faster,
  • converge in fewer iterations
  • achieves slightly better results (in tertms of mean and std).
    1
    2

It is a toy experiment but still...

New version results
image

Old version results
image

@kasyanovse kasyanovse self-requested a review November 8, 2023 07:55
@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (46b53a4) 71.94% compared to head (80d51b4) 72.04%.
Report is 4 commits behind head on main.

Files Patch % Lines
...ore/optimisers/genetic/operators/base_mutations.py 93.02% 6 Missing ⚠️
...ore/optimisers/genetic/parameters/mutation_prob.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #238      +/-   ##
==========================================
+ Coverage   71.94%   72.04%   +0.10%     
==========================================
  Files         136      136              
  Lines        8127     8164      +37     
==========================================
+ Hits         5847     5882      +35     
- Misses       2280     2282       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

golem/core/optimisers/genetic/operators/mutation.py Outdated Show resolved Hide resolved
golem/core/optimisers/genetic/operators/mutation.py Outdated Show resolved Hide resolved
golem/core/optimisers/genetic/operators/mutation.py Outdated Show resolved Hide resolved
golem/core/optimisers/genetic/operators/mutation.py Outdated Show resolved Hide resolved
test/integration/test_genetic_schemes.py Show resolved Hide resolved
@maypink maypink mentioned this pull request Dec 19, 2023
8 tasks
@kasyanovse
Copy link
Collaborator

kasyanovse commented Dec 21, 2023

В строке происходит проверка verifierом сразу после мутации. По идее, эта проверка реализована внутри мутации, ее можно убрать.

UPD: так как эта проверка осуществляется один раз при подготовке начального поколения, то пусть будет.

@kasyanovse
Copy link
Collaborator

kasyanovse commented Dec 26, 2023

У меня почему-то в ParentOperator в operators лежат функции, что несериализуемо и неудобно. Может быть хранить там строки, как сделано в кроссовере? Немного потестировал такой вариант у себя, все работает.
Я могу залить оба изменения, которые предложил в последних комментах.

@kasyanovse kasyanovse merged commit ee2e56c into main Dec 27, 2023
6 checks passed
@kasyanovse kasyanovse deleted the fix-mutation branch December 27, 2023 11:21
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

Successfully merging this pull request may close these issues.

4 participants