Data Science for Operational Excellence (Part-1)

April 6, 2017
By

(This article was first published on R-exercises, and kindly contributed to R-bloggers)



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.

Exercise 1
Load packages lpSolve and igraph. Then, take a look at lp.assign to see how it works.

Exercise 2
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.

Exercise 3
Who should be assign to each task to obtain all the work done at minimal cost?

Exercise 4
Based on the resource allocation plan, how much we will spend to get all this work done?

Exercise 5
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).

Exercise 6
Set up the offer constraint by generating integer random numbers between 50 and 300, without replacement.

Exercise 7
Set up the demand constraint by generating integer random numbers between 100 and 500, without replacement.

Exercise 8
Find out which factory will not use all its capacity at the optimal cost solution.

Exercise 9
What is the cost associated to the optimal distribution?

Exercise 10
Create adjacency matrix using your solution in order to create a graph using igraph package.

To leave a comment for the author, please follow the link and comment on their blog: R-exercises.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)