z is a sdpvar varible. When z and value(z) are used as function inputs, sub_0 returns different f2. I know why this is the case.
PLease give me help.
master_0:
function [y,z,f,eta]=master_0()
y=binvar(3,1);%表示是否在i地建设仓库
z=sdpvar(3,1);%表示仓库i储存的商品数量
eta=sdpvar(1,1);%表示第二阶段目标函数最大值
x=sdpvar(3,3,'full');%表示仓库i到j客户运送的商品数量
c=[22 33 24;33 23 30;20 25 27];%表示从i仓库到j客户运送商品的单位成本
C=[];
C=C+[z>=0];
C=C+[eta>=0];
for i=1:3
C=C+[z(i,1)<=800*y(i,1)];
end
C=C+[sum(z)>=772];
for i=1:3
for j=1:3
C=C+[x(i,j)>=0];
end
end
C=C+[eta>=sum(sum(c.*x))];
f=[400 414 326]*y+[18,25,20]*z+eta;
ops=sdpsettings('solver','gurobi');
result=optimize(C,f,ops);
sub_0:
function [x,d,g,f]=sub_0(z)
x=sdpvar(3,3,'full');%表示仓库i到j客户运送的商品数量
d=sdpvar(3,1);%表示j客户的需求
g=sdpvar(3,1);%表示客户需求波动比例(客户需求最大波动40)
pi=sdpvar(3,1);%对偶变量
theta=sdpvar(3,1);%对偶变量
v=binvar(3,1);%二进制辅助变量
w=binvar(3,1);%二进制辅助变量
% for i=1:3
% for j=1:3
% h(i,j)=binvar(1);
% end
% end
h=binvar(3,3,'full');%二进制辅助变量
M=100000;
c=[22 33 24;33 23 30;20 25 27];%表示从i仓库到j客户运送商品的单位成本
d_=[206,274,220]';%表示客户i的固定需求(预测值)
%[y,z]=master_0();
C=[];
C=C+[pi<=0];
C=C+[theta<=0];
C=C+[d>=0];
for i=1:3
C=C+[g(i)<=1];
C=C+[g(i)>=0];
end
for i=1:3
for j=1:3
C=C+[x(i,j)>=0];
end
end
for i=1:3
C=C+[x(i,1)+x(i,2)+x(i,3)<=z(i)];
end
for j=1:3
C=C+[x(1,j)+x(2,j)+x(3,j)>=d(j)];
end
for i=1:3
for j=1:3
C=C+[pi(i)-theta(j)<=c(i,j)];
end
end
for j=1:3
C=C+[d(j)==d_(j)+g(j)*40];
end
C=C+[g(1)+g(2)+g(3)<=1.8];
C=C+[g(1)+g(2)<=1.2];
for i=1:3
C=C+[-pi(i)<=M*v(i)];
end
for i=1:3
C=C+[z(i)-x(i,1)-x(i,2)-x(i,3)<=M-M*v(i)];
end
for j=1:3
C=C+[-theta(j)<=M*w(j)];
end
for j=1:3
C=C+[x(1,j)+x(2,j)+x(3,j)-d(j)<=M-M*w(j)];
end
for j=1:3
for i=1:3
C=C+[x(i,j)<=M*h(i,j)];
C=C+[c(i,j)-pi(i)+theta(j)<=M-M*h(i,j)];
end
end
f=0;
for i=1:3
for j=1:3
f=f+c(i,j)*x(i,j);
end
end
%ops=sdpsettings('solver','gurobi','gurobi.TuneTimeLimit',0,'gurobi.ResultFile','iu.lp');
ops=sdpsettings('solver','gurobi');
result=optimize(C,-f,ops);
The main function is as follow:
z is a sdpvar varible. When z and value(z) are used as function inputs, sub_0 returns different f2. I know why this is the case. PLease give me help. master_0:
sub_0: