R:定义优化问题构造函数OP(包ROI)的边界。UseMethod中的错误(“as.V”bound)

R:定义优化问题构造函数OP(包ROI)的边界。UseMethod中的错误(“as.V”bound),r,optimization,r-optimization,R,Optimization,R Optimization,我想在使用ROI包进行优化时为变量定义边界。我使用OP函数来构造优化问题对象 默认值为:下限等于零,上限等于+无穷大 下面是一个运行良好的示例代码: LP <- OP( c(2, 4, 3), L_constraint(L = matrix(c(3, 2, 1, 4, 1, 3, 2, 2, 2), nrow = 3), dir = c("<=", "<=", "<="), rhs =

我想在使用ROI包进行优化时为变量定义边界。我使用OP函数来构造优化问题对象

默认值为:下限等于零,上限等于+无穷大

下面是一个运行良好的示例代码:

LP <- OP( c(2, 4, 3),
      L_constraint(L = matrix(c(3, 2, 1, 4, 1, 3, 2, 2, 2), nrow = 3),
                   dir = c("<=", "<=", "<="),
                   rhs = c(60, 40, 80)),
      max = TRUE )
LP
LP
LP <- OP( c(2, 4, 3),
      L_constraint(L = matrix(c(3, 2, 1, 4, 1, 3, 2, 2, 2), nrow = 3),
                   dir = c("<=", "<=", "<="),
                   rhs = c(60, 40, 80)),
                    bounds = list(upper=c(100,100,100), lower=c(0,0,0)),
      max = TRUE )

Error in UseMethod("as.V_bound") : 
no applicable method for 'as.V_bound' applied to an object of class "list"
LP <- OP(c(2, 4, 3),
         L_constraint(L = matrix(c(3, 2, 1, 4, 1, 3, 2, 2, 2), nrow = 3),
                      dir = c("<=", "<=", "<="),
                      rhs = c(60, 40, 80)),
         bounds = V_bound(ui = seq_len(3), ub = rep.int(100, 3)),
         maximum = TRUE )