@@ -442,7 +442,8 @@ def get_new_direction_for_growing(self, step_length):
442442 return dirn * (step_length / LA .norm (dirn ))
443443
444444 def evaluate_criticality_measure (self , params ):
445- # TODO: add comment for calculation of criticality measure, need h != None
445+ # Calculate criticality measure for regularized problems (h is not None)
446+
446447 # Build model for full least squares function
447448 gopt , H = self .model .build_full_model ()
448449
@@ -452,19 +453,15 @@ def evaluate_criticality_measure(self, params):
452453 # gnew = gopt.copy()
453454 # crvmin = -1
454455 return np .inf
455- ##print("gopt", gopt)
456- ##print("H", H)
456+
457457 # NOTE: smaller params here to get more iterations in S-FISTA
458458 func_tol = params ("func_tol.criticality_measure" ) * self .delta
459- ##print("function tolerance (criticality measure)", func_tol)
460459 if self .model .projections :
461460 d , gnew , crvmin = ctrsbox_sfista (self .model .xopt (abs_coordinates = True ), gopt , np .zeros (H .shape ), self .model .projections , 1 ,
462461 self .h , self .lh , self .prox_uh , argsh = self .argsh , argsprox = self .argsprox , func_tol = func_tol ,
463462 max_iters = params ("func_tol.max_iters" ), d_max_iters = params ("dykstra.max_iters" ), d_tol = params ("dykstra.d_tol" ),
464463 scaling_changes = self .scaling_changes )
465464 else :
466- # NOTE: alternative way if using trsbox
467- # d, gnew, crvmin = trsbox(self.model.xopt(), gopt, H, self.model.sl, self.model.su, self.delta)
468465 proj = lambda x : pbox (x , self .model .sl , self .model .su )
469466 d , gnew , crvmin = ctrsbox_sfista (self .model .xopt (abs_coordinates = True ), gopt , np .zeros (H .shape ), [proj ], 1 ,
470467 self .h , self .lh , self .prox_uh , argsh = self .argsh , argsprox = self .argsprox , func_tol = func_tol ,
@@ -473,8 +470,6 @@ def evaluate_criticality_measure(self, params):
473470
474471 # Calculate criticality measure
475472 criticality_measure = self .h (remove_scaling (self .model .xopt (abs_coordinates = True ), self .scaling_changes ), * self .argsh ) - model_value (gopt , np .zeros (H .shape ), d , self .model .xopt (abs_coordinates = True ), self .h , self .argsh , self .scaling_changes )
476- ##print("d (criticality measure): ", d)
477- ##print("model value (criticality measure): ", model_value(gopt, 2*H, d, self.model.xopt(abs_coordinates=True), self.h, self.argsh))
478473 return criticality_measure
479474
480475 def trust_region_step (self , params , criticality_measure = 1e-2 ):
@@ -484,7 +479,6 @@ def trust_region_step(self, params, criticality_measure=1e-2):
484479 # QUESTION: c1 = min{1, 1/delta_max^2}, but choose c1=1here; choose maxhessian = max(||H||_2,1)
485480 # QUESTION: when criticality_measure = 0? choose max(criticality_measure,1)
486481 func_tol = (1 - params ("func_tol.tr_step" )) * 1 * max (criticality_measure ,1 ) * min (self .delta , max (criticality_measure ,1 ) / max (np .linalg .norm (H , 2 ),1 ))
487- ##print("function tolerance (trust region step)", func_tol)
488482
489483 if self .h is None :
490484 if self .model .projections :
@@ -520,14 +514,12 @@ def trust_region_step(self, params, criticality_measure=1e-2):
520514 self .h , self .lh , self .prox_uh , argsh = self .argsh , argsprox = self .argsprox , func_tol = func_tol ,
521515 max_iters = params ("func_tol.max_iters" ), d_max_iters = params ("dykstra.max_iters" ), d_tol = params ("dykstra.d_tol" ),
522516 scaling_changes = self .scaling_changes )
517+
523518 # NOTE: check sufficient decrease. If increase in the model, set zero step
524519 pred_reduction = self .h (remove_scaling (self .model .xopt (abs_coordinates = True ), self .scaling_changes ), * self .argsh ) - model_value (gopt , H , d , self .model .xopt (abs_coordinates = True ), self .h , self .argsh , self .scaling_changes )
525- ##("pred_reduction", pred_reduction)
526520 if pred_reduction < 0.0 :
527- ##print("bad d", d)
528521 d = np .zeros (d .shape )
529- ##print("d (trust region step): ", d)
530- ##print("new point (after trust region step): ", d + self.model.xopt(abs_coordinates=True))
522+
531523 return d , gopt , H , gnew , crvmin
532524
533525 def geometry_step (self , knew , adelt , number_of_samples , params ):
@@ -727,9 +719,7 @@ def calculate_ratio(self, x, current_iter, rvec_list, d, gopt, H):
727719 if len (self .model .projections ) > 1 : # if we are using multiple projections, only warn since likely due to constraint intersection
728720 exit_info = ExitInformation (EXIT_TR_INCREASE_WARNING , "Either multiple constraints are active or trust region step gave model increase" )
729721 else :
730- exit_info = ExitInformation (EXIT_TR_INCREASE_ERROR , "Either rust region step gave model increase" )
731- ##print("actual reduction: ", actual_reduction)
732- ##print("pred reduction: ", pred_reduction)
722+ exit_info = ExitInformation (EXIT_TR_INCREASE_ERROR , "Trust region step gave model increase" )
733723 ratio = actual_reduction / pred_reduction
734724 return ratio , exit_info
735725
0 commit comments