From 9d851f46ea98a209f11044b6bafab2dec17ab53b Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Thu, 1 Aug 2024 06:55:21 +0200 Subject: [PATCH] Avoid using deprecated "feasible" property (#631) The "feasible" property of pymoo.core.individual.Individual got deprecated in commit ad3ef6076a6bc7eed7c858c5776afadfb76fb5dd but was still used internally, thus producing deprecation warnings in user code. Use the FEAS property instead. --- pymoo/core/algorithm.py | 2 +- pymoo/core/replacement.py | 4 ++-- pymoo/core/survival.py | 2 +- pymoo/util/misc.py | 2 +- pymoo/util/normalization.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pymoo/core/algorithm.py b/pymoo/core/algorithm.py index 09335e9b1..54e7694f4 100644 --- a/pymoo/core/algorithm.py +++ b/pymoo/core/algorithm.py @@ -261,7 +261,7 @@ def result(self): opt = None # if no feasible solution has been found - elif not np.any(opt.get("feasible")): + elif not np.any(opt.get("FEAS")): if self.return_least_infeasible: opt = filter_optimum(opt, least_infeasible=True) else: diff --git a/pymoo/core/replacement.py b/pymoo/core/replacement.py index 10a569e69..933a3f2e6 100644 --- a/pymoo/core/replacement.py +++ b/pymoo/core/replacement.py @@ -59,8 +59,8 @@ def _do(self, problem, pop, off, **kwargs): ret = np.full((len(pop), 1), False) - pop_F, pop_CV, pop_feas = pop.get("F", "CV", "feasible") - off_F, off_CV, off_feas = off.get("F", "CV", "feasible") + pop_F, pop_CV, pop_feas = pop.get("F", "CV", "FEAS") + off_F, off_CV, off_feas = off.get("F", "CV", "FEAS") if problem.has_constraints() > 0: diff --git a/pymoo/core/survival.py b/pymoo/core/survival.py index ee95422aa..f078b97b9 100644 --- a/pymoo/core/survival.py +++ b/pymoo/core/survival.py @@ -86,7 +86,7 @@ def _do(self, problem, pop, off, **kwargs): def split_by_feasibility(pop, sort_infeas_by_cv=True, sort_feas_by_obj=False, return_pop=False): - F, CV, b = pop.get("F", "CV", "feasible") + F, CV, b = pop.get("F", "CV", "FEAS") feasible = np.where(b)[0] infeasible = np.where(~b)[0] diff --git a/pymoo/util/misc.py b/pymoo/util/misc.py index 392e718c2..480bd7378 100644 --- a/pymoo/util/misc.py +++ b/pymoo/util/misc.py @@ -360,7 +360,7 @@ def intersect(a, b): def has_feasible(pop): - return np.any(pop.get("feasible")) + return np.any(pop.get("FEAS")) def to_numpy(a): diff --git a/pymoo/util/normalization.py b/pymoo/util/normalization.py index ff5dc0b03..e0e60d188 100644 --- a/pymoo/util/normalization.py +++ b/pymoo/util/normalization.py @@ -305,7 +305,7 @@ def __init__(self) -> None: self._worst = None def update(self, pop): - F, feas = pop.get("F", "feasible") + F, feas = pop.get("F", "FEAS") self._infeas_ideal = find_ideal(F, current=self._infeas_ideal) if np.any(feas):