how can i make it to loop of an iteration?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
sharifah shuthairah syed abdullah
el 13 de Oct. de 2018
Comentada: sharifah shuthairah syed abdullah
el 18 de Oct. de 2018
i have this coding, i want to have make a loop of for 10 iteration.. the curent coding didnt give me 10 iteration..
i want to have 10 possible solution however its only show 1 solution. below is the coding. what can i do to make it generate 10 solution
%read data
clc
clear
%global f d;
%flow
f=[ 0 5 2 4 1
5 0 3 0 2
2 3 0 0 0
4 0 0 0 5
1 2 0 5 0];
%distance
d=[ 0 1 2 3 1
1 0 1 2 2
2 1 0 1 3
3 2 1 0 4
1 2 3 4 0];
[r,c]=size(f);
max_i= r;
max_j =r;
max_k= r;
max_q= r;
A=zeros(r,r);
ID=randperm(r);
MaxIt=10;
x=zeros(r,r);
n=length(ID);
x1=ID;
for i=1:n
for j=1:r
x(j,x1(j))=1;
B(i).mat=x; %store permutationof binary value, 0,1
end
x=zeros(r,r);
end
for i=MaxIt
for no=1:length(B)
z=0;
xa=B(no).mat;
for i=1:max_i
for j=1:max_j
for k=1:max_k
for q=1:max_q
z= z+ f(i,k).*d(j,q).*xa(i,j).*xa(k,q);
end
end
end
end
end
no;
F(no,:)=[no z];
end
zmin=min(F(:,2));
ii=find(F(:,2)==zmin) ;
x_initial = B(ii).mat;
xbin= B(ii).mat
z_minimum = zmin
%disp(B(ii).mat)
%fprintf (B(no).mat);
%disp(z)
10 comentarios
Kevin Chng
el 17 de Oct. de 2018
Quadratic Assignment Problem using GA
I'm not familiar with the topic above, do you have pseudocode for it? or any reference for me to see? Where do you find reference to write your code?
Perhaps they will help me to understand more.
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!