Skip to content
DeepForgeby svx
All problems

Constrained Policy Update

Problem

Apply a Lagrangian penalty to advantages: A_pen[a] = advantages[a] - lambda * cost_advantages[a]. Return the penalized advantage list.

Hint

The multiplier trades reward against constraint violation.

Test cases

case 1
in: [[1,2],[0.5,1],1]
expected: [0.5,1]
case 2
in: [[0],[2],0.5]
expected: [-1]
case 3
in: [[],[],1]
expected: []
Starter codePython
def constrained_advantage_update(advantages, cost_advantages, lambda_):
    # Your code here
    pass

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