代码之家  ›  专栏  ›  技术社区  ›  Taran

ROI包没有为不受约束的QP提供解决方案(QPOASES解算器)。

  •  0
  • Taran  · 技术社区  · 7 年前

    我正在设置一个简单的QP来测试ROI R包。然而,当一个简单的玩具问题是不受约束的时候,包装不能给出一个错误的解决方案。

    例子,

    # Maximize -1/2 x^2 + x, no constraints
    > x <- OP(Q_objective(as.matrix(-1), 1), maximum = TRUE, bounds = V_bound(lb = -Inf, ub = Inf, nobj = 1))
    > x
    > ROI Optimization Problem:
    
      Maximize a quadratic objective function of length 1 with
      - 1 continuous objective variable,
    
      subject to
      - 0 constraints
      - 1 lower and 0 upper non-standard variable bounds.
    

    看起来不错。但当我解决问题时,

    > sol <- ROI_solve(x, solver = 'qpoases')
    > sol
      No optimal solution found.
      The solver message was: Initialisation failed! QP could not be solved!
      The objective value is: 0.000000e+00
    > sol$solution
      [1] 0
    > sol$objval
      [1] 0
    > sol$status
      $code
      [1] 1
    
      $msg
       solver qpoases
        code 36
       symbol RET_INIT_FAILED_HOTSTART
       message Initialisation failed! QP could not be solved!
       roi_code 1
    

    真奇怪。一个相关的说明是,当我使用Quadprog解算器时,我能够得到无约束的解(=1),但是由于其他原因,我不得不从使用Quadprog切换到使用Qpoas。

    任何帮助都非常感谢。

    编辑:

    奇怪的是,这很管用,

    > ROI_solve(OP(Q_objective(as.matrix(-1), 1), maximum = TRUE), solver = 'qpoases')
      No optimal solution found.
      The solver message was: Initialisation failed! QP could not be solved!
      The objective value is: 0.000000e+00
    > ROI_solve(OP(Q_objective(as.matrix(1), -1), maximum = FALSE), solver = 'qpoases')
      Optimal solution found.
      The objective value is: -5.000000e-01
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Florian    7 年前

    这个不同的结果来自参数中设置的不同值 hessian_type 如果论点 黑森阶型 不是由提供的 用户roi.plugin.qpoases选择 黑森阶型 。由于一个 为它选择的第一个示例选择hessian类型时出现错误 第一个例子是 hessian_type = 6 (未知)第二次 正确的 hessian_type = 1 身份。

    x1 <- OP(Q_objective(as.matrix(-1), 1), maximum = TRUE, bounds = NULL)
    s1 <- ROI_solve(x1, solver = 'qpoases', hessian_type = 1L)
    solution(s1)
    
    x1 <- OP(Q_objective(as.matrix(-1), 1), maximum = TRUE, bounds = NULL)
    s1 <- ROI_solve(x1, solver = 'qpoases', hessian_type = 6L)
    solution(s1)
    

    这在新版本中是固定的,新版本正在去克兰的路上。