function [final_location,distance_new_to_old,distance_among_new,...
    objective_function,normed_final_solution] = squaredeuclidean_mds(prox,initial_location)

numobject = size(prox,1);
numdim = size(initial_location,1);

average_initial_location = sum(initial_location')/numobject;

for d = 1:numdim
    for i = 1:numobject
        initial_location(d,i) = initial_location(d,i) - ...
            average_initial_location(d);
    end
end


sumproxsq = sum(sum(prox.^2));

norm_sim = zeros(numobject,numobject);

for i = 1:numobject
    for j = 1:numobject
        
        if(i ~= j)
            
            norm_sim(i,j) = 1.0 - (prox(i,j)/sqrt(sumproxsq));
            
        end
    end
end


inter_distance = zeros(numobject,numobject);

for i = 1:numobject
    for j = 1:numobject
        
        for d = 1:numdim
            
            inter_distance(i,j) = inter_distance(i,j) + ...
                ((initial_location(d,i) - initial_location(d,j))^2);
            
        end
        
      
        
    end
end
   
initial_sumdistsq = sum(sum(inter_distance^2));

%epsil = 1.0e-012;

start_location = (numobject)*(initial_location/initial_sumdistsq);


objective_function = 0.0;

obdiff = 1.0;

while (obdiff > 1.0e-006)

    
    obprev = objective_function;
    
    [new_facility_location,distance_new_to_old,distance_among_new,objective_function] = ...
        squared_euclidean_multifacility(norm_sim,zeros(numobject,numobject),start_location);
    
    obdiff = (abs(objective_function - obprev))/obdiff;
    
    new_sumdistsq = sum(sum(distance_among_new^2));
    
    start_location = (numobject)*(new_facility_location/new_sumdistsq);
    
    average_start_location = sum(start_location')/numobject;
    
    for d = 1:numdim
        for i = 1:numobject
            start_location(d,i) = start_location(d,i) - average_start_location(d);
        end
    end
    
    distance_among_new
    
    start_location
    
    objective_function
end

final_location = new_facility_location;

normed_final_solution = start_location;

    
    
    