All problems
Armijo Condition Check
Problem
Check the Armijo sufficient-decrease condition for a step of size step along the descent direction -grad. Return True when f_new <= f_current - c * step * grad ** 2, and False otherwise. Here grad is the current gradient component along that direction.
Hint
Armijo compares the new value against the tangent line with slope -grad squared.
Test cases
case 1
in: [1,0.5,1,1,0.1]
expected: true
case 2
in: [1,0.85,1,1,0.1]
expected: true
case 3
in: [4,3,2,0.5,0.25]
expected: true
case 4
in: [0,0.001,0,1,0.1]
expected: false
Starter codePython
def armijo_condition(f_current, f_new, grad, step, c):
# Your code here
pass4 test cases · run your code against them in the editor