Effacer les filtres
Effacer les filtres

how can i make it to loop of an iteration?

2 vues (au cours des 30 derniers jours)
sharifah shuthairah syed abdullah
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 commentaires
Kevin Chng
Kevin Chng le 17 Oct 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.
sharifah shuthairah syed abdullah
i have the step
begin
create initial population;
for every generation, repeat
randomly select individuals into the mating pool;
apply genetic operators to generate offspring;
(maybe) apply post-crossover heuristic on offspring;
if not in i×Tc generations
compare every offspring with its similar parent and
remove the worse one;
else
compare every offspring with the worst member in
the current population and remove the worse one
until some stopping criterion is met
end;
http://iopscience.iop.org/article/10.1088/1757-899X/300/1/012002 this is the paper that i write for conference.. i want to solve the problem using genetic algorithm
the reference is from one f my lecturer in my university... i find one coding that solve the same problem using the same method, however i need to change here and there, and its become difficult..that is why i want to build my own..however i find a difficulties also..

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by