@@ -451,6 +451,16 @@ def solve(self):
451
451
x_trial = project (self .x + s , model .Lvar , model .Uvar )
452
452
f_trial = model .obj (x_trial )
453
453
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
+
454
464
# Evaluate the step and determine if the step is successful.
455
465
456
466
# Compute the actual reduction.
@@ -515,17 +525,6 @@ def solve(self):
515
525
# Fall back on trust-region rule.
516
526
step_status = "Rej"
517
527
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
-
529
528
self .step_status = step_status
530
529
status = ""
531
530
try :
0 commit comments