In a simple cost minimizing problem, how do I model the following constraint?

A dealer can supply up to 100 units at a cost of \$1240 per unit and a one time delivery fee of \$900. If however, 100 to 150 units are purchased, the dealer charges \$1210 per unit for the additional units beyond 100 with an additional delivery fee of \$700.

Now I know that binary variables need to be used, but not sure how.


2 Answers 2


We want a binary variable that will switch on when we buy over 100 units, thus allowing us to buy up to another 50 units at the reduced cost.

We'll have the variables:

$x$ - # of units bought at original price

$y$ - # of units bought at reduced price

$z$ - binary variable indicating we're buying more than 100 units

And now our constraints:

$0 \leq x \leq 100$

  • Can only purchase up to 100 units at original price

$0 \leq y \leq 50z$

  • Can only purchase up to 50 units at second price, provided we bought the first 100 units at the original price.

$100z \leq x$

  • The only way $z \rightarrow 1$ is when $x \rightarrow 100$, otherwise $z$ has to stay at $0$ for the constraint to hold.
  • Additionally, $z$ can still be $0$ when $x = 100$, allowing us to only purchase 100 units (if that were the optimal case).

This leaves us with the following objective:

$\min 900 + 1240x + 700z + 1210y$

$y$ is constrained by $z$, so unless $z \rightarrow 1$ $y$ will stay at $0$.

  • 1
    $\begingroup$ This seems to work! Thank you so much for helping $\endgroup$
    – user7537
    Dec 13, 2021 at 20:13

Since there is an additional "fixed" cost (delivery fee), you will need a binary variable indicating whether your order went into the upper range. You'll also want two order variables, number of units bought at \$1240 each and number bought at \$1210 each. Finally, you will need constraints that make the binary variable 1 when any units are bought at the lower price and force the number bought at full price to be 100 if the binary is set to 1.

  • $\begingroup$ Thanks for the reply. So the optimization would be: minimize 1240*x1 + 900*y1 + 1210*x2 + 700*y2. But the constraints have me stumped. $\endgroup$
    – user7537
    Dec 13, 2021 at 17:02
  • $\begingroup$ @Simba63: are you looking for a constraint/set of contraints for the above mentioned conditions? or a whole model including the objective function? $\endgroup$
    – Betty
    Dec 13, 2021 at 17:59
  • $\begingroup$ It's just the set of constraints. All the rest I can figure out myself. $\endgroup$
    – user7537
    Dec 13, 2021 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.