Skip to content

Instantly share code, notes, and snippets.

@Ram-N
Created July 2, 2013 23:57
Show Gist options
  • Save Ram-N/5914345 to your computer and use it in GitHub Desktop.
Save Ram-N/5914345 to your computer and use it in GitHub Desktop.
# actual problem definition
lpff <- make.lp(nrow=n.row, ncol=n.col)
defineIP()
lpff
solve(lpff)
sol <- get.variables(lpff)
defineIP <- function() {
set.objfn(lpff, rep(1, n.col))
set.constr.type(lpff, const.type.vec, 1:n.row) #horiz, vert, corners
set.rhs(lpff, b=rhs.vector, constraints=1:n.row) # assign rhs values
#Set all the columns at once
for (col in 1:n.col) {
set.column(lpff, col, df[ ,col])
set.type(lpff, col, "binary")
}
#assemble it all
dimnames(lpff) <- setRowAndColNames()
write.lp(lpff, "flowfreeIP.lp", "lp")#write it out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment