2013-04-13 22 views
6

Sto cercando un bel pacchetto R per risolvere i modelli di programmazione lineare. Sono abbastanza contento del valore predefinito lpSolve::lp, ma non c'è modo di ottenere l'ombra e i prezzi ridotti. Ho bisogno di questi, insieme ai vincoli di integralità.R per risolvere problemi di programmazione lineare

modello Esempio:

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

Siamo spiacenti, quali sono le ombre e i prezzi ridotti? – Arun

+0

@Arun è una variabile doppia - vedi http://en.wikipedia.org/wiki/Shadow_price – mreq

+2

Page 4 in [** questa documentazione **] (http://cran.r-project.org/web/packages /lpSolve/lpSolve.pdf) parla di "valori doppi" per i vincoli. E 'questo quello che stai cercando? – Arun

risposta

3

Come detto in commenti, page 4 of the documentation parla di questo. Ecco un estratto dalla documentazione:

# 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

per i futuri lettori: la chiave è' compute.sens = TRUE' – mreq

Problemi correlati