pymoo/n-constr-keyword
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| pymoo | info | safe, with xpd check --fix |
pymoo 0.6+ |
Since pymoo 0.6.0, Problem has no n_constr parameter and reads it as the number of inequality constraints. Write n_ieq_constr or n_eq_constr.
class Welded(Problem): def __init__(self): super().__init__(n_var=4, n_obj=2, n_constr=4, xl=xl, xu=xu) super().__init__(n_var=4, n_obj=2, n_ieq_constr=4, xl=xl, xu=xu)What the rule reports
Section titled “What the rule reports”The rule reports n_constr= given to super().__init__ in a problem class, or to Problem and ElementwiseProblem called by name. Problem has no such parameter since pymoo 0.6.0 and reads it from **kwargs as n_ieq_constr. A problem built with either keyword had the same n_ieq_constr, and GA with seed=1 returned the same X, F and G for both, bit for bit. A call that passes both keywords is left alone.
How to fix it
Section titled “How to fix it”xpd check --fix applies the fix of this rule.
The safe fix writes n_ieq_constr=.
Diagnostic message
Section titled “Diagnostic message”n_constr is no longer a parameter of Problem since pymoo 0.6.0, which reads it from **kwargs as n_ieq_constr. Write n_ieq_constr for the constraints in out["G"], and n_eq_constr for those in out["H"].See all rules in the pymoo pack.