尝试看起来很有前途的CVXR软件包。从最小化到最大化时面临一个问题:
library(CVXR)
# Variables to maximize over
x <- Variable(1)
y <- Variable(1)
# Problem definition
objective <- Maximize(0.34*x^2 + 1*x + 0.76*y^2 + 1*y)
constraints <- list(x + y >= 1, x >= 0, y >= 0)
prob <- Problem(objective, constraints)
# Problem solution
solution2.1 <- solve(prob)
solution2.1$status
solution2.1$value
当我使用minimize()
时,solve()
有效,但当更改为maximize()
时,我收到错误:Problem does not follow DCP rules.
任何人都知道这个问题的原因是什么以及如何解决?