Skip to content
DeepForgeby svx
All problems
MediumOptimizationop-361

Barrier Duality Gap Value

Problem

For a logarithmic barrier with m constraints and parameter t, the duality gap is m / t.

Given the number of constraints and t > 0, return the gap.

Hint

The gap shrinks as the barrier parameter grows.

Test cases

case 1
in: [3,1]
expected: 3
case 2
in: [5,10]
expected: 0.5
case 3
in: [1,0.5]
expected: 2
Starter codePython
def barrier_duality_gap_value(constraints, t):
    # Your code here
    pass

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