suppose that decision variable is X with N dimensions, and one type of the constraint is y = y0-sum(max(0,x)*b)-sum(min(0,x)*a), where the dimension of x is from 1 to N which means that there are N constraints, and the y should be less than y_min and be greater than y_max, i.e. y_min <= y0-sum(max(0,x)*b)-sum(min(0,x)*a) <= y_max.

In cvxpy, it could be write as y0 - cp.sum(cp.pos(x[:i])*b) + cp.sum(cp.neg(x[:i])*a),

however, -cp.sum(cp.pos(x[:i])*b) is a concave expression, cp.sum(cp.neg(x[:i])*a) is a convex expression, and the sum of them would not satisfy the DCP rule.

Is it possible to rewrite this type of constraint to follow the DCP rule?

(although we could use dccp to solve it.)

  • 2
    $\begingroup$ Not sure if this is helpful, but your concave expression can be made linear using extra binary variables. $\endgroup$ Commented Mar 1, 2023 at 15:11
  • $\begingroup$ @ErwinKalvelagen, could you give me some examples? Thanks $\endgroup$ Commented Mar 1, 2023 at 15:17
  • 3
    $\begingroup$ $$\begin{aligned} &y^+ - y^- = y \\ & y^+ \le M\delta\\& y^- \le M(1-\delta)\\&y^+,y^- \ge 0 \\ & \delta\in \{0,1\}\end{aligned}$$ This formulation should really be in your toolbox as it is not uncommon. $\endgroup$ Commented Mar 1, 2023 at 15:21
  • $\begingroup$ ok, I understand, I will try, Thanks @ErwinKalvelagen $\endgroup$ Commented Mar 1, 2023 at 15:30


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.