All problems
Wolfe Condition Check
Problem
Check the strong Wolfe conditions for a step of size step along -gradient.
The Armijo part requires f_new <= f_current - c1 * step * g_current ** 2, and the curvature part requires abs(g_new) <= c2 * abs(g_current). Return True only when both inequalities hold.
Hint
Both the decrease and the curvature inequality must hold.
Test cases
case 1
in: [1,0.5,1,0.2,1,0.1,0.9]
expected: true
case 2
in: [1,0.85,1,0.2,1,0.1,0.9]
expected: true
case 3
in: [1,0.5,2,2.5,1,0.1,0.9]
expected: false
case 4
in: [2,1,-3,-1,0.5,0.2,0.5]
expected: true
Starter codePython
def wolfe_condition(f_current, f_new, g_current, g_new, step, c1, c2):
# Your code here
pass4 test cases · run your code against them in the editor