function calculated_index = emptiness(M)

% !!!Not tested!!!  Only works on Matlab 6.5 or higher.
% This calculates the ratio of the volume of the largest internal hole in a population
% to the volume of the convex hull of the population.

% Ratios volume convex hull of largest internal hole to volume of convex hull of population
% Created by Jim Work, University of South Carolina, August 13, 2003

[K,v_initial] = convhull(M(:,2),M(:,3),M(:,4));    % The convhull function is used to find the
%  perimeter individuals.

while size(M,1)>4
   M(K,:) = [];
   [K,v_current] = convhull(M(:,2),M(:,3),M(:,4));
end

calculated_index = v_current/v_initial;