2013-04-13 13 views
6

線形計画モデルを解くための素敵なRパッケージを探しています。私はデフォルトのlpSolve::lpにはとても満足していますが、の影と価格をにする方法はありません。私はこれらを統合性の制約とともに必要としています。R線形計画問題を解決するため

サンプルモデル:

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

+0

@Arunこれはデュアル変数です。http://en.wikipedia.org/wiki/Shadow_price – mreq

+2

を参照してください。[** this documentation **](http://cran.r-project.org/web/packages/lpSolve/lpSolve.pdf)は制約のための '二重の値'について話します。これはあなたが探しているものですか? – Arun

答えて

3

としては、コメントの下でこのことについてpage 4 of the documentation会談を述べました。ドキュメントの抜粋は次のとおりです。

# 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 
+2

について知りませんでした:キーは' compute.sens = TRUE'です – mreq

関連する問題