# Linearize sum of continuous and boolean variable

For maximizing the objective function $$\sum_i{d_i y_i}+ A x - B \cdot \mathbb{I}_{x>0}$$, how can I linearize $$A x - B \cdot \mathbb{I}_{x>0}$$ term where $$d_i, A$$ and $$B$$ are positive constants and $$x, y_i$$ are continuous non-negative variables? Can you explain the logic of linearization? There are many other constraints involving $$y_i, x$$.

• Minimize or maximize? Sep 8, 2020 at 22:43
• @RobPratt Maximize Sep 8, 2020 at 22:53

If $$M$$ is a (small) upper bound on $$x$$, introduce a binary variable $$z$$ and big-M constraint $$x \le M z$$. The idea is that $$x>0$$ implies $$z=1$$. Now use $$B z$$ in the objective.