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

Investigate moving determine_alternative_permissible_values function for genes to __init__ of Genome. #196

Closed
mschmidt87 opened this issue Jul 20, 2020 · 3 comments · Fixed by #201
Assignees
Labels
maintenance Fighting the second law
Milestone

Comments

@mschmidt87
Copy link
Member

In the implementation introduced in #180 , we check for alternative permissible values for each gene every time we call the mutate method. This is wasteful since we can just do this once in the __init__ of Genome and store the results in a data structure.

This ticket is therefore about investigating this and implementing the change if deemed feasible.

@HenrikMettler
Copy link
Contributor

As a side note: We can not directly initialize the alternative permissible value, but only all permissible values for a gene, since the former depends on the current allele (basically: alternative_permissible_values = all_permissible_values \ {current_value})

@jakobj jakobj added this to the #thefuture milestone Jul 20, 2020
@jakobj
Copy link
Member

jakobj commented Jul 20, 2020

for completeness i'm quoting from #180

this might save quite some computation time at the expense of increased memory usage and slower instantiation of Genome objects. as always, the root of all evil is premature optimization, so i wouldn't implement this without profiling and finding that this is indeed a bottleneck. maybe a more lightweight compromise would be some kind of memoization, e.g., decorating the function determining all permissible values with the lru cache decorator.

@mschmidt87
Copy link
Member Author

Given that the memory footprint of the data structure to be stored is probably very small, and that the function determining all permissible value is always called with the same argument (the configuration of the dna, if it it determine all permissible value as suggested by @HenrikMettler above), I think that memoization is not a good alternative.

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

Successfully merging a pull request may close this issue.

3 participants