Skip to content

Commit 482ee73

Browse files
committed
Simplify passing G, CV if n_nonlincon==0
1 parent 018a2aa commit 482ee73

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

CADETProcess/optimization/individual.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,9 @@ def __init__(
8080
self.g = g
8181
self.m = m
8282

83-
if cv is None:
83+
if g is not None and cv is None:
8484
cv = g
8585
self.cv = cv
86-
87-
if cv_tol is None:
88-
cv_tol = self.n_g*[0]
8986
self.cv_tol = cv_tol
9087

9188
if x_untransformed is None:

CADETProcess/optimization/optimizer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ def run_post_generation_processing(
441441
else:
442442
M = len(X)*[None]
443443

444+
if self.optimization_problem.n_nonlinear_constraints == 0:
445+
G = len(X)*[None]
446+
CV = len(X)*[None]
447+
444448
population = Population()
445449
for x, f, g, cv, m in zip(X, F, G, CV, M):
446450
x_untransformed \

CADETProcess/optimization/pymooAdapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ def run(self, optimization_problem, x0=None):
148148
G = pop.get("_G").tolist()
149149
CV = pop.get("_CV").tolist()
150150
else:
151-
G = len(X)*[None]
152-
CV = len(X)*[None]
151+
G = None
152+
CV = None
153153

154154
# Handle issue of pymoo not handling np.inf
155155
pop.set("F", np.nan_to_num(F, posinf=1e300))

0 commit comments

Comments
 (0)