X-Git-Url: https://ruin.nu/git/?p=germs.git;a=blobdiff_plain;f=src%2Fgenesorter.cpp;h=3198543fae391f4805211406a5f8f76ccf28c889;hp=81b9da56635b03bf265de647bf349ac91f917079;hb=34293060b5be57f6e2ea620ad4c3ff0f94e1d305;hpb=ebdd033ac96ff67b70a80146d076f07ad68f5dad diff --git a/src/genesorter.cpp b/src/genesorter.cpp index 81b9da5..3198543 100644 --- a/src/genesorter.cpp +++ b/src/genesorter.cpp @@ -41,7 +41,8 @@ struct ScoreCmp { GeneSorter::ActionList GeneSorter::sort(const GeneOrder& go, const Model& m){ ActionList al; GeneOrder temp(go); - while(inversionDistance(temp) > 0){ + size_t dist = inversionDistance(temp); + while(dist > 0){ //cout << "Distance: " << inversionDistance(temp) << " : "; //copy(temp.begin(), temp.end(), ostream_iterator(cout, " ")); //cout << endl; @@ -54,6 +55,7 @@ GeneSorter::ActionList GeneSorter::sort(const GeneOrder& go, const Model& m){ SortAction sa = pq.top().second; sa(temp); al.push_back(sa); + --dist; }else return ActionList(); //TODO: Need to handle hurdles. }