问题描述
我正在尝试在优化的目标函数处找到x和y的值。 这是找到我使用的最优值的代码
objective.in=c(6.55,7.9)
const.mat=matrix(c(0.25,0.25,0.5,0.5),nrow=3,byrow = TRUE)
const.dir<-c("<=","<=","<=")
const.rhs<-c(500,200,200)
lp("max",objective.in,const.mat,const.dir,const.rhs)
解决方法
> library(lpSolve)
> objective.in=c(6.55,7.9)
> const.mat=matrix(c(0.25,0.25,0.5,0.5),nrow=3,byrow = TRUE)
> const.dir<-c("<=","<=","<=")
> const.rhs<-c(500,200,200)
> res<-lp("max",objective.in,const.mat,const.dir,const.rhs)
> res$objval
[1] 3160
使用?lp.object
查找有关lp()
返回的对象中可用内容的更多信息。