I have a question regarding writing some formulas for LP. How would you code the price change after X number of units sold.

So lest say the base price for the first X units sold is £5 and then there is a £1 discount for units bought after the X unit.


The answer is different depending on if you are selling or buying. First, look at the case where you are selling products and want to maximize revenue.


  • $w$: the number of units sold
  • $v$: the number units sold in excess of $X$
  • $r$: the total revenue

Your constraints are then $$ 5 w - v = r \\ w - v \le X$$

The first constraint defines revenue as 5 times the total sold, less the number sold at a discount. The second constraint forces the discount on quantities above the threshold $X$. These constraints don't explicitly disallow a discount on items sold below the threshold, but If you are trying to maximize revenue there is no need. However if revenue is a cost, then you need additional constraints and a Boolean variable to indicate that you are eligible for the discount. To add this, you need the following additional variable.

  • $d$: indicator that more than $X$ items have been purchased.

and the following model. $$ 5 w - v = r \\ v \le w - X d \\ v \le M d \\ d \in \{0, 1\} $$

Where $M$ is an a priori upper bound on the number of items sold at a discount.


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.