Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. install.packages("lpSolve")
  2. library(lpSolve)
  3.  
  4.  
  5.  
  6. #Setting the coefficients of decision variables
  7. objective.in=c(25,20)
  8.  
  9. #Constraint Matrix
  10. const.mat=matrix(c(20,12,5,5),nrow = 2,byrow = T)
  11.  
  12. #defining constraints
  13. const_time=540 #in minutes
  14. const_res=2000
  15.  
  16. #RHS for constraints
  17. const.rhs=c(const_res,const_time)
  18.  
  19. #Direction for constraints
  20. const.dir=c("<=","<=")
  21.  
  22.  
  23. #Finding the optimum solution
  24. opt=lp(direction = "max",objective.in,const.mat,const.dir,const.rhs)
  25. summary(opt)
  26.  
  27.  
  28. #Objective values of x and y
  29. opt$solution
  30.  
  31. #Value of objective function at optimal point
  32. opt$objval
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement