Skip to content

pymoo/unseeded-run

Pack Severity Fix Versions
pymoo info unsafe, with xpd check --fix --unsafe-fixes All versions

minimize without seed starts from a new random state on every run, so two runs return different fronts. Pass seed.

res = minimize(problem, NSGA2(pop_size=100), ("n_gen", 200))
res = minimize(problem, NSGA2(pop_size=100), ("n_gen", 200), seed=1)

The rule reports minimize without seed. Two runs of NSGA2 on ZDT1 then returned different fronts, and two runs with seed=1 returned the same front. The rule leaves alone a call that takes **kwargs, a call whose algorithm was built with seed, and a file that calls np.random.seed, which numpy-seed-ignored reports.

With --unsafe-fixes, xpd adds seed=1.

minimize without seed starts from a new random state on every run, and two runs returned different fronts. Pass seed, such as seed=1, to get the same result again.

See all rules in the pymoo pack.