%This program is used to compare the performance between
%hard C-means and fuzzy C-means.

%Carson KAO, May 28, 1997
str = input('PLS input data file name or enter for default:','s');
%load data pair, center & cost function files
if strcmp('normal',str),
   datafile = 'hncentr.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['hcmcentr = ', datafile(1:index-1) ';']);
   datafile = 'fncentr.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['fcmcentr = ', datafile(1:index-1) ';']);
   datafile = 'normal.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['data = ', datafile(1:index-1) ';']);
   datafile = 'hncost.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['hcmU = ', datafile(1:index-1) ';']);
   datafile = 'fncost.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['fcmU = ', datafile(1:index-1) ';']);
else
   datafile = 'hdcentr.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['hcmcentr = ', datafile(1:index-1) ';']);
   datafile = 'fdcentr.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['fcmcentr = ', datafile(1:index-1) ';']);
   datafile = 'default.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['data = ', datafile(1:index-1) ';']);
   datafile = 'hdcost.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['hcmU = ', datafile(1:index-1) ';']);
   datafile = 'fdcost.dat';
   index = findstr(datafile, '.');
   eval(['load ', datafile]);
   eval(['fcmU = ', datafile(1:index-1) ';']);
end
%separate index
fcm_s = sepclust(fcmcentr);
hcm_s = sepclust(hcmcentr);
fprintf('Fuzzy C-means separate index = %f\n',fcm_s);
fprintf('Hard  C-means separate index = %f\n',hcm_s);
%compact index
fcm_pi = pifcm(fcmcentr,data,fcmU);
hcm_pi = pihcm(hcmcentr,data,hcmU);
fprintf('Fuzzy C-means compact index = %f\n',fcm_pi);
fprintf('Hard  C-means compact index = %f\n',hcm_pi);
%compactness & separation validity function S
fcm_S = fcm_pi/fcm_s;
hcm_S = hcm_pi/hcm_s;
fprintf('Fuzzy C-means validity function S = %f\n',fcm_S);
fprintf('Hard  C-means validity function S = %f\n',hcm_S);






