X-Git-Url: https://ruin.nu/git/?p=germs.git;a=blobdiff_plain;f=src%2Fgenesorter.cpp;h=3198543fae391f4805211406a5f8f76ccf28c889;hp=602a6dde276318e069fa8e1496c005110e9b27d4;hb=34293060b5be57f6e2ea620ad4c3ff0f94e1d305;hpb=efe42ca948704593c847996d0ae8da71d15bb75b diff --git a/src/genesorter.cpp b/src/genesorter.cpp index 602a6dd..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; @@ -49,11 +50,12 @@ GeneSorter::ActionList GeneSorter::sort(const GeneOrder& go, const Model& m){ if (safe.size() > 0){ priority_queue,vector >, ScoreCmp > pq; for (ActionList::iterator sa = safe.begin(); sa != safe.end(); ++sa){ - pq.push(pair(m.score(*sa),*sa)); + pq.push(pair(m.score(*sa,temp),*sa)); } SortAction sa = pq.top().second; sa(temp); al.push_back(sa); + --dist; }else return ActionList(); //TODO: Need to handle hurdles. }