3

I'm a novice with R. I'm trying to figure out the functions/packages I can use for a Logistics Optimization problem. For example, how can we maximize routes of trucks to deliver goods given that the company has 5 trucks and each has max. capacity of 500 boxes but unable to reach the max limit.

Kindly see the table below to give you a clearer picture of my sample problem.

TABLE 1.  Current Set-up per Truck          
TruckNo  Current_Cap_Per_Truck   Max_Cap   Available_Space
      1                    500       500                 0
      2                    500       500                 0
      3                    300       500               200
      4                    300       500               200
      5                    300       500               200

Table 1 shows that Trucks 1 and 2 reached the max capacity, however trucks 3,4 and 5 got only 300 box each. As you can see, there is a total of 600 box to occupy the available space. I was thinking maybe we can adjust the load for trucks 3,4,and 5 so that we can maximize the capacity of each truck and minimize the number of trucks to be used.

Has anyone had a an experience using R package or functions to solve this kind of problem? R offers several optimization packages but I couldnt figure out how to start doing the script. Thank you.

Karussell
  • 17,085
  • 16
  • 97
  • 197
user2291413
  • 39
  • 1
  • 3
  • 1
    This question is interesting and I look forward to responses. Community members may be more interested in answering thoughtfully if you supply some data for them to play with on their own while thinking through solutions (in the case that the solution isn't canned in a simple package). – ndoogan Apr 17 '13 at 17:09
  • 2
    http://lpsolve.r-forge.r-project.org/ is this homework? Example here: http://fishyoperations.com/r/linear-programming-in-r-an-lpsolveapi-example/ – Brandon Bertelsen Apr 17 '13 at 17:46
  • 1
    With the data you give (no constraints except the maximum capacity of each truck), a greedy approach seems to suffice: fill the first truck until full, then the second, and so on, until there are no more boxes -- all trucks, except perhaps the last one, are full. If you want the load of the trucks to be more balanced, compute the number of trucks needed (as before), and allocate the boxes proportionally to the maximum capacity of the trucks. – Vincent Zoonekynd Apr 17 '13 at 17:52
  • @BrandonBertelsen I read the problem as one of jointly optimizing truck routes and truck loads. – ndoogan Apr 17 '13 at 17:52
  • At it's core, this is a basic linear programming problem. Vincent is simply explaining what could otherwise be defined by an LP solution. – Brandon Bertelsen Apr 17 '13 at 17:54
  • @Brandon, MILP to be exact as it would involve "truck #i is used" boolean variables. Though most LP solvers (including the one you pointed to) do have a variable type option (continuous/integer/boolean) to handle the more general MILP. – flodel Apr 17 '13 at 17:58
  • 3
    Still think it looks suspiciously like homework :P – Brandon Bertelsen Apr 17 '13 at 18:03
  • @Brandon, this is not a homework problem, but yeah looks like it. :) Been using R for only a month. I've done correlation and regression analysis. Haven't tried working on optimization problem even during my undergrad. I wish I could check out fishyoperations.com but I can't seemed to view the website either. – user2291413 Apr 18 '13 at 07:05
  • I'm trying to understand the function of for loop in the R script provided in http://fishyoperations.com/uploads/lpsolve_example.R, . What does it do? What is the end result of this code? The first thing I did is to understand the sub functions (functions inside the for loop). For example, what does set.column do? I know the the values for 1st and last argument except for c(1, cargo[type,'volume'],1). Can someone help me figure out the value for cargo[type,'volume']? Thanks. – user2291413 Apr 23 '13 at 07:18

0 Answers0