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

Added sequence generation option by giving a generator method #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

btezergil
Copy link

Proposed Changes

  • Added :generator option to evolve method to use sequence generator function
  • Converted build-population into a multi-arity method that supports sequence generator function

Pre-merge Checklist

  • Write + run tests
  • Update CHANGELOG and increment version
  • Update README and relevant documentation

monitors (:monitors options)]
(loop [population (io/build-population population-size allele-set genome-length fitness-function)
monitors (:monitors options)
sequence-generator-function (:generator options)]
Copy link
Owner

Choose a reason for hiding this comment

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

Could you add this to the docstring for this function?

Copy link
Author

Choose a reason for hiding this comment

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

The new commit addresses this, you can find my detailed response below.

"Build `population-size` individuals by invoking `build-individual` on random, conforming genetic sequences."
[population-size alleles sequence-length fitness-function]
(repeatedly population-size #(build-individual (generate-sequence alleles sequence-length) fitness-function)))
"Build `population-size` individuals by invoking `build-individual` on random, conforming genetic sequences.
Copy link
Owner

Choose a reason for hiding this comment

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

This looks good, but I'd really appreciate a test with a trivial sequence-generator-function if you wouldn't mind

and removed the unused function parameters for sequence generation
functon case
@btezergil
Copy link
Author

I've made updates to core.cljc in my latest commit. I think the initial implementation lacked some clarity in the sense that it made two function parameters (allele-set and genome-length) obsolete. Therefore, I've extracted the common parts into a function with a docstring, and divided the evolve method into two parts, the new one only gets a generator function instead of an allele set and genome length. I've also added an explanatory docstring into the new method.

While the new changes were not necessary in terms of functionality, I think eliminating the unused parameters made the overall code more readable. If you are okay with this version, I'll be adding the necessary tests to finalize the development related to this.

There is a middle commit that is unrelated, I'll be removing that part and squashing the commits together after you are okay with all changes.

Also, as a final point, I've realized after a couple of hours that the mutation and crossover functions require nature's individual structure to be returned, we can make this clearer in docstrings. WDYT?

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.

None yet

3 participants