I have formulated a subproblem based on an uncertainty set defined by d. It is a robust optimization problem. I have a confusion that should I include d as a variable and impose equality constraint or put it as expression. However I know for sure that d is an optimization variable. Also when I input some optimal value z* from Master problem the value of g turns negative.
m = 3; % Number of facility locations
n = 3; % Number of customers
%Fixed cost of the building facilities at site i, f(i)
f = [400; 414; 326];
%Unit capacity cost a(i), i = 1,....,m
a = [18; 25; 20];
%Unit transportation cost c(ij), i = 1,....,m; j = 1,....,n
c = [22 33 24; 33 23 30; 20 25 27];
%Forecast demand df(j)
df = [206; 274; 220];
%Maximal demand deviation dm(j)
dm = [40; 40; 40];
%Capacity variable z*(i) , obtained from master problem
zo_set = [772; 0; 0];
lb = zeros(3,1); ub = ones(3,1);
for i = 1:m
for j = 1:n
M1(i,j) = min(df(j)+dm(j),zo_set(i)); %M1(i,j) == min(df(j)+dm(j),zo(i)) for every i,j
end
end
for i = 1:m
M2(i) = max(c(i,:)) %M2(i) == max(c(i,j)) for every i
end
for j = 1:n
M3(j) = max(c(:,j)) %M3(j) == max(c(i,j)) for every j
end
cvx_begin
cvx_solver gurobi
variable x(3,3) nonnegative;
variable u(3) nonnegative;
variable v(3) nonnegative;
variable p(3,3) binary;
variable q(3) binary;
variable r(3) binary;
variable d(3);
variable g(3);
objS = sum(sum(c.*x));
maximize (objS);
subject to
%Demands calculated by introducing uncertainty
d == df + g .* dm;
sum(g) <= 1.8;
g(1)+ g(2)<= 1.2 ;
g(:) >= lb; g(:) <= ub;
%Capacity Constraints (Primal feasibilty)
for i= 1:m
sum(x(i,:)) <= zo_set(i);
end
% Demand Constraints (Primal feasibilty)
for j= 1:n
sum(x(:,j)) >= d(j)
end
% Dual feasibility Constraints
for i = 1:m
for j = 1:n
v(j) - u(i) <= c(i,j)
end
end
%M1 constraints
for i = 1:m
for j = 1:n
x(i,j) <= M1(i,j) .* p(i,j)
end
end
for i = 1:m
for j = 1:n
c(i,j) - v(j) + u(i) <= (c(i,j) + M2(i)) .* (1 - p(i,j))
end
end
% M3 constraints
for j = 1:n
v(j) <= M3(j).* q(j)
end
for j = 1:n
sum(x(:,j)) - d(j) <= dm(j) .* (1 - q(j))
end
% M2 constraints
for i = 1:m
u(i) <= r(i) .* M2(i) ;
end
for i = 1:m
zo_set(i) - sum(x(i,:)) <= (1 - r(i)) .* zo_set(i);
end
cvx_end
Please let me know how to fix the issue. For the given z* , I get positive value of g but for second iteration g becomes negative.