1
$\begingroup$

I was hoping to get some help in modelling the following logic. I tried to solve it by "Big-M method" but failed. Thank you in advance!

$a(k,n)$ and $b(k,n)$ are known constants, $\lambda$ and $\mu_k$ are variables used for optimization, and such logic is used at a gp model.

My original logic is as follows: if $a_{k,n}-b_{k,n}\ge\dfrac{\lambda}{\mu_k}$

(To ensure that the following expression has a real number solution)

$$p_{k,n} = \frac{1}{2}\left[\sqrt{\left(\frac1{a_{k,n}}-\frac1{b_{k,n}}\right)^2+\frac{4\mu_k}{\lambda}\left(\frac1{b_{k,n}}-\frac1{a_{k,n}}\right)}-\left(\frac1{a_{k,n}}+\frac1{b_{k,n}}\right)\right]$$

else $p_{k,n} = 0$.


I first tried to avoid the condition $a_{k,n}-b_{k,n} \ge \frac{\lambda}{\mu_k}$ by changing to the following constraints:

\begin{align}\text{tmp1} &= \left[\left(\frac1{a_{k,n}}-\frac1{b_{k,n}}\right)^2+\frac{4\mu_k}{\lambda}\left(\frac1{b_{k,n}}-\frac1{a_{k,n}}\right)\right]^+\\\text{tmp2}&=\sqrt{\text{tmp1}}-\left(\frac1{a_{k,n}}+\frac1{b_{k,n}}\right)\\p_{k,n}&=\frac{1}{2}[\text{tmp2}]^+\end{align}

where $[x]^+=\max\{0,x\}$, but got the following error

Disciplined convex programming error:
    Cannot perform the operation max({constant},{concave})

due to \begin{align}\text{tmp1} &= \left[\left(\frac1{a_{k,n}}-\frac1{b_{k,n}}\right)^2+\frac{4\mu_k}{\lambda}\left(\frac1{b_{k,n}}-\frac1{a_{k,n}}\right)\right]^+\\&=\max\left\{0,\left(\frac1{a_{k,n}}-\frac1{b_{k,n}}\right)^2+\frac{4\mu_k}{\lambda}\left(\frac1{b_{k,n}}-\frac1{a_{k,n}}\right)\right\}\end{align}

Now I feel that the if-then-else constraint may be converted in a big-M way, but I don't know how to express it; but maybe this intuition is wrong.

$\endgroup$
2
  • 1
    $\begingroup$ What about using an indicator variable? Saying that p_k,n = (1-x)*that_whole_expression, where x is binary and then using the big-M a_k,n - b_k,n + M*x >= lambda/miu $\endgroup$ Commented Dec 20, 2022 at 16:40
  • $\begingroup$ Thank you very much for your help, but since my model is geometric programming, binary variables cannot be used. If I didn't declare that this is a geometric programming in CVX, I would not be able to implement $\frac{\lambda}{\mu_k}$ such variable division operations. $\endgroup$
    – WaMIMO
    Commented Dec 21, 2022 at 2:16

1 Answer 1

2
$\begingroup$

As @J.Dionisio suggested, you can:
$a_{k,n}-b_{k,n} - {\lambda \over \mu_{k}} \le Mx_k$ where
$x_k \in\ \{0,1\}$ and $M$ is upper bound of any value possible in the model (constants or vars)
Also since dividing will be problem replace
$y_k \cdot \mu_k = 1$ and
$\lambda \cdot z = 1$

So first constraint turns like
$(a_{k,n}-b_{k,n}) - y_k \lambda \le Mx_k$
$y_k \lambda - (a_{k,n}-b_{k,n}) \le M(1-x_k)$

$2p_{n,k} = x_k \cdot tmp1$
In tmp1, replace $\lambda$ with $z$

$\endgroup$
2
  • $\begingroup$ Thank you very much for your help, but since my model is geometric programming, binary variables cannot be used. If I didn't declare that this is a geometric programming in CVX, I would not be able to implement $\frac{\lambda}{\mu_k}$ Such variable division operations $\endgroup$
    – WaMIMO
    Commented Dec 21, 2022 at 2:15
  • $\begingroup$ Not an expert on cvxpy but you may check the answer here math.stackexchange.com/questions/3303985/… $\endgroup$ Commented Dec 21, 2022 at 3:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.