Integer program formulation for conditional constraints

230 Views Asked by At

I have following question: some one want to buy fish and rice, fish should be bought in integer, weights 0.1kg each, rice can be bought in any number. we want to minimize the cost, there is constraint "If the weight of fish and rice exceeds 20kg, there is $10 charge." How can I add this constraint in this integer program question? I am very confused

1

There are 1 best solutions below

0
On BEST ANSWER

Let $r \in \mathbb{R}^+$ represent the amount (in $kg$) of rice and $f\in \mathbb{N}$ the amount of fish to buy. Let $c_f$ and $c_r$ denote the cost per $kg$. You want to minimize the cost given by $$ c_f f +c_r r +10 y $$ where $y$ is a binary variable that equals $1$ if the total weight exceeds $20$, which you can write as follows: $$ r+f \le 20+My\\ y\in \{0,1\} $$ $M$ is a large constant. If $r+f \le 20$, the equation is satisfied with $y=0$ and no penalty is charged. If not, you have to activate $y$.