Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-199

Integer Relaxation Gap

Problem

Measure the gap between an integer program and its LP relaxation.

For a minimization problem, return lp_value - integer_value, which is non-negative and bounds the integrality gap.

Hint

The relaxation can only be at least as good as the integer optimum.

Test cases

case 1
in: [10.5,10]
expected: 0.5
case 2
in: [7,7]
expected: 0
case 3
in: [3.25,2]
expected: 1.25
case 4
in: [0,0]
expected: 0
Starter codePython
def integer_relaxation_gap(lp_value, integer_value):
    # Your code here
    pass

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