All problems
Optimum Sensitivity
Problem
Minimize f(x, y) = 0.5*a*x^2 + 0.5*b*y^2 subject to the equality constraint x + y = s.
The KKT solution is x* = s*b/(a + b) and y* = s*a/(a + b). Return the sensitivities [dx*/ds, dy*/ds], which are b/(a+b) and a/(a+b). The parameter s cancels, and a + b > 0.
Hint
Solve the equality-constrained problem, then differentiate the optimizer with respect to s.
Test cases
case 1
in: [1,1,5]
expected: [0.5,0.5]
case 2
in: [2,1,3]
expected: [0.3333333333333333,0.6666666666666666]
case 3
in: [3,6,1]
expected: [0.6666666666666666,0.3333333333333333]
case 4
in: [1,4,2]
expected: [0.8,0.2]
Starter codePython
def optimum_sensitivity(a, b, s):
# Return [dx_ds, dy_ds]
# Your code here
pass4 test cases · run your code against them in the editor