Consider the following transportation problem. Here you have your costs, supplies and demands.
Now, the trick is to formulate it as a LP-problem.
Setting it up
restart: with(simplex): with(ArrayTools): with(linalg):
The objective function
First, we need to formulate an objective function. This is done by using all the cost variables from the table above. The variable C is a vector that contains all the costs. The X variable counts how many variable there are and the dotprod method generates our objective function. It is possible to do this differently but I think this makes it easier to understand.
If the problem involves a big M, just replace it with a very large number.
c := vector([ 464,513,654,867, 352,416,690,791, 995,682,388,685 ]); x := vector(Size(c,2)); z := dotprod(x,c);
Creating the constrains
There are two types of constraints here. The first is for the supplies and the second is for the demand. I have added an empty line within the constraints just to make is easier to see. The supply constraints are made out each of the rows from the table and the demands are from the columns.
c := [ x + x + x + x = 75, x + x + x + x = 125, x + x + x + x = 100, x + x + x = 80, x + x + x = 65, x + x + x = 70, x + x + x = 85 ];
Using the simplex method
minimize(z, c, NONNEGATIVE); assign(%); Z;