<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/data-science-for-operational-excellence-part-1/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://r-exercises.com/2017/04/06/data-science-for-operational-excellence-part-1-exercises/?utm_source=rss&utm_medium=rss&utm_campaign=data-science-for-operational-excellence-part-1-exercises"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>﻿<a target="_blank" rel="nofollow" href="http://r-exercises.com/wp-content/uploads/2017/04/code-1839406__340.jpg?x61433"><img sizes="(max-width: 150px) 100vw, 150px" alt="" class="wp-image-4872" src="https://i1.wp.com/r-exercises.com/wp-content/uploads/2017/04/code-1839406__340-150x150.jpg?resize=150%2C150" data-recalc-dims="1"></a></p>
<p>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.<br>
Linear programming is a technique for the optimization of a linear objective function, subject to linear equality and linear inequality constraints.<br>
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.<br>
Answers to the exercises are available here. If you obtained a different (correct) answer than those<br>
listed on the solutions page, please feel free to post your answer as a comment on that page.<br>
Please install and load the package lpsolve and igraph before starting the exercise.</p>
<p>Answers to the exercises are available <a target="_blank" rel="nofollow" href="http://r-exercises.com/2017/04/06/data-science-for-operational-excellence-part-1-solutions/">here</a>.</p>
<p><strong>Exercise 1</strong><br>
Load packages lpSolve and igraph. Then, take a look at lp.assign to see how it works.</p>
<p><strong>Exercise 2</strong><br>
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.</p>
<p><strong>Exercise 3</strong><br>
Who should be assign to each task to obtain all the work done at minimal cost?</p>
<p><strong>Exercise 4</strong><br>
Based on the resource allocation plan, how much we will spend to get all this work done?</p>
<p><strong>Exercise 5</strong><br>
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).</p>
<p><strong>Exercise 6</strong><br>
Set up the offer constraint by generating integer random numbers between 50 and 300, without replacement.</p>
<p><strong>Exercise 7</strong><br>
Set up the demand constraint by generating integer random numbers between 100 and 500, without replacement.</p>
<p><strong>Exercise 8</strong><br>
Find out which factory will not use all its capacity at the optimal cost solution.</p>
<p><strong>Exercise 9</strong><br>
What is the cost associated to the optimal distribution?</p>
<p><strong>Exercise 10</strong><br>
Create adjacency matrix using your solution in order to create a graph using igraph package.</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a title="Data science for Doctors: Inferential Statistics Exercises(Part-4)" target="_blank" rel="nofollow" href="http://r-exercises.com/2017/04/02/data-science-for-doctors-inferential-statistics-part4/">Data science for Doctors: Inferential Statistics Exercises(Part-4) </a></li>
<li><a title="Data Science for Doctors – Part 1 : Data Display" target="_blank" rel="nofollow" href="http://r-exercises.com/2017/01/29/data-science-for-doctors-part-1-data-display/">Data Science for Doctors – Part 1 : Data Display </a></li>
<li><a title="Data Science for Doctors – Part 2 : Descriptive Statistics" target="_blank" rel="nofollow" href="http://r-exercises.com/2017/02/05/data-science-for-doctors-part-2-descriptive-statistics/">Data Science for Doctors – Part 2 : Descriptive Statistics </a></li>
<li><a target="_blank" rel="nofollow" href="http://r-exercises.com/start-here-to-learn-r/">Explore all our (>1000) R exercises</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-exercises.com/r-courses/">Find an R course using our R Course Finder</a> directory</li>
</ol>
</div>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://r-exercises.com/2017/04/06/data-science-for-operational-excellence-part-1-exercises/?utm_source=rss&utm_medium=rss&utm_campaign=data-science-for-operational-excellence-part-1-exercises"> R-exercises</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/bFT0Y9pvSTM"></a></div>