【问题标题】:ROI package doesn't give a solution (qpoases solver) for an unconstrained QPROI 包没有为不受约束的 QP 提供解决方案(qpoases 求解器)
【发布时间】:2019-03-01 18:35:41
【问题描述】:

我正在设置一个简单的 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 切换到 qpoases。

非常感谢任何帮助。

编辑:

奇怪的是,这行得通,

> 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

【问题讨论】:

  • 似乎这应该发给包维护者(在确保您的规范中不存在可行域之外的初始值等典型错误之后。)

标签: r optimization quadratic-programming quadprog r-optimization


【解决方案1】:

如果参数 hessian_type 不是由 用户 ROI.plugin.qpoases 选择hessian_type。并且由于一个 为它选择的第一个示例选择粗麻布类型的错误 对于第一个示例,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)

这在新版本中已修复,新版本正在前往 CRAN 的路上。

【讨论】:

  • 优秀。谢谢@Florian
猜你喜欢
  • 1970-01-01
  • 2019-08-27
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-04
相关资源
最近更新 更多