R矩阵形式的二次编程

时间:2018-09-07 19:36:43

标签: r quadratic-programming

我正在使用nativeptr<type>软件Renter image description here

解决以下优化问题:

quadprog

我从解决上述问题中得到的解决方案是:

Dmat <- matrix(c(1,1.5,1.5,5),nrow=2,ncol=2)
dvec <- c(0.5,0)
Amat <- -matrix(c(3,15,2,-3),nrow=2,ncol=2)
bvec <- matrix(c(-2,1),nrow=2,ncol=1)

solve.QP(Dmat,dvec,Amat,bvec)

正确的解决方法是

$`solution`
[1] -0.2307692  0.1794872

$value
[1] 0.1604208

我在做什么错?

1 个答案:

答案 0 :(得分:1)

您必须:

  • public abstract class ActionTaken : MonoBehaviour { public char type; public Transform minionTakingAction; } public class MovementTaken : ActionTaken { public int targetTileH; public int targetTileV; public MovementTaken(Transform _minionTakingAction, int _targetTileH, int _targetTileV) { type = 'M'; minionTakingAction = _minionTakingAction; targetTileH = _targetTileH; targetTileV = _targetTileV; } } Queue<ActionTaken> actionTaken; public void activateMovement(ActionTaken toActivate) {//some code using toActivate's members targetTileH and targetTileV}
  • 取反Dmat
  • 转置dvec
  • 取反Amat

也就是说:

bvec

Dmat <- matrix(c(2,3,3,10),nrow=2,ncol=2)
dvec <- c(-0.5,0)
Amat <- -matrix(c(3,15,2,-3),nrow=2,ncol=2,byrow=TRUE)
bvec <- -matrix(c(-2,1),nrow=2,ncol=1)