📄 as.m
字号:
% 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -