I have a piecewise constraint that I am having a hard time converting using big-M modelling. The context is a gym owner that is updating membership costs subject to churn restrictions. The owner can increase or decrease the prices which will have an effect on the churn probability of a customer, $n$. However, if the change in price is small enough, there is no churn. The function looks like:

$ch_n$ =

\begin{cases} 0, & |p^*_n - p_n|\leq \epsilon \\ m_n(p^*_n - p_n), & p^*_n - p_n > \epsilon \end{cases}

Where $ch_n$ is the churn probability of customer n. This is zero is the price increase is less than some threshold epsilon ($p^*_n$ is the new price and the decision variable. $p_n$ is the old price). If the change is greater than epsilon, the churn probability is a linear function of the price change (so $m_n$ is known for each customer).

The difficulty I am having the the presence of the absolute values in the constraint definition.

  • 1
    $\begingroup$ Welcome to OR SE. We need some clarifications on the question. First, you said $p_n$ is the decision variable, but deciding the old price doesn't really make sense (barring possession of a time machine). Should $p^*_n$ be the decision variable and $p_n$ data? Second, either $p^*_n \ge p_n$ (in which case the absolute values are unnecessary) or $p^*_n$ can be smaller than $p_n$ (in which case the churn probability is negative, which makes no sense). Can you clarify that? $\endgroup$
    – prubin
    Jan 12, 2023 at 19:29
  • $\begingroup$ Apologies, I mis-placed the comma. I meant that $p^{*}_{n}$ is the decision variable and $p_{n}$ is the old price. Your second point is also very valid and something I had overlooked. I will update the post to make this clearer. $\endgroup$
    – akkha
    Jan 12, 2023 at 21:21

1 Answer 1


While the clarification sought by Prof Paul is relevant here generally how abs is handled:
Define $z \in R^n$
$p_n^* - p_n \le z_n $
$p_n - p_n* \le z_n $

$z_n-(ϵ+\sigma) \le Mx_n $
$ϵ - z_n \le M(1-x_n)$

$m_nz_n + M(x_n-1) \le ch_n \le m_nz_n + M(1-x_n) $
$0 \le ch_n \le x_n $ $\ \ \forall n $
In the above two constraints M can be replaced by 1.

$x \in \{0,1\}^n $
$\sigma$ is a small number say like 0.001 depending upon scale of $ϵ $

  • $\begingroup$ Many thanks for the reply. I think I am following the logic. One follow up question: would it be correct to think of $z_{n}$ as the upper bound of the increase in price? $\endgroup$
    – akkha
    Jan 12, 2023 at 21:42
  • $\begingroup$ For the $n$th customer, yes $\endgroup$ Jan 12, 2023 at 21:52
  • $\begingroup$ Thanks a lot Sutanu, I have gone over your answer a few times now and I think I understand how to deal with absolute values now. Much appreciated! $\endgroup$
    – akkha
    Jan 16, 2023 at 20:04

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.