There all,
my optimization problem is doing almoust well, but I can't figure out why it is make mastake in just one column. The first part gives a set of feasible solutions. Then in second part I have to extract from the solution matrix t minimum values, so in each column and row to be just one minimum value. I have two minimum values in one column and in another there is no values. If it is already chosen minimum value in some column it is needed to find another value, first higher.
Please help me!
m=11;
n=11;
A=[1 1 370 2 505 30; 2 2 833 1 933 30; 3 1 510 3 695 30; 4 3 1038 1 1224 30; 5 1 220 4 545 30; 6 4 805 5 840 10; 7 5 865 4 915 30; 8 4 1185 6 1253 30;
9 6 361 4 433 30; 10 4 635 7 852 30; 11 7 880 4 1094 30;12 4 1152 1 71 30]
for i=1:1:m
j=2;
for l=1:1:m
if A(i,j+2)==A(l,j) & l~=i
x(i,l)=1;
if A(l,j+1)A(i,j+3)>=A(i,6) & A(l,j+1)A(i,j+3)>0;
t(i,l)=A(l,j+1)A(i,j+3)A(i,6);
else
t(i,l)=1440+(A(l,j+1)A(i,j+3));
end
else
x(i,l)=0;
t(i,l)=0;
end
end
end
display (x)
display(t)
%Following part have to give an optimal set of solution so in each row and in each column to be minimum value, but with condition to have just one value in each row and each column, there is no column with two values and row with two values. BUt J obtained one column with two values. Why?
proc1Matrix = zeros(size(t));
proc2Matrix = zeros(size(t));
for i = 1:size(t, 1);
currRow = t(i, :);
nonZeroElems = nonzeros(currRow);
minNonZeroElem = min(nonZeroElems);
if ~isempty(minNonZeroElem)
minElement = find(currRow == minNonZeroElem);
if length(find(proc1Matrix(:,mod(i,12)+1))) > 0
t(i,minElement) = 0;
currRow = t(i,:);
nonZeroElems = nonzeros(currRow);
minNonZeroElem = min(nonZeroElems);
minElement = find(currRow == minNonZeroElem);
end
proc1Matrix(i, minElement) = minNonZeroElem
end
end
Z=sum(sum(proc1Matrix))
