pymoo/has-terminated-assignment
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| pymoo | error | none, edit by hand | pymoo 0.6+ |
Since pymoo 0.6.0, has_terminated is not read, so setting it does not restart a loaded algorithm that had finished. Give the algorithm a new termination instead.
(checkpoint,) = np.load("checkpoint.npy", allow_pickle=True).flatten()checkpoint.has_terminated = Falseres = minimize(problem, checkpoint, ("n_gen", 20), seed=1, copy_algorithm=False)checkpoint.termination = MaximumGenerationTermination(20)res = minimize(problem, checkpoint, copy_algorithm=False)What the rule reports
Section titled “What the rule reports”The rule reports has_terminated = False on a name that the file assigns from np.load, pickle.load or dill.load, also as one name of a tuple. Another object with an attribute of the same name is left alone. The checkpoint recipe of pymoo 0.4 and 0.5 set the attribute to let a loaded algorithm run on, and since 0.6.0 pymoo no longer reads it. An NSGA2 that had finished its 5 generations ran 0 more generations after has_terminated = False, and 15 more after it got a new termination.
How to fix it
Section titled “How to fix it”xpd has no automatic fix, so make the change by hand.
Diagnostic message
Section titled “Diagnostic message”has_terminated is not read since pymoo 0.6.0, so a loaded algorithm that had finished stays finished. It ran 0 more generations after this line, and 15 more after it got a new termination. Write $A.termination = MaximumGenerationTermination(n), with the class from pymoo.termination.max_gen and n the total number of generations.See all rules in the pymoo pack.