如何在 R 中使用 Lpsolve 检索优化的 objective 函数中的变量值

how to retrieve values of variables in the optimised objective function using Lpsolve in R

我正在尝试在优化的 objective 函数中找到 x 和 y 的值。 这是我使用的寻找最佳值的代码

objective.in=c(6.55,7.9)
const.mat=matrix(c(0.25,0,0.25,0.5,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,0.25,0.5,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() returns.

对象中可用内容的更多信息