load eve_black_one.dat

tic;

best_vaf = 0.0;
store_vaf = zeros(100,1);

core = [4,4,4,4,4,4,4,4,4,4];

datamatrix = [eve_black_one,core'];

prox = zeros(16,16);

for i = 1:16
    for j=1:16
        
        for k = 1:10
            
            prox(i,j) = prox(i,j) + ((datamatrix(k,i) - datamatrix(k,j))^2);
            
        end
        
        prox(i,j) = sqrt(prox(i,j));
        
    end
end

prox


for i = 1:100
    
    [outpermone,outpermtwo,coordone,coordtwo,fitone,fittwo,addconone,...
        addcontwo,vaf] = ms_biscalqa(prox,targlin(16),targlin(16), ...
        randperm(16),randperm(16),3,1);
    
    store_vaf(i) = vaf;
    
    if (vaf > best_vaf)
        
        best_vaf = vaf;
        best_outpermone = outpermone;
        best_outpermtwo = outpermtwo;
        best_coordone = coordone;
        best_coordtwo = coordtwo;
        best_fitone = fitone;
        best_fittwo = fittwo;
        best_addconone = addconone;
        best_addcontwo = addcontwo;
        
    end
    
end

sorted_vafs = sort(store_vaf');

sorted_vafs;

        best_vaf
        best_outpermone 
        best_outpermtwo
        best_coordone
        best_coordtwo
      
        best_addconone
        best_addcontwo 
        
        axes = zeros(16,2);
        
        for i = 1:16
            
            axes(best_outpermone(i),1) = best_coordone(i);
            axes(best_outpermtwo(i),2) = best_coordtwo(i);
        end
        
        figure(1)
        
        plot(axes(1:16,1),axes(1:16,2),'ko')
        
        hold on
        
        for i = 1:16
            
            objectlabels{i,1} = int2str(i);
            
        end
        
        text(axes(1:16,1),axes(1:16,2),objectlabels,'fontsize',10,'verticalalignment','bottom')
        
        weight_new_to_old = 8 - datamatrix;
        
        old_facility_location = axes';
        
        for i = 1:10
            
            newobjectlabels{i,1} = int2str(i);
            
        end
        
        [new_facility_location,distance_new_to_old,distance_among_new,objective_function] = ...
            cityblock_multifacility_hap(weight_new_to_old,zeros(10,10),old_facility_location,1.0e-012)
        
        
        newaxes = new_facility_location';
        
        plot(newaxes(1:10,1),newaxes(1:10,2),'rx')
        
        text(newaxes(1:10,1),newaxes(1:10,2),newobjectlabels,'fontsize',10,'verticalalignment','bottom')
        
        figure(2)
        
        plot(axes(1:16,1),axes(1:16,2),'ko')
        
        hold on
        
        [new_facility_location,distance_new_to_old,distance_among_new,objective_function] = ...
            euclidean_multifacility_hap(weight_new_to_old,zeros(10,10),old_facility_location,1.0e-012)
        
        
        
        text(axes(1:16,1),axes(1:16,2),objectlabels,'fontsize',10,'verticalalignment','bottom')
        
       
        
        newaxes = new_facility_location';
        
        plot(newaxes(1:10,1),newaxes(1:10,2),'rx')
        
        text(newaxes(1:10,1),newaxes(1:10,2),newobjectlabels,'fontsize',10,'verticalalignment','bottom')
        
        figure(3)
        
        plot(axes(1:16,1),axes(1:16,2),'ko')
        
        hold on
        
        [new_facility_location,distance_new_to_old,distance_among_new,objective_function] = ...
            squared_euclidean_multifacility(weight_new_to_old,zeros(10,10),old_facility_location)
        
        
        
        text(axes(1:16,1),axes(1:16,2),objectlabels,'fontsize',10,'verticalalignment','bottom')
        
        
        
        
        newaxes = new_facility_location';
        
        plot(newaxes(1:10,1),newaxes(1:10,2),'rx')
        
        text(newaxes(1:10,1),newaxes(1:10,2),newobjectlabels,'fontsize',10,'verticalalignment','bottom')
        
        
        
toc;



