This page shows a few uses of the omTransport R function.
We have 10 tasks that we need to assign to 3 people. Each person has a different speed at which he does each task, and we want to partition the tasks as evenly as possible. Also, some tasks are more “tiring” than others.
Let’s say that Person A is a gardener, Person B is a farmer, and Person C is a programmer. The 10 tasks are: planting a tree, tending a garden, four different difficulties of planting a field, taking care of livestock, cooking a meal, auditing a business, and building a mobile application.
We want to minimize the total time that it takes to complete all the tasks, while keeping an even distribution of effort.
For the tasks above, we’ll estimate their required effort to be:
## Tree Garden Easy Field
## 1 3 2
## Medium Field Difficult Field Really Difficult Field
## 4 6 8
## Livestock Cooking a Meal Auditing a Business
## 7 4 8
## Mobile Application
## 8
And the time that it will take for each worker to do each task (in hours) is:
## Gardener Farmer Programmer
## Tree 0.1 0.25 1.0
## Garden 0.5 0.75 2.0
## Easy Field 2.0 1.00 5.0
## Medium Field 4.0 2.00 8.0
## Difficult Field 6.0 3.00 11.0
## Really Difficult Field 8.0 4.00 14.0
## Livestock 10.0 5.00 25.0
## Cooking a Meal 1.0 1.00 2.5
## Auditing a Business 50.0 25.00 25.0
## Mobile Application 100.0 125.00 25.0
We’ll use omTransport to divide up the tasks.
omTransport takes five parameters:
tamatrix: The cost function for each agent-task pairing, in matrix form, with the agents as the columns and the tasks as the rows. For example, the element (“Tree”,“Gardner”) is how long the gardener would have to take to plant a tree.
taskweights: How much effort each task takes. By default, all task weights are assumed to be the same.
agentassignment: The distribution of effort to each agent. By default, all agents are assumed to take on an even distribution of work.
tasknames: Names of the tasks.
agentnames: Names of the agents.
df <- data.frame(Gardener=c(.1,.5,2,4,6,8,10,1,50,100),Farmer=c(.25,.75,1,2,3,4,5,1,25,125),Programmer=c(1,2,5,8,11,14,25,2.5,25,25)) #agent-task matrix
tasks <- c("Tree","Garden","Easy Field","Medium Field","Difficult Field","Really Difficult Field","Livestock","Cooking a Meal","Auditing a Business","Mobile Application")
agents <- c("Gardener","Farmer","Programmer")
efforts <- c(1,3,2,4,6,8,7,4,8,8)
omTransport(tamatrix=df,taskweights=efforts,tasknames=tasks,agentnames=agents)
## $Gardener
## [1] "Garden" "Easy Field" "Medium Field" "Difficult Field"
## [5] "Cooking a Meal"
##
## $Farmer
## [1] "Really Difficult Field" "Livestock"
##
## $Programmer
## [1] "Tree" "Auditing a Business" "Mobile Application"
Now let’s get to a more real-world example (actually the motivating idea for this package).
Let’s say that we want to establish NCAA football as a minor league system to the NFL. Our goal is to create an even distribution of feeder college teams to pro teams, while minimizing the college teams’ amount of travel.
So, we’ll make each college football team a “task” and each NFL team an “agent”. Some teams are stronger than others (we don’t want the Falcons to get Alabama, Auburn, Georgia and Georgia Tech), so we’ll estimate each college’s “worth” to be its number of NFL draft picks in the past 25 years. The cost for each college-pro relationship will be the amount of miles between the two teams. Finally, we want each pro team to get as even a distribution of “worth” as possible.
Thanks to Pro Football Reference and Google Maps, I’ve pre-processed the location for each professional and college team I’m going to use. Each college that has a draft pick in the past 25 years is used.
data(colleges,package="omTransport") #load college locations
data(proteams,package="omTransport") #load pro locations
data(collegeweights,package="omTransport") #load number of draft picks for each college
distances <- distm(colleges,proteams) #returns the matrix for the distance from each college team to each pro team
rownames(distances) <- rownames(colleges) #set names of tasks
colnames(distances) <- rownames(proteams) #sets names of agents
distances <- round(distances/1609,0) #convert to miles
head(distances)
## Atlanta, Georgia, USA Baltimore, Maryland, USA
## Abilene Christian 892 1373
## Air Force 1194 1510
## Akron 531 287
## Ala-Birmingham 140 694
## Alabama 187 741
## Alabama A&M 143 634
## Boston, Massachusetts, USA Buffalo, New York, USA
## Abilene Christian 1706 1344
## Air Force 1777 1379
## Akron 547 184
## Ala-Birmingham 1053 778
## Alabama 1099 819
## Alabama A&M 990 700
## Charlotte, North Carolina, USA Chicago, Illinois, USA
## Abilene Christian 1099 929
## Air Force 1346 927
## Akron 406 322
## Ala-Birmingham 361 581
## Alabama 409 600
## Alabama A&M 327 498
## Cincinnati, Ohio, USA Cleveland, Ohio, USA
## Abilene Christian 967 1172
## Air Force 1091 1232
## Akron 209 31
## Ala-Birmingham 408 620
## Alabama 442 658
## Alabama A&M 324 538
## Dallas, Texas, USA Denver, Colorado, USA
## Abilene Christian 171 583
## Air Force 624 52
## Akron 1020 1237
## Ala-Birmingham 581 1096
## Alabama 536 1067
## Alabama A&M 602 1069
## Detroit, Michigan, USA Indianapolis, Indiana, USA
## Abilene Christian 1139 909
## Air Force 1164 1000
## Akron 118 261
## Ala-Birmingham 644 435
## Alabama 678 460
## Alabama A&M 560 349
## Jacksonville, Florida, USA Kansas City, Missouri, USA
## Abilene Christian 1075 541
## Air Force 1445 552
## Akron 743 704
## Ala-Birmingham 373 581
## Alabama 401 565
## Alabama A&M 419 535
## Miami, Florida, USA Green Bay, Wisconsin, USA
## Abilene Christian 1265 1044
## Air Force 1699 947
## Akron 1062 407
## Ala-Birmingham 667 765
## Alabama 680 783
## Alabama A&M 728 682
## Minneapolis, Minnesota, USA Nashville, Tennessee, USA
## Abilene Christian 932 781
## Air Force 725 1009
## Akron 652 443
## Ala-Birmingham 865 184
## Alabama 869 209
## Alabama A&M 792 100
## New Orleans, Louisiana, USA New York Giants
## Abilene Christian 596 1531
## Air Force 1048 1635
## Akron 907 393
## Ala-Birmingham 312 863
## Alabama 269 910
## Alabama A&M 388 802
## New York Jets Oakland, California, USA
## Abilene Christian 1531 1325
## Air Force 1635 946
## Akron 393 2170
## Ala-Birmingham 863 2004
## Alabama 910 1969
## Alabama A&M 802 1990
## Philadelphia, Pennsylvania, USA Phoenix, Arizona, USA
## Abilene Christian 1459 720
## Air Force 1580 556
## Akron 343 1753
## Ala-Birmingham 784 1455
## Alabama 831 1413
## Alabama A&M 724 1459
## Pittsburgh, Pennsylvania, USA
## Abilene Christian 1224
## Air Force 1323
## Akron 91
## Ala-Birmingham 610
## Alabama 652
## Alabama A&M 535
## Los Angeles, California, USA San Diego, California, USA
## Abilene Christian 1076 1016
## Air Force 818 814
## Akron 2056 2040
## Ala-Birmingham 1801 1754
## Alabama 1761 1712
## Alabama A&M 1800 1758
## San Francisco, California, USA Seattle, Washington, USA
## Abilene Christian 1333 1581
## Air Force 954 1058
## Akron 2178 2045
## Ala-Birmingham 2012 2082
## Alabama 1977 2061
## Alabama A&M 1998 2040
## Tampa, Florida, USA Washington, DC, USA
## Abilene Christian 1077 1345
## Air Force 1496 1491
## Akron 910 281
## Ala-Birmingham 463 661
## Alabama 474 708
## Alabama A&M 529 602
## Houston, Texas, USA
## Abilene Christian 318
## Air Force 837
## Akron 1103
## Ala-Birmingham 567
## Alabama 518
## Alabama A&M 618
We now have the distance from each college team and each pro team, or the cost values between each task and each agent. Now, all that’s left to do is find the estimated optimal allocation of colleges to professional teams.
omTransport(tamatrix=distances,taskweights=collegeweights$Weight,tasknames=rownames(distances),agentnames=colnames(distances)) #run the algorithm; the "tasks" are the college teams because they're the ones being assigned
## $`Atlanta, Georgia, USA`
## [1] "Alabama" "Alabama State" "Auburn" "Georgia Tech"
## [5] "Morehouse" "Morris Brown" "Tuskegee"
##
## $`Baltimore, Maryland, USA`
## [1] "Ala-Birmingham" "James Madison" "Samford" "Tennessee"
## [5] "Tusculum" "Virginia" "Virginia Union"
##
## $`Boston, Massachusetts, USA`
## [1] "Albany (NY)" "Army"
## [3] "Bentley" "Boston College"
## [5] "Brown" "Central Connecticut State"
## [7] "Connecticut" "Connecticut State"
## [9] "Cornell" "Dartmouth"
## [11] "Harvard" "Hobart"
## [13] "Hofstra" "Maine"
## [15] "Marist" "Massachusetts"
## [17] "McGill" "New Hampshire"
## [19] "Northeastern" "Sacred Heart"
## [21] "State Paul's" "Syracuse"
## [23] "Yale"
##
## $`Buffalo, New York, USA`
## [1] "Akron" "Buffalo" "Central Michigan"
## [4] "Central State (OH)" "Clarion" "Eastern Michigan"
## [7] "Grand Valley State" "Kent State" "Michigan State"
## [10] "Monmouth" "Mount Union" "Saginaw Valley State"
## [13] "Slippery Rock" "Toledo" "Western Michigan"
## [16] "Western Ontario" "Youngstown State"
##
## $`Charlotte, North Carolina, USA`
## [1] "Georgia" "Presbyterian" "South Carolina"
##
## $`Chicago, Illinois, USA`
## [1] "Central Missouri State" "Illinois"
## [3] "Illinois State" "Midwestern State"
## [5] "Missouri" "Missouri Southern"
## [7] "Missouri State" "Missouri Western State"
## [9] "Northern Illinois" "Northwestern"
## [11] "Western Illinois"
##
## $`Cincinnati, Ohio, USA`
## [1] "Ark-Pine Bluff" "Bowling Green" "Cincinnati"
## [4] "Eastern Kentucky" "Lambuth" "Lane College"
## [7] "Louisville" "Mars Hill" "Memphis"
## [10] "Miami (OH)" "Middle Tenn. State" "Murray State"
## [13] "Tenn-Martin"
##
## $`Cleveland, Ohio, USA`
## [1] "Ashland" "Ball State" "Ohio" "Ohio State"
##
## $`Dallas, Texas, USA`
## [1] "Abilene Christian" "Angelo State (TX)" "North Texas"
## [4] "Southern Methodist" "Tarleton State" "TCU"
## [7] "Texas A&M" "Texas A&M-Commerce" "Texas Southern"
## [10] "West Texas A&M"
##
## $`Denver, Colorado, USA`
## [1] "Air Force" "Colorado" "Colorado State"
## [4] "Northern Colorado" "Utah" "Weber State"
## [7] "Western Kentucky" "Wyoming"
##
## $`Detroit, Michigan, USA`
## [1] "Albion" "Hillsdale" "Michigan" "Notre Dame"
##
## $`Indianapolis, Indiana, USA`
## [1] "Arkansas" "Arkansas A&M" "Arkansas State"
## [4] "Central Arkansas" "Eastern Illinois" "Harding"
## [7] "Indiana" "Lindenwood" "Newberry"
## [10] "Purdue" "SE Missouri State" "Southern Illinois"
## [13] "SW Missouri State"
##
## $`Jacksonville, Florida, USA`
## [1] "Albany State (GA)" "Florida" "Fort Valley State"
## [4] "Georgia Southern" "Georgia State" "Jacksonville State"
## [7] "Troy" "Valdosta State"
##
## $`Kansas City, Missouri, USA`
## [1] "East Central (OK)" "Kansas" "Kansas State"
## [4] "NW Oklahoma State" "Oklahoma" "Oklahoma State"
## [7] "Washburn"
##
## $`Miami, Florida, USA`
## [1] "Bethune-Cookman" "Central Florida" "Florida A&M"
## [4] "Florida Atlantic" "Florida International" "Miami (FL)"
##
## $`Green Bay, Wisconsin, USA`
## [1] "Iowa" "Iowa State"
## [3] "Michigan Tech" "Northern Iowa"
## [5] "NW Missouri State" "Wisconsin"
## [7] "Wisconsin Stevens Point" "Wisconsin Stout"
## [9] "Wisconsin Whitewater"
##
## $`Minneapolis, Minnesota, USA`
## [1] "Chadron State" "Concordia-StatePaul (MN)"
## [3] "Idaho State" "Jamestown"
## [5] "Manitoba" "Minnesota"
## [7] "Montana" "Montana State"
## [9] "Nebraska" "Nebraska-Omaha"
## [11] "North Dakota" "North Dakota State"
## [13] "Pittsburg State" "South Dakota"
## [15] "South Dakota State"
##
## $`Nashville, Tennessee, USA`
## [1] "Delta State" "Jackson State" "La-Monroe"
## [4] "Louisiana Tech" "Mississippi" "Mississippi State"
## [7] "North Alabama" "Stillman" "Tennessee State"
## [10] "Vanderbilt"
##
## $`New Orleans, Louisiana, USA`
## [1] "Alcorn State" "Grambling State"
## [3] "La-Lafayette" "Louisiana State"
## [5] "McNeese State" "Nicholls State"
## [7] "NW State (LA)" "Pearl River Community College"
## [9] "Sam Houston State" "SE Louisiana"
## [11] "Southern" "Tulane"
##
## $`New York Giants`
## [1] "Citadel" "Coastal Carolina" "Knoxville"
## [4] "North Carolina" "North Carolina State" "South Carolina State"
## [7] "The Citadel"
##
## $`New York Jets`
## [1] "Bloomsburg" "Columbia" "Fordham"
## [4] "Indiana (PA)" "Langston" "Lehigh"
## [7] "Norfolk State" "Penn State" "Princeton"
## [10] "Richmond" "Rowan" "Rutgers"
## [13] "Towson" "William and Mary" "William Penn"
##
## $`Oakland, California, USA`
## [1] "Boise State" "Cal State-Sacramento" "California"
## [4] "Nevada"
##
## $`Philadelphia, Pennsylvania, USA`
## [1] "Delaware" "Delaware State"
## [3] "Duke" "Elon"
## [5] "Hampton" "Howard"
## [7] "Livingstone" "Maryland"
## [9] "Morgan State" "Navy"
## [11] "North Carolina A&T" "North Carolina Central"
## [13] "Pennsylvania" "Temple"
## [15] "Villanova" "Wake Forest"
## [17] "Widener" "Winston-Salem State"
##
## $`Phoenix, Arizona, USA`
## [1] "Arizona" "Arizona State" "New Mexico"
## [4] "New Mexico State" "Texas-El Paso" "Texas Tech"
## [7] "Western New Mexico" "Wingate"
##
## $`Pittsburgh, Pennsylvania, USA`
## [1] "Alabama A&M" "California (PA)" "Chattanooga"
## [4] "Kentucky" "Kentucky State" "Marshall"
## [7] "Pittsburgh" "Tenn-Chattanooga" "Tennessee Tech"
## [10] "West Alabama" "West Virginia"
##
## $`Los Angeles, California, USA`
## [1] "Butte Junior College (CA)" "Cal Poly-San Luis Obispo"
## [3] "Fresno State" "USC Los Angeles"
##
## $`San Diego, California, USA`
## [1] "Brigham Young" "California-Davis"
## [3] "Long Beach Community College" "Mount San Antonio Junior College"
## [5] "Northern Arizona" "San Diego"
## [7] "San Diego State" "Southern Utah"
## [9] "UCLA" "UNLV"
## [11] "Utah State"
##
## $`San Francisco, California, USA`
## [1] "Hawaii" "Oregon" "San Jose State" "Stanford"
##
## $`Seattle, Washington, USA`
## [1] "Eastern Washington" "Idaho" "Oregon State"
## [4] "Portland" "Portland State" "Washington"
## [7] "Washington State" "Western Oregon" "Whitworth (WA)"
##
## $`Tampa, Florida, USA`
## [1] "East Carolina" "Florida State" "South Florida"
## [4] "Southern Miss" "State Augustine's"
##
## $`Washington, DC, USA`
## [1] "Appalachian State" "Clemson" "Furman"
## [4] "Gardner-Webb" "Lenoir-Rhyne" "Liberty"
## [7] "Virginia Tech"
##
## $`Houston, Texas, USA`
## [1] "Baylor" "Houston" "Rice"
## [4] "S.F. Austin" "Texas" "Texas-San Antonio"
## [7] "Texas A&M-Kingsville" "Texas State" "Tulsa"