There are a number of orders, which needs to be shipped. For each order, there may be 1 to 3 route options. The problem here is to find out the best allocation (combination) of orders among these routes.


Suppose the full capacity and per km transport cost for each type of truck are:

7.6(size) -> 5300(weight), 4.4(cost per km);
9.6(size) -> 7100(weight), 4.81(cost per km);
15(size) -> 12000(weight), 6.34(cost per km);

Suppose all routes has 3 number of transit times to reach the destination, then:

transit cost of each route = transit times*order quantity allocated to this route*4.5

Suppose transport cost of route is based on number of trucks used and the travling distance, then:

transport cost of each route = number of trucks allocated to this route*route distance

// Variables

x[j] -> 0-1 variables, if route x1,x2,x3....xj is used.
a[i][j] -> is the weight proportion of order i allocated to route j
t[j][s] -> truck number of certain size needed for each routes

Objective Function:

Min (total tranpsort cost + total transit cost) -> MinΣ(x[j]*t[j][s]*Distance[j]*Cost[j] + x[j]*a[i][j]*OrderQuantity[i]*TransitTimes

Subject to:

1. if a[i][j] is the proportion of weight allocation among the feasible routes of an order, then:
a1+a2+a3 = 1
2. orders combined together must choose the same route
3. orders combined together must be the same route type
4. all orders must be allocated to one or more trucks and shipped
5. the chosen of the truck size must be within the truck options for each route
6. total weight loaded on the truck must not exceed the total capacity of the truck

This is how the input date may look like: enter image description here

This is the CSV formate of the input data:


The optimization result might look like this:

enter image description here

My questions: I am not sure how to write the constraints 2,3,5,6. In particular, I have no idea to:

1). model the connection between the weight allocated to a route and the associated truck size and quantity needed for the same route (i.e. how to write the objective function properly to represent the total transport cost); 
2). make sure orders combined using the same route and same route type

An MIP code example using Google OR tools or Gurobi python would be helpful.


Your Answer

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

Browse other questions tagged or ask your own question.