Skip to content
DeepForgeby svx
All problems
HardOptimizationop-293

KKT Point For One Sided Bound

Problem

Minimize (x - a)^2 subject to x <= c. When a <= c the unconstrained point is feasible with multiplier 0; otherwise the boundary x = c is active with multiplier 2 (c - a).

Given a and c, return [x, lambda].

Hint

Stationarity gives 2(x - a) + lambda = 0 with lambda >= 0 for x = c active.

Test cases

case 1
in: [0,2]
expected: [0,0]
case 2
in: [5,1]
expected: [1,-8]
case 3
in: [3,3]
expected: [3,0]
Starter codePython
def kkt_point_one_sided_bound(a, c):
    # Your code here
    pass

3 test cases · run your code against them in the editor