<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-4/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.r-exercises.com/2017/04/27/data-science-for-operational-excellence-part-4-exercises/?utm_source=rss&utm_medium=rss&utm_campaign=data-science-for-operational-excellence-part-4-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="https://i2.wp.com/www.r-exercises.com/wp-content/uploads/2017/04/forecasting-part-4-2.png"><img sizes="(max-width: 150px) 100vw, 150px" alt="" class="wp-image-5475" src="https://i2.wp.com/www.r-exercises.com/wp-content/uploads/2017/04/forecasting-part-4-2-150x150.png?resize=150%2C150" data-recalc-dims="1"></a></p>
<p>Suppose your friend is a restaurant chain owner (only 3 units) facing some competitors challenges related to low price, lets call it a price war. Inside his business he knows that there’s no much cost to be cut. But, he thinks that, maybe if he tries harder to find better supplier with low freight and product costs, he could be in a better situation. So, he decided to hire you a recent grad data scientist to figure out how to solve this problem and to build a tool to make your findings to be incorporated in his daily operations. As a Data Scientist you know that this problem could be solved through the use of lpSolve package.</p>
<p>Our goal here is to expand your knowledge to create custom constraints to be used in real business problems.</p>
<p>Answers to the exercises are available <a target="_blank" rel="nofollow" href="http://r-exercises.com/2017/04/27/data-science-for-operational-excellence-part-4-solutions/">here</a>.</p>
<p><strong>Exercise 1</strong><br>
We will solve a transportation problem for your friend’s restaurant chain with 2 different products sold from 4 different suppliers. Create a cost vector that model different costs for each combination of restaurant, supplier and product. Use integer random numbers from 0 to 1000 to fill this vector. In order to be reproducible, set seed equals to 1234.</p>
<p><strong>Exercise 2</strong><br>
Create the demand constraints. Consider that every restaurant need a specific quantity for each product. Use integer random numbers from 100 to 500 to define minimum quantities to keep the restaurant open without running out of any supplies.</p>
<p><strong>Exercise 3</strong><br>
Create the offer constraints. Consider that every supplier can deliver a specific quantity related to each product. Use integer random numbers from 200 to 700 to define maximum quantities that each supplier can deliver.</p>
<p><strong>Exercise 4</strong><br>
Prepare the parameter of the <code>lp()</code> function using the variables created above.</p>
<p><strong>Exercise 5</strong><br>
Now, solve these problem with these constraints created so far.</p>
<div>
<aside><img src="http://www.r-exercises.com/2017/04/27/data-science-for-operational-excellence-part-4-exercises/?utm_source=rss&utm_medium=rss&utm_campaign=data-science-for-operational-excellence-part-4-exercises"></aside>
<div><strong>Learn more</strong> about geo visualization in the online course <a target="_blank" rel="nofollow" href="http://www.r-exercises.com/product/r-complete-data-visualization-solutions/">R: Complete Data Visualization Solutions</a>. In this course you will learn how to:
<ul>
<li>Build advanced map visualizations</li>
<li>Work with different sources for maps</li>
<li>And much more visualizations</li>
</ul>
</div>
</div>
<p><strong>Exercise 6</strong><br>
We know that some suppliers have minimum order quantities. Create a new set of constraints to represent that. Use integer random numbers from 50 to 70 to define minimum quantities that we can order from each supplier.</p>
<p><strong>Exercise 7</strong><br>
Now, solve these problem with these constraints created so far.</p>
<p><strong>Exercise 8</strong><br>
We also know that some vehicles have maximum capacity in terms of weight and volume. Create a new set of constraints to represent that. Use integer random numbers from 100 to 500 to define maximum quantities that we can order from each supplier.</p>
<p><strong>Exercise 9</strong><br>
Prepare again the <code>lp()</code> function parameters using the variable created above.</p>
<p><strong>Exercise 10</strong><br>
Now, solve these problem with all constraints.</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a title="Lets Begin with something sample" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2016/03/23/lets-begin-with-something-sample/">Lets Begin with something sample </a></li>
<li><a title="Data Science for Operational Excellence (Part-1)" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2017/04/06/data-science-for-operational-excellence-part-1-exercises/">Data Science for Operational Excellence (Part-1) </a></li>
<li><a title="Data Exploration with Tables exercises" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2016/04/20/data-exploration-with-tables-exercises/">Data Exploration with Tables exercises </a></li>
<li><a target="_blank" rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/">Explore all our (>1000) R exercises</a></li>
<li><a target="_blank" rel="nofollow" href="http://www.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://www.r-exercises.com/2017/04/27/data-science-for-operational-excellence-part-4-exercises/?utm_source=rss&utm_medium=rss&utm_campaign=data-science-for-operational-excellence-part-4-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/QE2L8QjHzkY"></a></div>