Skip to content

pymoo/mutation-prob-per-individual

Rule mutation-prob-per-individual
Pack pymoo
Severity warning
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions pymoo 0.6 and later

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

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=.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

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.

Browse the other rules of the pymoo pack.