All problems
Trust Region Radius Contraction
Problem
Standard trust-region radius rules: shrink to 0.25 * radius when the gain ratio is below 0.25, double the radius when the ratio exceeds 0.75 and the step is on the boundary, and keep it otherwise.
Given the current radius, the gain ratio rho, and a boolean for boundary contact, return the new radius.
Hint
Order the checks so poor agreement dominates.
Test cases
case 1
in: [1,0.1,true]
expected: 0.25
case 2
in: [1,0.9,true]
expected: 2
case 3
in: [2,0.9,false]
expected: 2
Starter codePython
def trust_region_radius_contraction(radius, rho, at_boundary):
# Your code here
pass3 test cases · run your code against them in the editor