Hi,
I am trying to write my optimization model by following the way of Factory, Warehouse, Sales Allocation Model: Solver-Based example. Unfortunately, I have this error:
% Unable to perform assignment because the size of the left side is 90-by-1 and the size of the right side is 5-by-3.
%
% Error in Constraint (line 28)
% xtemp(:,:,ii) = d_ik;
The optimization model:
This is the code I tried to write:
i = 5; k = 3; t = 6;d_ik = [1,5,6; 3,6,3; 5,7,0; 6,3,9; 2,8,8];TR_t = [1000, 1000, 1000, 1000, 1000, 1000];X_ikt = zeros(i,k,t); % Allocate arrays
for ii = 1:i for jj = 1:k for kk = 1:t obj(ii,jj,kk) = 1; end endendobj = X_ikt(:);matwid = length(obj);Aineq = spalloc(t,matwid,i*k*t);bineq = zeros(t,1);clearer1 = zeros(size(obj));clearer12 = clearer1(:);counter = 1;for ii = 1:t xtemp = clearer1; xtemp(:,:,ii) = d_ik; xtemp = sparse(xtemp(:)); % Convert to sparse
Aineq(counter,:) = xtemp'; % Fill in the row
bineq(counter) = TR(ii)'; counter = counter + 1;endintcon = t+1:length(obj);lb = zeros(length(obj),1);ub = Inf(length(obj),1);opts = optimoptions('intlinprog','Display','off','PlotFcn',@optimplotmilp);[solution,fval,exitflag,output] = intlinprog(obj,intcon,Aineq,bineq,lb,ub,opts);
PS: I am intended to write my model like Factory, Warehouse, Sales Allocation Model: Solver-Based example to obtain computational efficiency for large scale models and to solve using different techniques such as Genetic Algorithm.
Best Answer