# Linear programming with if-then-else (big-M)

I am trying to formulate the following in linear programming. $$\begin{cases}\text{if}\,\,a>b\,\,\text{then}\,\,c=a\\\text{else}\,\,c=b.\end{cases}$$

I tried some things with big $$M$$, like $$a + my > b+m(1-y),$$ so that $$y$$ (binary) can be used to pick either $$a$$ or $$b$$ or $$c$$.

I know this does not work, because $$y$$ will always be $$1$$ in this example. But even with the help of other examples I cannot seem to figure it out. Any tips?

• A nice topic on big $M$ formulation could be found here. – A.Omidi Nov 12 '19 at 5:37

Equivalently, $$c=\max(a,b)$$. See this post.