Fuzzy c-means clustering algorithm based on genetic algorithm

funtion varagrout = CHIMBUSCO(xy,dmat,salesmen,min_tour,pop_size,num_iyer,show_prog,show_res)
clc
clear all;
load CoordinateData
m = size(CoordinateData,2);
lb = min(CoordinateData);
ub = max(CoordinateData);
options = [3,20,1e-6];
cn = 4;
sizepop = 40;
MAXGEN = 30;
NVAR = m*cn;
PRECI = 10;
pc = 0.8;
pm = 0.05;
trace = zeros(NVAR+1,MAXGEN);
FieldD = [rep([PRICE],[1,NVAR]);rep([lb;ub],[l,cn]);rep([1;0;1;1],[1,NVAR])];
Chrom = crtbp(sizepop,NVAR*PRECI);
V = bs2rv(Chrom,FieldD);
ObjV = ObjFun(CoordinateData,cn,V,options);
gen = 0;
while gen < MACGEN
	FitnV = ranking(ObjV);
	SelCh = select('rws',Chrom,FitnV);
	SelCh = recombin('xovsp',SelCh,pc);
	SelCh = mut(SelCh,pm);
	V = bs2rv(SelCh,FieldD);
	newObjV = ObjFun(CoordinateData,cn,V,options);
	newChrom = SelCh;
		for i = 1:sizepop
			if ObjV(i) > newObjV(i);
				ObjV(i) = newObjV(i);
				Chrom(i,:) = newChrom(i,:);
			end
		end
		gen = gen+1;
		[trace(end,gen),idx] = min(ObjV);
		trace(1:NVAR,gen) = V(idx,:);
		fprintf(1,'%d',gen);
	end
		

Guess you like

Origin blog.csdn.net/weixin_44616447/article/details/108681928