Skip to content
DeepForgeby svx
All problems
HardOptimizationop-350

Elastic Net Composite Proximal Step

Problem

The proximal operator of t * (lambda1 ||x||_1 + (lambda2 / 2) ||x||^2) applies soft thresholding with t * lambda1 to v, then divides by (1 + t * lambda2).

Given v, t, lambda1, and lambda2, return the prox value.

Hint

Compose the L1 prox with the scaling induced by the quadratic term.

Test cases

case 1
in: [2,0.5,1,2]
expected: 0.75
case 2
in: [0.1,1,0.5,0]
expected: 0
case 3
in: [-3,0.25,0.5,1]
expected: -2.3
Starter codePython
def elastic_net_proximal_step(v, t, lambda1, lambda2):
    # Your code here
    pass

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