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

BUG in eval_mate_probs() #68

Open
ialxn opened this issue Mar 3, 2023 · 0 comments
Open

BUG in eval_mate_probs() #68

ialxn opened this issue Mar 3, 2023 · 0 comments

Comments

@ialxn
Copy link

ialxn commented Mar 3, 2023

The fitness values of a population might contain positive AND negative values in OptProb.eval_mate_probs(). Thus its sum might be positive, negative, or even accidentally zero. So we have to be more careful to avoid negative probabilities that arrive if the sum of the probabilities has a different sign than the probability of a member.

`

Set -1*inf values to 0 to avoid dividing by sum of infinity.

    # This forces mate_probs for these pop members to 0.
    pop_fitness[pop_fitness == -1.0*np.inf] = 0

    # Fitness of the population might contain positive AND negative values.
    # Thus its sum can be positive, negative or even accidentally zero.

    # All fitness values are zero
    if np.count_nonzero(pop_fitness) == 0:
        self.mate_probs = np.ones(len(pop_fitness)) \
                          / len(pop_fitness)
    else:
        # Make all values positive, the smallest will be offset by the sdev of the data
        pop_fitness += (pop_fitness.min() + pop_fitness.std())
        self.mate_probs = pop_fitness/np.sum(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