Created
July 10, 2019 11:11
-
-
Save Harshit1694/3cc4a709d9057ba71c7e55c456bf0878 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("lpSolve") | |
library(lpSolve) | |
#Setting the coefficients of decision variables | |
objective.in=c(25,20) | |
#Constraint Matrix | |
const.mat=matrix(c(20,12,5,5),nrow = 2,byrow = T) | |
#defining constraints | |
const_time=540 #in minutes | |
const_res=2000 | |
#RHS for constraints | |
const.rhs=c(const_res,const_time) | |
#Direction for constraints | |
const.dir=c("<=","<=") | |
#Finding the optimum solution | |
opt=lp(direction = "max",objective.in,const.mat,const.dir,const.rhs) | |
summary(opt) | |
#Objective values of x and y | |
opt$solution | |
#Value of objective function at optimal point | |
opt$objval |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment