Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Major change for creating individuals and population#43

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
tpdsantos wants to merge55 commits intowildart:master
base:master
Choose a base branch
Loading
fromtpdsantos:master

Conversation

tpdsantos
Copy link

Based on the approach of thega package in python, each gene has its own structure, making it easier to create individual and populations.

Another main advantage is that is now very easy to create individuals with different types of genes, being them binary, integer or floating-point genes. All the crossover, mutation and selection functions were modified, and some dispatches created, to accomodate this new approach. Added simple examples in the README file and some basic usage.

Added as well a prototype for parallelization of the population using theDistributedArrays package. It works well but needs more intensive testing with different types of populations.

tpdsantosand others added24 commitsFebruary 19, 2020 18:19
Some parts of the code are now obsolete and the genetic algorithm does not work with with different types of chromossome, that's my goal from now on.
The individual, instead of being a vector of values, is a vector of AbstractGene. Each entry of the vector is a gene, of any type supported (binary, integer and float). Now the individual can have different types of genes.
Already did some testing regarding mutations of any gene, and they're working fine. Now the issue are the crossover and selectionfunctions, since there's one per Genetic Algorithm run. Need to think better on wht'a best and more efficient.
Started debugging the entire code, created a new file just for the structures and some other global code.Have to test the selection function
Changed the way the fitting tolerance is calculated, since it was giving some weird results, now it's simpler.Changed the infinite while loop for a for loop to be able to parallelize it in the future.
The FloatGene has already been tested and works fine. Now I have to start building parallel code.
…ADME to add the functions and behaviours created.
Finally fixed the problem regarding the parent population being also updated during crossovers, forgot that,for structures, a `copy` is not enough, a `deepcopy` was needed.
Finally finished the first prototype for parallelizing the Genetic Algorithm using DistributedArrays package.It works quite well, but now it needs to be modified to be able to use piping for communication with external programs.
Now communication through FIFOs works using parallel computation.For non-parallel computation it does not work because the pipes must be launched in separate processes.
The previous prototype was quite slow due to using remote channels and the pipe reading not being madein the process it was running. Now the remote channels are gone and the pipe reading and the objectivefunction are determined in the same process, which is much more efficient and faster.
@stephenll
Copy link

For the Elitism line 157 in ga.jl, could you utilize thefull_fitness rather than recalculate to populatefitness? This could help if your objective function is expensive.

I've seen in other GA algorithms, the fitness is kept with the individual and only recalculated if it is from a mutation or crossover.

@tpdsantos
Copy link
Author

you're absolutely right, I'm already aware of that and fixed it after doing this pull request, now the objective function is used only in thefull_fitness variable

When not using external programs the GA code worls well with both computers connected, now I have to figure out out torun properly using external programs
@wildart
Copy link
Owner

@tpdsantos Thanks for the effort. However, can we make these changes gradually. I will not be able to review PR in this form.
Some of the things that I noticed:

  • Why do you need to to create a wrapper type for mutations & etc.?
  • Why the input type for mutating functions changed toBitVector? I understand change from Vector{Bool}, but why the rest?

I deliberately tried to be open-ended with the individual type, so any kind of structure can be accepted. Introducing a supertype, e.g. AbstractGene, seems like a big constraint. In any way, you would write specific mutations and recombinations for the special individual type but they would remain in functional form. This PR would require any additional individual type integrated into the package.

If you need to attach any specific information to individual, e.g.IntegerGene name value, you can create a wrapper function around your type to expose an individual structure to the already available individual modification functions. Similarly to what you do withSelection type wrapper.

@tpdsantos
Copy link
Author

@wildart thanks for the reply. I understand that there are many changes. My main reason was just to add this branch to your project to ease the creation of individual types, since I thought it was confusing and the documentation was lacking.

Following your points:

  • I created the wrapper for mutations because the mutations available were for specific types of genes, and if the individual has different types of genes the mutations must be different as well. I was basically trying to not mess with thega function. regarding the wrapper around theIntegerGene, I wanted to give the user the ability to easily change the mutation functions BEFORE entering thega function. My main goal was to compile all that I could before running the algorithm itself and not evaluate the mutation symbol in each iteration.
  • I actually only changed theVector{Bool} types forBitVector

Anyway, I understand that it can't be done now. I'm still working on this branch, since I want to add more functionalities for parallelism, working out-of-the-box with external programs and easily integrate the code with clusters. If I have time I'll try to make it even more general.

What do you think the branch needs to be accepted?

@wildart
Copy link
Owner

I wanted to give the user the ability to easily change the mutation functions BEFORE entering thega function. My main goal was to compile all that I could before running the algorithm itself and not evaluate the mutation symbol in each iteration.

Mutations is a parameter toga, you can overwritega to accept mutation symbols instead of function names, and select an appropriate function to pass to the original version ofga.

I'm still working on this branch, since I want to add more functionalities for parallelism, working out-of-the-box with external programs and easily integrate the code with clusters.

I understand that parallelism is long overdue for this package. But, initially one thing should be addressed before implementing it. In#36, I outlined that an individual initialization must be removed from the main algorithm, as it runs only one before starting main algorithm loop. That would make possible to deconstruct main algorithm to a components suitable for parallelization.

I think that specific parallel devices must be created to run parts of the algorithm in single-core, multi-core and multi-threading environments. I haven't started thought of this much. I opened a new issue to discuss the parallelization approach. See#45.

tpdsantosand others added4 commitsMarch 3, 2021 01:21
Before this update boundary checking was performed AFTER the new variables were saved in the gene vector, which made it much more difficult to have new values inside boundaries.In this update, boundary checking is made BEFORE new values are saved, drastically increasing the probability of having new values inside boundaries.
@wildartwildartforce-pushed themaster branch 14 times, most recently from71d4d34 tob925a2cCompareOctober 30, 2021 18:25
@wildartwildartforce-pushed themaster branch 4 times, most recently fromf8f9fc4 tocc7ffe2CompareDecember 10, 2021 20:29
@wildartwildartforce-pushed themaster branch 2 times, most recently from12d8cee tob0f5477CompareDecember 20, 2021 02:47
@wildartwildartforce-pushed themaster branch 2 times, most recently fromdd6579c toc81f2c9CompareDecember 29, 2021 01:18
@wildartwildartforce-pushed themaster branch 3 times, most recently from091f38a tocf3f2fbCompareMarch 19, 2022 22:33
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@tpdsantos@stephenll@wildart

[8]ページ先頭

©2009-2025 Movatter.jp