用Octave计算二次规划问题
\(\frac{1}{2} x'×c×x+d'×x\)
\( s.t. \quad x ≥ 0 \)
 
广告
{{v.name}}
例子:
\( \min \quad \frac{1}{2} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix}' × \begin{bmatrix} 1 & 2 \\ 2 & 3 \end{bmatrix} × \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} + \begin{bmatrix} 4 \\ -5 \end{bmatrix}' × \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} \)
设\(x_0=\begin{bmatrix}0\\0\end{bmatrix}\),代码如下:
>> x0 = [0; 0];
定义矩阵 c,代码如下:
>> c = [1 2;
     2 3];
定义矩阵 d,代码如下:
>> d = [4; -5];
求解,代码如下:
>> [x, minval, exitflag, output, lambda] = pqpnonneg (c, d, x0)
x =

        0
   1.6667

minval = -4.1667
exitflag = 3
output =

  scalar structure containing the fields:

    algorithm = nnls-pqp
    iterations = 3

lambda =

  -7.3333
        0
友链