8000 Changed to "aggressive" magical steps, where the new step can · PythonOptimizers/NLP.py@d802118 · GitHub
[go: up one dir, main page]

Skip to content

Commit d802118

Browse files
Andrew Lambedpo
authored andcommitted
Changed to "aggressive" magical steps, where the new step can
influence the trust region size and step acceptance.
1 parent 8fe0ccc commit d802118

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

nlp/optimize/tron.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,16 @@ def solve(self):
451451
x_trial = project(self.x + s, model.Lvar, model.Uvar)
452452
f_trial = model.obj(x_trial)
453453

454+
# Incorporate a magical step to further improve the trial
455+
# (if possible) and modify the predicted reduction to
456+
# take the extra improvement into account
457+
if "magical_step" in dir(model):
458+
(x_trial, s_magic) = model.magical_step(x_trial)
459+
s += s_magic
460+
m -= f_trial
461+
f_trial = model.obj(x_trial)
462+
m += f_trial
463+
454464
# Evaluate the step and determine if the step is successful.
455465

456466
# Compute the actual reduction.
@@ -515,17 +525,6 @@ def solve(self):
515525
# Fall back on trust-region rule.
516526
step_status = "Rej"
517527

518-
# Incorporate the magical step knowledge here, if any
519-
# This is a "conservative" approach where the magical step
520-
# is not used to determine the trust region size.
521-
if "magical_step" in dir(model) and self.step_accepted:
522-
(self.x, s_magic) = model.magical_step(self.x)
523-
self.dvars += s_magic
524-
self.f = model.obj(self.x)
525-
self.g = model.grad(self.x)
526-
if self.save_g:
527-
self.dgrad = self.g - self.g_old
528-
529528
self.step_status = step_status
530529
status = ""
531530
try:

0 commit comments

Comments
 (0)
0