用 R 解决线性规划问题

7
我正在寻找一个好用的R包来解决线性规划模型。我对默认的lpSolve::lp非常满意,但是无法获取影子价格和降低的价格。我需要这些东西,以及完整性约束。
示例模型:
A = rbind(
    c(0.5, 0.2, 0.2),
    c( -1,   1,   0),
    c(  0,   1,  -1),
    c( -1,  -1,  -1),
    c( -1,   0,   0),
    c(  0,  -1,   0),
    c(  0,   0,  -1)
)
b = c(5, 0, 0, -13, 0, 0, 0)
c_ = c(8.4, 6, 9.2)
(signs = c('=', rep('<=', 6)))

res = lpSolve::lp('min', c_, A, signs, b,  all.int = TRUE)

# Objective function
res
# Variables
res$solution

# Shadow prices???
# Reduced prices???

1
抱歉,什么是阴影和降价? - Arun
@Arun 这是一个双重变量 - 请参见http://en.wikipedia.org/wiki/Shadow_price - mreq
2
这份文档的第4页讨论了用于约束条件的“对偶值”。这是你正在寻找的内容吗? - Arun
@Arun 是的,就是那个。回答一下,我会接受它的。 - mreq
2个回答

4

4

如评论中所述,文档的第4页讨论了这个问题。以下是文档的摘录:

# Get sensitivities
lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$sens.coef.from
## Not run: [1] -1e+30 2e+00 -1e+30
lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$sens.coef.to
## Not run: [1] 4.50e+00 1.00e+30 1.35e+01

# Right now the dual values for the constraints and the variables are
# combined, constraints coming first. So in this example...

lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$duals
## Not run: [1] 4.5 0.0 -3.5 0.0 -10.5

# ...the duals of the constraints are 4.5 and 0, and of the variables,
# -3.5, 0.0, -10.5. Here are the lower and upper limits on these:

lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$duals.from
## Not run: [1] 0e+00 -1e+30 -1e+30 -1e+30 -6e+00
lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$duals.to
## Not run: [1] 1.5e+01 1.0e+30 3.0e+00 1.0e+30 3.0e+00

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接