-1
$\begingroup$

How can I formulate in mixed linear programming (a set of constraints) the following issue. I have an objective function $\underset{x}{\max} g(x)$. I need to convert a continuous linear function $f(x)$ (with $x$ real) such that when $f(x) < 0$ it passes 0 to the objective function and when $f(x) \ge 0$ it passes $f(x)$.

I have the indicator constraints formulated as

\begin{equation} y \ge \frac{1}{M}f(x) \tag{1} \end{equation} \begin{equation} y \le 1 + \frac{1}{M}f(x) \tag{2} \end{equation}

with $M$ sufficiently big, but I am missing the link from $f(x$) to $g(x)$ such that when

\begin{equation} f(x) < 0 \quad \text{then} \quad g(x) = 0 \end{equation}

and

\begin{equation} f(x) \ge 0 \quad \text{then} \quad g(x) = f(x) \end{equation} with $g(x) \ge 0$.

Any guidance on this?

$\endgroup$
2

1 Answer 1

2
$\begingroup$

You want to maximize $\max(f(x),0)$. Assume $L \le f(x) \le U$ for constants $L$ and $U$. Maximize $g(x)$ subject to $$ 0 \le g(x) \le U y \\ 0 \le g(x) - f(x) \le (0-L)(1-y) \\ y \in \{0,1\} $$

$\endgroup$
4
  • $\begingroup$ what about if L=0 and U=+inf? $\endgroup$
    – Di Al
    Commented Nov 30, 2023 at 16:01
  • $\begingroup$ $L=0$ is fine, but $U$ needs to be finite. Also, $L=0$ means that $f(x) \ge 0$, so $\max(f(x),0)=f(x)$. $\endgroup$
    – RobPratt
    Commented Nov 30, 2023 at 16:05
  • $\begingroup$ Not sure what you mean. Just think of $g$ as a variable. The formulation I proposed enforces $g=\max(f(x),0)$. $\endgroup$
    – RobPratt
    Commented Nov 30, 2023 at 16:32
  • $\begingroup$ many thanks. I think I got it. It's precisely what I need. making L safelly small and U safelly big generalizes the case. $\endgroup$
    – Di Al
    Commented Nov 30, 2023 at 17:09

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.