I'm trying to linearize the problem:
$\max f(x)\\\text{s.t.}\\g(x)\geq 0$
Where $g(x)$ are already linear functions, but $f(x)$ is the following piecewise function:
$f(x)=\begin{cases} bx, & \text{if } x < c \\[2ex] 0, & \text{if } x = c \\[2ex] -ax, & \text{if } x>c \end{cases}$
With $a,b,c>0$ constants.
This seems very easy, but I'm having a hard time to find a solution. So, I would be very thankful for any help!
You can introduce three binary variables, one for each piece, a constraint that they sum to 1, and additional linear constraints that link the binary variables to $f(x)$, but it is simpler to just solve three separate problems and take the max.
If $x\in[L,U]$ and $\epsilon>0$ is a tolerance, impose linear constraints \begin{align} z_1+z_2+z_3&=1\\ L z_1+c z_2+(c+\epsilon)z_3 \le x &\le (c-\epsilon)z_1+c z_2+U z_3\\ -M(1-z_1)\le f-b x &\le M(1-z_1)\\ -M(1-z_2)\le f&\le M(1-z_2)\\ -M(1-z_3)\le f+a x&\le M(1-z_3) \end{align}