function [k, plist] = evalrankga(D)
nvars = length(D);
options = optimoptions('ga', 'CrossoverFcn',@rankxover,...
    'MutationFcn',@rankmutation, 'CreationFcn',@rankcreationfcn);
[x,k,exitflag,output,population,scores] = ga(@(perm) (rankfitness(perm,D)),nvars,options);
%The below uses find to list the indexes of the scores that give the fval
%(kmin). This is used to pull out the corresponding permutation in the
%population. Then, since many of these are actually the same permutation,
%unique() pull out the unique permutations giving kmin. This is p.
plist = unique(population(find(scores(:)==k),:),'rows');
end