在matlab中设置约束

时间:2013-10-25 18:35:36

标签: matlab

我有以下问题:

权重矢量= [0.05,0.05,0.15,0.05,0.22,0.08,0.4]

权重向量标题= [A11,A12,A21,A22,A31,A32,B1]我有以下约束

0≤A11+ A12 + A21 + A22 + A31 +A32≤0.3

0≤B1≤0.8

A11 + A12 = A21 + A22 = A31 + A32

A11 + A12 + A21 + A22 + A31 + A32 + B1 = 1

我希望最小化与上述约束条件下原始权重向量的平方差之和

如何在MATLAB中的quadprog中指定约束?

抱歉没有格式化,我对堆栈溢出相当新

以下是一些示例基本代码

weights.data = [0.05 0.05 0.15 0.05 0.22 0.08 0.4]
weights.header = {'A11', 'A12', 'A21', 'A22', 'A31', 'A32', 'B1'}
w0 = weights.data
Constraints = [
    1 0 1
    1 0 1
    1 0 1
    1 0 1
    1 0 1
    1 0 1
    0 1 1

    ]

ub = [0.3 0.8 1]
lb = [0 0 1]

A0 = Constraints;

%%Inequality constraints
A_le = [-A0, A0]'; % lower bound first
b_le = [-lb, ub];
n = 7

[solution, fval, exitflag,output] = quadProg(eye(n), -w0', A_le,b_le,[],[],[],[],w0, options);













Thanks for your help!

0 个答案:

没有答案