If condition in Objective function.

888 Views Asked by At

I am new to optimization problems. I'm solving an integer programming problem, but I have a problem with the objective function. The question states that if the Quantity allocated in a store (Q) is greater than the required quantity (RQ), the penalty is P1 and if the Quantity allocated is less than RQ, the penalty is P2. How can I frame the objective function for this since it involves conditional logic?

1

There are 1 best solutions below

0
On

Introduce binary variables $x_1$ and $x_2$, and impose linear big-M constraints \begin{align} Q - RQ &\le M_1 x_1 \tag1 \\ RQ - Q &\le M_2 x_2 \tag2 \\ \end{align} Here, $M_1$ is a small constant upper bound on $Q-RQ$, and $M_2$ is a small constant upper bound on $RQ-Q$. Constraint $(1)$ enforces $Q>RQ \implies x_1=1$. Constraint $(2)$ enforces $Q<RQ \implies x_2=1$. Now minimize $P_1 x_1 +P_2 x_2$.