Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sangamc/3ed2a4d0d08d61c13a8f9dc492ecfead to your computer and use it in GitHub Desktop.
Save sangamc/3ed2a4d0d08d61c13a8f9dc492ecfead to your computer and use it in GitHub Desktop.
library(lpSolve)
preds$team <-as.character(preds$team)
obj = preds$prediction
con <- rbind(t(model.matrix(~ FD.Position + 0,preds)), t(model.matrix(~ team + 0, preds)), rep(1,nrow(preds)), preds$Salary)
dir <- c(">=",">=",">=",">=",">=",rep('<=',length(unique(preds$team))),"<=","<=")
rhs <- c(1,2,2,2,2,rep(4,length(unique(preds$team))),9,60000)
result = lp("max", obj, con, dir, rhs, all.bin = TRUE)
preds[which(result$solution == 1),]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment