0

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

默认值为:下限等于 0,上限等于 +infinity。

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

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 <- 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"

但是描述说“边界”需要一个列表作为输入。

有没有人知道如何正确地将边界传递给 OP 函数?

4

1 回答 1

1
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 )
于 2017-06-13T17:20:20.700 回答