All problems
Log Barrier Objective Value
Problem
The logarithmic barrier for constraints g_i(x) < 0 is -sum_i log(-g_i(x)).
Given the constraint values, return the barrier value, or None when any constraint value is nonnegative.
Hint
The barrier is finite only strictly inside the feasible region.
Test cases
case 1
in: [[-1,-2]]
expected: -0.6931471805599453
case 2
in: [[-0.5]]
expected: 0.6931471805599453
case 3
in: [[-1,0,-2]]
expected: null
Starter codePython
def log_barrier_objective_value(constraints):
# Your code here
pass3 test cases · run your code against them in the editor