8000 Critical bug fixes for auglag · PythonOptimizers/NLP.py@4707ea7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4707ea7

Browse files
Andrew Lambedpo
authored andcommitted
Critical bug fixes for auglag
- corrected size error in SlackNLP for range constraints - fixed variable names in Auglag
1 parent 2f01764 commit 4707ea7

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

nlp/model/snlp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(self, model, **kwargs):
7676

7777
# Update effective number of variables and constraints
7878
n = self.original_n + n_slacks
79-
m = self.original_m + model.nrangeC
79+
m = self.original_m
8080

8181
Lvar = -np.infty * np.ones(n)
8282
Uvar = +np.infty * np.ones(n)

nlp/optimize/auglag.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -317,41 +317,41 @@ def solve(self, **kwargs):
317317

318318
dL = al_model.dual_feasibility(self.x)
319319
PdL = self.project_gradient(self.x, dL)
320-
Pmax_new = np.max(np.abs(PdL))
321-
convals_new = slack_model.cons(self.x)
320+
Pmax = np.max(np.abs(PdL))
321+
convals = slack_model.cons(self.x)
322322

323323
# Specific handling for the case where the original NLP is
324324
# unconstrained
325325
if slack_model.m == 0:
326-
max_cons_new = 0.
326+
max_cons = 0.
327327
else:
328-
max_cons_new = np.max(np.abs(convals_new))
328+
max_cons = np.max(np.abs(convals))
329329

330330
self.f = self.model.model.model.obj(self.x[:on])
331-
self.pgnorm = Pmax_new
331+
self.pgnorm = Pmax
332332

333333
# Print out header, say, every 20 iterations.
334334
if self.iter % 20 == 0:
335335
self.log.info(self.header)
336336

337337
self.log.info(self.format % (self.iter, self.f,
338-
self.pgnorm, max_cons_new,
338+
self.pgnorm, max_cons,
339339
al_model.penalty,
340340
bc_solver.iter, bc_solver.status,
341341
self.omega, self.eta))
342342

343343
# Update penalty parameter or multipliers based on result
344-
if max_cons_new <= np.maximum(self.eta, self.eta_opt):
344+
if max_cons <= np.maximum(self.eta, self.eta_opt):
345345

346346
# Update convergence check
347-
if max_cons_new <= self.eta_opt and Pmax_new <= self.omega_opt:
347+
if max_cons <= self.eta_opt and Pmax <= self.omega_opt:
348348
exitOptimal = True
349349
break
350350

351-
self.update_multipliers(convals_new, bc_solver.status)
351+
self.update_multipliers(convals, bc_solver.status)
352352

353353
# Update reference constraint norm on successful reduction
354-
cons_norm_ref = max_cons_new
354+
cons_norm_ref = max_cons
355355
infeas_iter = 0
356356

357357
# If optimality of the inner loop is not achieved within 10
@@ -368,10 +368,10 @@ def solve(self, **kwargs):
368368
self.update_penalty_parameter()
369369
self.log.debug("keeping current multipliers estimates")
370370

371-
if max_cons_new > 0.99 * cons_norm_ref and self.iter != 1:
371+
if max_cons > 0.99 * cons_norm_ref and self.iter != 1:
372372
infeas_iter += 1
373373
else:
374-
cons_norm_ref = max_cons_new
374+
cons_norm_ref = max_cons
375375
infeas_iter = 0
376376

377377
if infeas_iter == 10:
@@ -413,4 +413,4 @@ def solve(self, **kwargs):
413413
self.log.info("f = %12.8g" % self.f)
414414
if slack_model.m != 0:
415415
self.log.info("pi_max = %12.8g" % np.max(al_model.pi))
416-
self.log.info("max infeas. = %12.8g" % max_cons_new)
416+
self.log.info("max infeas. = %12.8g" % max_cons)

0 commit comments

Comments
 (0)
0