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

GA probability of selecting parents incorrect #63

Open
stefanwintersteller opened this issue Jun 20, 2022 · 0 comments
Open

GA probability of selecting parents incorrect #63

stefanwintersteller opened this issue Jun 20, 2022 · 0 comments

Comments

@stefanwintersteller
Copy link

Hi,

the probability of selecting parents is calculated by (https://github.com/gkhayes/mlrose/blob/master/mlrose/opt_probs.py eval_mate_probs function):

self.mate_probs = pop_fitness/np.sum(pop_fitness)

This results in high probabilities for bad individuals and low probabilities for good individuals for minimization problems.
Example: Population with 2 individuals, individual_1 fitness -1 and individual_2 fitness -2. The probability of selecting individual_1 (the good one) is 1/3 and probability of selecting individual_2 (the bad one) is 2/3. It is more likely to select individuals with poor fitness.

A quick fix could be the use of the reciprocal value for minimization problems:

if self.maximize == 1:
self.mate_probs = pop_fitness / np.sum(pop_fitness)
else:
self.mate_probs = 1/pop_fitness / np.sum(1/pop_fitness)

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

No branches or pull requests

1 participant