All problems
Robust Counterpart Check
Problem
Check whether x satisfies the robust counterpart of a box-uncertain constraint.
With coefficients a_i uncertain in [a_i - d_i, a_i + d_i], the worst case uses a_i + d_i for positive x_i and a_i - d_i for negative x_i. Return True when the worst-case left-hand side is at most b + tol.
Hint
The sign of x decides which uncertainty endpoint is worst.
Test cases
case 1
in: [[1,1],[0.1,0.1],[1,1],2.1,1e-9]
expected: false
case 2
in: [[1,1],[0.1,0.1],[1,1],2,1e-9]
expected: false
case 3
in: [[1,-2],[0.5,0.5],[2,3],-1,1e-9]
expected: true
Starter codePython
def robust_counterpart_check(a, d, x, b, tol):
# Your code here
pass3 test cases · run your code against them in the editor