0
$\begingroup$

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

$\endgroup$
4
$\begingroup$

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$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.