Is this a constraint optimisation problem? If so, which OR-tools template is most appropriate?

Viewed 41

I'm a little bit conceptually lost with the right approach to the problem I'm solving. I think Google's OR tools can potentially be a direction I can go, but unsure how to get started.

This is a shipping cost optimisation problem - I have 3 packages, and 5 different shipping providers. Each package has a weight and longest dimension, and each provider has restrictions on these dimensions, and potential surcharges based on the dimensions of the package.

For example, let's say the packages are represented with the following dicts:

package_one = {"weight":10, "longest_dim": 120}
package_two = {"weight":12, "longest_dim": 60}

And say the shipping providers have the following constraints:

provider_one = {"max_weight": 10, "longest_dim": 150, "cost_per_item": 3.99}
provider_two = {"max_weight": 25, "longest_dim": 200, "cost_per_item": 10.99}
provider_three = {"max_weight": 15, "longest_dim": 100, "cost_per_item": 4.99}

What I'm looking to do is find the cheapest way of delivering all the packages - so in this case, even though provider_two can ship the packages (since their combined weight is 22 and combined height is 180, meeting the constraint requirements), the cost would be $21.98, whereas if package_one was sent by provider_one while package_two was sent by provider_two it would cost $8.98.

In summary, my questions are something like:

  1. Can you solve this problem using OR tools - if so, what model would be most appropriate (bin-packing? scheduling?) and what are some things to consider
  2. Would this be a two-pronged approach - do I first need to look at feasibility (e.g. what group of packages is possible to send with a shipping provider within its constraints) and then consider cost optimisation?

Thanks in advance for your help - this has been melting my brain all day.

1 Answers

Start by writing the equations.

You can create one Boolean variable per item and per provider. Then add constraints for the feasibility of the problem (only shipped once, must be shipped, must fit...)

Then add the objective part.

About solving, this is a simple linear problem with Boolean equations. CP-SAT or the linear solver wrapper are good fit.

Related