R has many powerful libraries to handle operations research. This exercise tries to demonstrate a few basic functionality of R while dealing with linear programming.
Linear programming is a technique for the optimization of a linear objective function, subject to linear equality and linear inequality constraints.
The lpsolve package in R provides a set of functions to create models from scratch or use some prebuilt ones like the assignment and transportation problems.
Answers to the exercises are available here. If you obtained a different (correct) answer than those
listed on the solutions page, please feel free to post your answer as a comment on that page.
Please install and load the package lpsolve and igraph before starting the exercise.
Answers to the exercises are available here.
Load packages lpSolve and igraph. Then, take a look at lp.assign to see how it works.
Create a matrix representing the cost related to assign 4 tasks(rows) to 4 workers(cols) by generating integer random numbers between 50 and 100, with replacement. In order to make this exercise reproducible, define seed as 1234.
Who should be assign to each task to obtain all the work done at minimal cost?
Based on the resource allocation plan, how much we will spend to get all this work done?
Take a look at lp.transport to see how it works. Set up the cost matrix by generating integer random numbers between 0 and 1000, without replacement. Consider that will be 8 factories(rows) serving 5 warehouses(cols).
Set up the offer constraint by generating integer random numbers between 50 and 300, without replacement.
Set up the demand constraint by generating integer random numbers between 100 and 500, without replacement.
Find out which factory will not use all its capacity at the optimal cost solution.
What is the cost associated to the optimal distribution?
Create adjacency matrix using your solution in order to create a graph using igraph package.