matlab 程序改错
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/18 21:15:34
matlab 程序改错
clear
X=[26111 27463 65822 29476 16500 43502 52600 30067\x0544995.9\x0554700 46437 30701.7 36700 20808 123687;
96.7 61.98 171.01 84.57 35.14 108.3 164.99 67.98 120.56 139.15 118.26 67.83 64.93 59.70 279.71];
Y=[6796\x05 2622 15079 5165\x055040 25981 8037 9595 9150 26506\x0510165 3974 25971 6199 34951;
2477 4378 8315 3719\x051725 5606 6717 4056\x0510446 7042 8026\x054293 728 3461 1300];
Z=[ 4640 2950 \x056462 4618 3202 2915 1706 1977 4861 3212 3449 2452 3077 6530 11876;
18.5\x05 25.6\x05132.3\x0586.4\x0522.7\x0557.4 204.5\x0524.8\x05120.3\x0551.5\x05113.9\x0557.6\x0511\x05 44.2\x05 111.2;
2005\x052126.42\x052617.75\x05639.13\x051116.11\x051622.1\x051808.36\x05 916.404\x051236.78\x052728.01\x051262.43\x05 284.15\x052242.4\x05876.34\x055755.53];
D=X'; B=Y'; C=Z';
n=size(X',1);m=size(X,1) ; p=size(Y,1) ; s=size(Z,1) ;
epsilon=10^-10;
LB=epsilon*ones(m+s+p,1);
UB(m+s+p,1)=Inf;
A=[-D zeros(n,p) Z';
zeros(n,m) Y' -Z';
-D Y' zeros(n,s)]; b=zeros(3*n,1);
for i=1:n;
f=[zeros(1,m) -B(i,:) zeros(1,s)] ;
Aeq=[D(i,:) zeros(1,p) zeros(1,s)];
beq=1;
w(:,i)=linprog(f,A,b,Aeq,beq,LB,UB);
end
w
程序运行后 显示 Exiting due to infeasibility:6 lower bounds exceed the corresponding upper bounds.
求改错.数据矩阵的维数是没错的,估计是在上下限的地方出错了
clear
X=[26111 27463 65822 29476 16500 43502 52600 30067\x0544995.9\x0554700 46437 30701.7 36700 20808 123687;
96.7 61.98 171.01 84.57 35.14 108.3 164.99 67.98 120.56 139.15 118.26 67.83 64.93 59.70 279.71];
Y=[6796\x05 2622 15079 5165\x055040 25981 8037 9595 9150 26506\x0510165 3974 25971 6199 34951;
2477 4378 8315 3719\x051725 5606 6717 4056\x0510446 7042 8026\x054293 728 3461 1300];
Z=[ 4640 2950 \x056462 4618 3202 2915 1706 1977 4861 3212 3449 2452 3077 6530 11876;
18.5\x05 25.6\x05132.3\x0586.4\x0522.7\x0557.4 204.5\x0524.8\x05120.3\x0551.5\x05113.9\x0557.6\x0511\x05 44.2\x05 111.2;
2005\x052126.42\x052617.75\x05639.13\x051116.11\x051622.1\x051808.36\x05 916.404\x051236.78\x052728.01\x051262.43\x05 284.15\x052242.4\x05876.34\x055755.53];
D=X'; B=Y'; C=Z';
n=size(X',1);m=size(X,1) ; p=size(Y,1) ; s=size(Z,1) ;
epsilon=10^-10;
LB=epsilon*ones(m+s+p,1);
UB(m+s+p,1)=Inf;
A=[-D zeros(n,p) Z';
zeros(n,m) Y' -Z';
-D Y' zeros(n,s)]; b=zeros(3*n,1);
for i=1:n;
f=[zeros(1,m) -B(i,:) zeros(1,s)] ;
Aeq=[D(i,:) zeros(1,p) zeros(1,s)];
beq=1;
w(:,i)=linprog(f,A,b,Aeq,beq,LB,UB);
end
w
程序运行后 显示 Exiting due to infeasibility:6 lower bounds exceed the corresponding upper bounds.
求改错.数据矩阵的维数是没错的,估计是在上下限的地方出错了
如果没有上限不用定义为无穷大的,默认就是没有上限,调用linprog时不要写即可
w(:,i)=linprog(f,A,b,Aeq,beq,LB);
w(:,i)=linprog(f,A,b,Aeq,beq,LB);