工业工程师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.
运筹学是一种决策的科学方法,通常在需要分配稀缺资源或有限资源的条件下,寻求系统的最佳设计和运行。 科学的决策方法要求使用一个或多个数学优化模型(即,实际情况的表示)来做出最佳决策。
项目选择 (Project Selection)
Capital budgeting and investment planning are used to analyze the profitability of a projected investment or project, and thus, to determine those worth pusuing. For these decision, time value of money (a concept that money you have now is worth more than the identical sum in the future due to its potential earning capacity) must be considered.
资本预算和投资计划用于分析预计投资或项目的盈利能力,从而确定值得追求的收益。 对于这些决策,必须考虑货币的时间价值(概念是,由于其潜在的赚钱能力,您现在拥有的金钱比将来的总价值还多)。
Ideally, the selected projects should be those that yield the highest net present values (i.e. the difference between the present value of cash inflows and the present value of cash outflows over a period of time). However, there might be budgeting constraints that could limit the selection of all the most profitable projects. For that reason, their selection must be optimized.
理想情况下,选定的项目应该是那些产生最高净现值的项目(即一段时间内现金流入的现值和现金流出的现值之差)。 但是,可能存在预算限制,可能会限制所有最有利可图的项目的选择。 因此,必须对其选择进行优化。
Project selection problems can be analyzed and solved using binary integer programming algorithms, where selected projects would take a value of 1 and those not selected a value of 0.
可以使用二进制整数编程算法来分析和解决项目选择问题,其中所选项目的值为1,未选择项目的值为0。
The lpSolve package from R contains several functions for solving integer programing problems. For the following example, let’s consider the following business case related with project selection:
来自R的lpSolve软件包包含一些函数,用于解决整数编程问题。 对于以下示例,让我们考虑与项目选择相关的以下业务案例:
A company is interested in investing in multiple projects for the next four years. However, the company has limited budget for each year as shown on the table below:
一家公司有兴趣在未来四年内投资多个项目。 但是,该公司每年的预算有限,如下表所示:

In addition to the capital constraints, there are 4 additional constraints to be taken into consideration:
除了资金限制外,还需要考虑4个其他限制:
- Projects 4 and 5 are mutually exclusive 项目4和5是互斥的
- Maximum 4 projects can be selected最多可以选择4个项目
- Project 4 depends on project 2项目4取决于项目2
- Projects 1 and 3 must go together 项目1和3必须一起去
Questions to be answered:
有待回答的问题:
- What combination of projects will maximize the net present value? 项目的哪些组合将使净现值最大化?
- Which is the maximum expected net present value that can be achieved? 可以达到的最大预期净现值是多少?
Decision Variables:
决策变量:

Problem Formulation:
问题表述:

R Code:
R代码:
# Import lpSolve package
library(lpSolve)
# Set coefficients of the objective function
f.obj <- c(2, 3, 1, 5, 4)
# Set matrix corresponding to coefficients of constraints by rows
f.con <- matrix(c(3, 0, 1, 10, 2, # capital limit year #1
0, 5, 2, 4, 0, # capital limit year #2
0, 1, 1, 2, 5, # capital limit year #3
0, 0, 2, 0, 1, # capital limit year #4
0, 0, 0, 1, 1, # projects 4 and 5 mutually exclusive
1, 1, 1, 1, 1, # maximum of 4 projects accepted
0, -1, 0, 1, 0, # project 4 depends on project 2
1, 0, -1, 0, 0), # project 1 and project 3 go together
nrow = 8, byrow = TRUE)
# Set unequality signs
f.dir <- c(rep("<=", 7), "=")
# Set right hand side coefficients
f.rhs <- c(12, 8, 8, 4, 1, 4, 0, 0)
# Final value (z)
lp("max", f.obj, f.con, f.dir, f.rhs, int.vec = 1:5, all.bin = TRUE)
# Variables final values
lp("max", f.obj, f.con, f.dir, f.rhs, int.vec = 1:5, all.bin = TRUE)$solution
Solution:
解:
Success: the objective function is 10
x1 x2 x3 x4 x5
1 1 1 0 1
According to the results, the maximum Net Present Value in millions that could be obtained is $10 millions by selecting projects 1, 2, 3 and 5.
根据结果,通过选择项目1、2、3和5,可获得的以百万计的最大净现值是1000万美元。
结论思想 (Concluding Thoughts)
Projects selection can be optimized through operation research algorithms to maximize expected net present values. The lpSolve R package allows solving capital budgeting and investment planning with just a few lines of code through binary integer programming.
可以通过运筹学算法来优化项目选择,以最大化预期的净现值。 lpSolve R软件包允许通过二进制整数编程仅用几行代码来解决资本预算和投资计划。
Managers, investors and engineers must be capable of optimizing the selection of projects to ensure high levels of profitability and discounted cash inflows while not exceeding the given budgets and the organization’s objectives. To do so, they must have reliable and robust decision support systems and use efficient decision making tools.
经理,投资者和工程师必须能够优化项目的选择,以确保高水平的获利能力和现金流量折扣,同时又不超过给定的预算和组织的目标。 为此,他们必须拥有可靠且强大的决策支持系统并使用有效的决策工具。
— —
— —
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/project-selection-with-r-cd3f676aa158