#NEWLINE# def update_tr_radius( Delta , actual_reduction , predicted_reduction , step_norm , bound_hit ) : #NEWLINE# #INDENT# 'Update the radius of a trust region based on the cost reduction.\n\n    Returns\n    -------\n    Delta : float\n        New radius.\n    ratio : float\n        Ratio between actual and predicted reductions. Zero if predicted\n        reduction is zero.\n    ' #NEWLINE# if ( predicted_reduction > 0 ) : #NEWLINE# #INDENT# ratio = ( actual_reduction / predicted_reduction ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ratio = 0 #NEWLINE# #UNINDENT# if ( ratio < 0.25 ) : #NEWLINE# #INDENT# Delta = ( 0.25 * step_norm ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( ratio > 0.75 ) and bound_hit ) : #NEWLINE# #INDENT# Delta *= 2.0 #NEWLINE# #UNINDENT# #UNINDENT# return ( bound_hit , ratio )