SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: lpSolve - Load data into matrix [ Reply ]
By: Arne Henningsen on 2014-09-13 04:51
[forum:41444]
Dear Mauro

Here is a simplified example that you can adjust to create the column names for your matrix::

paste( "S(", rep( LETTERS[1:4], each = 3 ), rep( LETTERS[24:26], 4 ), ")")

Please note that this forum is for the R-package "linprog" and not for the R-package "lpSolve".

Best regards,
Arne

lpSolve - Load data into matrix [ Reply ]
By: Mauro Rozenberg on 2014-09-11 13:08
[forum:41442]

VACAC_lpSolve.r (13) downloads
Hi all!
I'm new using R and lpSolve but I do have experience using other analytics and optimization software.
I think I'm doing fine but I have come up with a little problem.
My program optimizes the scheduling for different stores. It has variable size (variables and constrains) depending on the data that is read from a data base.
The difficulty that I met is that I can't find a way to name the variables and load the data into the LP model matrix without using a for loop which is not very .
Here's what I’m doing for the naming. Could you suggest me something better?

for (X in 1:QBlo) {
for (Y in 1:QSem) {
C <- C + 1
colnames(lpmodel)[C] <- paste("Salida(Leg:", unique(RR_bloque$LEG)[X], "_Bloq:", RR_bloque$SEM[X], "_Sem:", Suc_sem$SEM[Y], ")" , sep="")
set.type(lpmodel,C,"binary")
}
}

Attached is the complete programm.

Best,
MR

Thanks to:
Vienna University of Economics and Business Powered By FusionForge