Skip to content

pymoo/mutation-prob-per-individual

Pack Severity Fix Versions
pymoo warning unsafe, with xpd check --fix --unsafe-fixes pymoo 0.6+

Since pymoo 0.6.0, prob is the share of individuals that mutate, and prob_var is the chance for each variable, so an old prob=1/n mutates far less. Write prob_var= when you mean the chance per variable.

mutation = PM(prob=1 / problem.n_var, eta=20)
mutation = PM(prob_var=1 / problem.n_var, eta=20)

The rule reports prob= on PM, PolynomialMutation, BitflipMutation, BFM, GaussianMutation and GM when the value is 1 divided by something, or a number of at most 0.2, and the call has no prob_var. Up to pymoo 0.5.0 prob was the chance that one variable changes. Since 0.6.0 it is the share of individuals that mutate, and prob_var is the chance per variable.

20,000 individuals of 30 variables pymoo 0.5.0 pymoo 0.6.2
individuals changed by prob=1/30 63 percent 2 percent
individuals changed by prob_var=1/30 not run 57 percent

The default for prob_var is min(0.5, 1 / n_var). The rule is a warning because a low mutation probability per individual can be intentional.

xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.

The unsafe fix writes prob_var=.

prob is the share of individuals that mutate since pymoo 0.6.0, and prob_var is the chance per variable. With prob=1/30 on 30 variables 2 percent of the individuals changed, where prob_var=1/30 changed 57 percent, as prob=1/30 did on pymoo 0.5.0. Write prob_var=$V if $V is the chance per variable.

See all rules in the pymoo pack.