as.m
来自「清华大学运筹学课件」· M 代码 · 共 47 行
M
47 行
% AS.m
%This program solves Quadratic Programming by using Active Set algorithm.
%n=input('Enter the dimension number of the variable: n= ')
%ME=input('Enter the number of the equality constraints: me= ')
%MI=input('Enter the number of the unequality constraints: mi= ')
H=input('Enter the matrix: H= ')
g=input('Enter the coefficient: g= ')
AM=input('Enter the coefficient matrix of equality constraints: Am= ')
bM=input('Enter the coefficient of equality constraints: bm= ')
AI=input('Enter the coefficient matrix of unequality constraints: Ai= ')
bI=input('Enter the coefficient matrix of unequality constraints: bi= ')
x=f_feasiblesolution(AM,bM,AI,bI); %find the first feasible solution
%find the set I(x) and A(x)=S
S=AM;
for i=1:MI
if (AI*x-bI)(i)==0 S=[S;AI(i)]; end
end
%solve d and y
d=-inv(H)*(g+H*x)+inv(H)*S'*inv(S*inv(H)*S')*(S*inv(H)*(g+H*x));
y=inv(S*inv(H)*S')*(S*inv(H)*(g+H*x));
%step3
if d==0 and y>=0 break
elseif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?