rstudio下 使用 r_使用R优化生产计划

rstudio下 使用 r

工业工程师R (R for Industrial Engineers)

行动调查 (Operations Research)

Operations Research is a scientific approach for decision making that seeks for the best design and operation of a system, usually under conditions requiring the allocation of scarce or limited resources. The scientific approach for decision making requires the use of one or more mathematical optimization models (i.e. representations of the actual situation) to make the optimum decision.

运筹学是一种决策的科学方法,通常在需要分配稀缺资源或有限资源的条件下,寻求系统的最佳设计和运行。 科学的决策方法要求使用一个或多个数学优化模型(即,实际情况的表示)来做出最佳决策。

Operations Research techniques are widely applied to optimize problems in multiple fields, including production planning and scheduling, facility location, supply chain, finance, marketing, transportation, and healthcare.

运筹学技术被广泛应用于优化多个领域的问题,包括生产计划和调度,设施位置,供应链,财务,营销,运输和医疗保健。

整数编程 (Integer Programming)

Integer programming (also referred as IP) is an operations research technique used when (typically) all the objectives and constraints are linear (in the variables) and when all the decision variables are integer.

整数编程(也称为IP)是一种运筹学技术,当(通常)所有目标和约束都是线性的(在变量中)并且所有决策变量都是整数时

Interested in learning more about the fundamental of operations research and linear programming? Feel free to check out the following article:

有兴趣了解更多有关运筹学和线性编程基础知识的信息吗? 随时查看以下文章:

The lpSolve package from R contains several functions for solving integer programming problems and getting significant statistical analysis. For the following example, let’s consider the following business case related with production planning:

来自R的lpSolve软件包包含几个函数,用于解决整数编程问题并获得重要的统计分析。 对于以下示例,让我们考虑以下与生产计划相关的业务案例:

A manufacturing company produces four different products. Each product can be made by two different methods. The manual method requieres work in fabrication, assesmbly, and test departments, while the automated method combines the assembly and test operations in one department.

一家制造公司生产四种不同的产品。 每种产品可以通过两种不同的方法制造。 手动方法需要制造,装配和测试部门的工作,而自动化方法则将装配和测试操作合并到一个部门中。

The table below describes the price and cost features of the products, along with marketing information on the range of possible sales in the coming month. Becuase Product 1 is delivered to one large retailer under a long-term contract, a threshold demand quantity of 1,500 units must be met. For the other products, there is flexibility in how much demand to meet, up to a ceiling that represents the maxim possible sales.

下表描述了产品的价格和成本特征,以及有关下个月可能销售范围的营销信息。 由于产品1是根据长期合同交付给一个大型零售商的,因此必须满足1,500个单位的最低需求量。 对于其他产品,可以灵活满足需要的数量,最高限额代表最大可能的销售额。

Image for post

On the other hand, the following table provides data on the various departments at the firm, consisting of the time per product required on each department and the number of hours available in each department during the month.

另一方面,下表提供了公司各个部门的数据,包括每个部门每个产品所需的时间以及一个月中每个部门的可用小时数。

Image for post

Questions to be answered:

有待回答的问题:

  • What production plan will maximize profit for the company?

    哪种生产计划将使公司获得最大利润?
  • What is the maximum profit that can be obtained for the following month?

    下个月可获得的最大利润是多少?

Decision Variables:

决策变量:

Image for post

Problem Formulation:

问题表述:

Image for post

R Code:

R代码:

# Import lpSolve package
library(lpSolve)


# Set coefficients of the objective function
f.obj <- c(15, 25, 15, 63, 45, 50, 10, 45)


# Set matrix corresponding to coefficients of constraints by rows
f.con <- matrix(c(1, 1, 0, 0, 0, 0, 0, 0,     # demand product 1 upper bound
                  1, 1, 0, 0, 0, 0, 0, 0,     # demand product 1 lower bound
                  0, 0, 1, 1, 0, 0, 0, 0,     # demand product 2
                  0, 0, 0, 0, 1, 1, 0, 0,     # demand product 3
                  0, 0, 0, 0, 0, 0, 1, 1,     # demand product 4
                  3, 0, 5, 0, 4, 0, 4, 0,     # manual fabrication
                  8, 0, 12, 0, 10, 0, 9, 0,   # manual assembly
                  2, 0, 3, 0, 5, 0, 2, 0,     # manual test
                  0, 5, 0, 6, 0, 7, 0, 4,     # automatic fabrication
                  0, 4, 0, 5, 0, 8, 0, 5),    # automatic assembly/test
                nrow = 10, byrow = TRUE)


# Set unequality signs
f.dir <- c("<=", ">=", "<=", "<=", "<=", "<=", "<=", "<=", "<=", "<=")


# Set right hand side coefficients
f.rhs <- c(3000, 1500, 2500, 2000, 3200, 16000, 30000, 15000, 24000, 20000)


# Final value (z)
lp("max", f.obj, f.con, f.dir, f.rhs, all.int = TRUE)


# Variables final values
lp("max", f.obj, f.con, f.dir, f.rhs, all.int = TRUE)$solution

Solution:

解:

Success: the objective function is 331000 


# x11 x12  x21  x22  x31  x32  x41  x42
1250  250    0 2500 2000    0    0 1300

According to the results, the maximum profit that can be obtained for the following month is $331,000. To achieve this, 1250 units of product 1 must be manually manufactured and 250 units automatically manufactured, 2500 units of product 2 must be automatically manufactured, 2000 units of product 3 must be manually manufactured, and 1300 units of product 4 must be automatically manufactured.

根据结果​​,下个月可以获得的最大利润为$ 331,000。 为此,必须手动制造1250件产品1,并自动制造250件产品,必须自动制造2500件产品2,必须手动制造2000件产品3,并且必须自动制造1300件产品4。

结论思想 (Concluding Thoughts)

Integer programming represents another great optimization technique for better decision making that can be applied for production planning and sccheduling. The lpSolve R package allows to solve integer programming problems with just a few lines of code.

整数编程代表了另一种出色的优化技术,可用于更好地制定决策,该技术可用于生产计划和计划编制。 lpSolve R软件包仅需几行代码即可解决整数编程问题。

— —

— —

If you found this article useful, feel welcome to download my personal codes on GitHub. You can also email me directly at rsalaza4@binghamton.edu and find me on LinkedIn. Interested in learning more about data analytics, data science and machine learning applications in the engineering field? Explore my previous articles by visiting my Medium profile. Thanks for reading.

如果您觉得本文有用,欢迎在 GitHub上 下载我的个人代码 您也可以直接通过rsalaza4@binghamton.edu向我发送电子邮件,并在 LinkedIn 上找到我 有兴趣了解更多有关工程领域中的数据分析,数据科学和机器学习应用程序的信息吗? 通过访问我的Medium 个人资料 来浏览我以前的文章 谢谢阅读。

- Robert

-罗伯特

翻译自: https://medium.com/swlh/production-planning-optimization-with-r-48b225fcd06e

rstudio下 使用 r

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值