Skip to content

Commit

Permalink
Avoid using deprecated "feasible" property (anyoptimization#631)
Browse files Browse the repository at this point in the history
The "feasible" property of pymoo.core.individual.Individual got
deprecated in commit ad3ef60 but was
still used internally, thus producing deprecation warnings in user code.
Use the FEAS property instead.
  • Loading branch information
dlax authored Aug 1, 2024
1 parent c3e7d76 commit 9d851f4
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pymoo/core/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pymoo/core/replacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion pymoo/core/survival.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pymoo/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pymoo/util/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9d851f4

Please sign in to comment.