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

Dev/genome reorder #239

Conversation

HenrikMettler
Copy link
Contributor

@HenrikMettler HenrikMettler commented Aug 25, 2020

Implements a first solution to #225
Reorders the nodes in the parents genome(s) before creating offspring, without violating any node dependencies, as suggested in Goldman 2015. Works only with levels_back = n_columns and n_rows = 1 since possible issue with limitations in levels_back and more than 1 row are not accounted for.
Currently I did not add a new example for this functionality but changed levels_back = n_columns in example_minimal.py and set the boolean for doing reorder to true.
Testing currently only covers repeated application of reorder on two examples genomes, while asserting no changes in the resulting sympy expression.

@HenrikMettler HenrikMettler marked this pull request as draft August 25, 2020 12:12
@jakobj jakobj added this to the 0.3.0 milestone Aug 27, 2020
@jakobj jakobj linked an issue Aug 27, 2020 that may be closed by this pull request
Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks for working on this! 🚀

i've added a few inline comments that should be addressed

cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/hl_api.py Outdated Show resolved Hide resolved
cgp/hl_api.py Outdated Show resolved Hide resolved
test/test_genome.py Outdated Show resolved Hide resolved
examples/example_minimal.py Outdated Show resolved Hide resolved
cgp/population.py Show resolved Hide resolved
@jakobj
Copy link
Member

jakobj commented Sep 1, 2020

also: mypy reports issues, please fix them :)

@HenrikMettler
Copy link
Contributor Author

Should I add more tests for the auxiliary functions used in reorder_genome or is the general empirical test sufficient?

Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, this is already much easier to understand, isn't it? 👌

i've added a few more inline comment

cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/hl_api.py Outdated Show resolved Hide resolved
Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, we're getting there :) some more inline suggestions

cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
@jakobj jakobj marked this pull request as ready for review September 4, 2020 15:58
@mschmidt87
Copy link
Member

Are you still working on this, @HenrikMettler ?

@HenrikMettler
Copy link
Contributor Author

Yes, was on holiday last week and this week I have some other priorities. Will probably wrap this up next week.

Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome work! 🥇

i've added some inline comments that should be addressed before merging

cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
test/test_genome.py Show resolved Hide resolved
test/test_genome.py Outdated Show resolved Hide resolved
test/test_genome.py Outdated Show resolved Hide resolved
test/test_genome.py Show resolved Hide resolved
test/test_genome.py Show resolved Hide resolved
Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work! 🚀

i've left a few more inline comments, i'd say one more round and we're ready to merge.

test/test_genome.py Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
cgp/hl_api.py Outdated Show resolved Hide resolved
cgp/hl_api.py Outdated Show resolved Hide resolved
cgp/hl_api.py Outdated Show resolved Hide resolved
cgp/ea/mu_plus_lambda.py Outdated Show resolved Hide resolved
cgp/ea/mu_plus_lambda.py Outdated Show resolved Hide resolved
@@ -25,6 +25,7 @@ def __init__(
n_processes: int = 1,
local_search: Callable[[IndividualBase], None] = lambda combined: None,
k_local_search: Union[int, None] = None,
reorder_genome: bool = True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mschmidt87 any strong feelings about changing this default behaviour? for 1.0 i'd anyway like to use this as the default, so we might as well change it now, right?

Copy link
Contributor Author

@HenrikMettler HenrikMettler Nov 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I set this default behavior to False for now? Otherwise, the tests and examples would require adaptation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, do it :) we can still change it at a later point in time.

Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the update!

a bit more nitpicking and please implement the test that raise exceptions as my inline comment indicates. otherwise this looks awesome!

cgp/ea/mu_plus_lambda.py Outdated Show resolved Hide resolved
cgp/genome.py Outdated Show resolved Hide resolved
examples/example_reorder.py Outdated Show resolved Hide resolved
test/test_genome.py Show resolved Hide resolved
Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome stuff! 👍

just one more question and I'd like to hear @mschmidt87's thoughts on changing the default behavior. if the default is changed, i guess we should adopt all tests and examples accordingly.

also, before merging it would be good to rewrite commit history such that each commit applies a logical change.

cgp/genome.py Outdated Show resolved Hide resolved
@HenrikMettler HenrikMettler force-pushed the dev/genome_reorder branch 2 times, most recently from 227dde8 to b4aff44 Compare October 30, 2020 11:19
Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, great work! 👍

before merging, the history still needs some cleaning up imho. i would suggest organizing this PR in three commits:

  • implementation of reorder
  • addition of tests
  • addition of example

@HenrikMettler
Copy link
Contributor Author

Is it ok, if I squash everything in one commit? Due to the previous squashing it is difficult to separate implementation, examples and test development (but I will try to keep this better seperated in future PR's)

@HenrikMettler HenrikMettler force-pushed the dev/genome_reorder branch 2 times, most recently from 7b20c7b to 0f44a01 Compare November 4, 2020 16:06
@HenrikMettler
Copy link
Contributor Author

@jakobj travis found a logic mistake in the example. I fixed it and while doing also adapted some docstrings to make more sense. Could you quickly look at them before merging?

@jakobj
Copy link
Member

jakobj commented Nov 5, 2020

looks great, thanks! 👍 travis is also happy! please squash the new commit, then it's ready to be merged. 🎉

@HenrikMettler HenrikMettler merged commit c2bd94d into Happy-Algorithms-League:master Nov 5, 2020
@HenrikMettler HenrikMettler deleted the dev/genome_reorder branch November 5, 2020 12:45
@jakobj jakobj modified the milestones: 0.3.0, 0.2.0 Nov 5, 2020
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.

Reorder genome to reduce limitations of gene connections
3 participants