'No strict inequalities in cvxpy problem but still get the error "Strict inequalities are not allowed"

I was using the CVXPY library in Python, trying to solve a particular optimization problem.

import cvxpy as cp
import numpy as np
from scipy.stats import norm

(...)

a = cp.Variable([10, 1])

obj = cp.Maximize(sum(norm.logcdf(A @ a, scale=sigma)))
constraints = [a >= np.zeros([10, 1]), a <= np.ones([10, 1])]

prob = cp.Problem(objective=obj, constraints=constraints)

prob.solve()

Here A is a particular numpy Matrix, and sigma is a particular scalar. When I try to solve the question, the package gives me the below error.

Traceback (most recent call last):
  File "~\anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3326, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-23-c554382c1c69>", line 19, in <module>
    obj = cp.Maximize(sum(norm.logcdf(A @ a, scale=sigma)))
  File "~\anaconda3/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py", line 1848, in logcdf
    cond1 = self._open_support_mask(x, *args) & (scale > 0)
  File "~\anaconda3/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py", line 901, in _open_support_mask
    return (a < x) & (x < b)
  File "~\anaconda3/lib/python3.7/site-packages/cvxpy/expressions/expression.py", line 597, in __gt__
    raise NotImplementedError("Strict inequalities are not allowed.")
NotImplementedError: Strict inequalities are not allowed.

But the problem itself contains no strict inequality... Seems like the SCIPY package has conflict with CVXPY, but have no idea how to resolve...



Solution 1:[1]

There is a norm in cvxpy. So please change as below code:

from scipy.stats import stats
obj = cp.Maximize(sum(stats.logcdf(A @ a, scale=sigma)))

functions

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1