-3

I have the following optimization problem: I want to minimize the cost of buying products from various suppliers. Prices of the products vary depending on supplier. Additionally, each supplier has their shipping cost. Shipping cost can be discounted depending on the amount of products bought from given supplier. I know how to define cost function and most of the constraints, but I’m struggling to formulate the shipping cost which is quantity dependent.

Further I’d like to solve the problem programmatically with Python, but I have to start from mathematical formulation.

Any hints on how to incorporate quantity dependent discount into linear Optimization problem?

Malcolm
  • 21
  • 3
  • 3
    Hello, and welcome to stack overflow. You might want to break your question down into two separate posts. The preferred format for questions on stack overflow is [one question per post](https://meta.stackexchange.com/q/222735), so your question might not attract a response from someone who knows an answer to only one of your two questions. – dbc Aug 24 '20 at 21:02
  • Hi dbc, thanks for the guidelines, I reformulated my post. – Malcolm Aug 25 '20 at 13:47
  • The formulation depends on the details of the rules for the discounts. – Erwin Kalvelagen Aug 26 '20 at 23:01
  • Hi @ErwinKalvelagen, the details are: if the cost of buying goods from given supplier exceeds specified amount, the original shipping cost is discounted by some percentage - the values for each supplier are different. – Malcolm Aug 28 '20 at 05:45

1 Answers1

0

The discounted shipped cost is probably a piecewise linear function. Often we model with SOS2 variables (Special Ordered Set of Type 2). Many solvers/modeling systems support this or have other support for piecewise linear functions.

AFAIK PuLP has no facilities for this. So we need to use binary variables. Here is one approach. Below I just use one supplier. just add a supplier index to the model to handle multiple suppliers.

(1) Introduce a binary variable b with:

  product_cost < discount_threshold  =>  b = 0    
  product_cost >= discount_threshold =>  b = 1

This can be modeled as:

  b * discount_threshold <= product_cost <= discount_threshold + b*(U-discount_threshold)

where

  discount_theshold : data
  product_cost : positive variable 
  U : upperbound on product_cost

(2) Next, we need to calculate the net_shipping_cost. We need to work with:

  b=0 => net_shipping_cost = shipping_cost
  b=1 => net_shipping_cost = (1-discount_percentage) * shipping_cost

where

  net_shipping_cost : positive variable
  shipping_cost : positive variable (calculated elsewhere)
  discount_percentage : constant

This can be modeled as:

  net_shipping_cost >= shipping_cost - M*b
  net_shipping_cost >= (1-discount_percentage) * shipping_cost - M*(1-b)

where

  M : upper bound on shipping_cost
        

We use here that we are minimizing the total cost.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
  • I managed to formulate part of the problem in Pyomo, but still not able to add the shipping cost into it. I posted another question here: https://stackoverflow.com/questions/65369002/minimize-cost-based-on-purchased-volume-pyomo – Malcolm Dec 20 '20 at 07:39