diff --git a/HW10/MakePermutationMatrix.cpp b/HW10/MakePermutationMatrix.cpp index 4338623..8a2d716 100644 --- a/HW10/MakePermutationMatrix.cpp +++ b/HW10/MakePermutationMatrix.cpp @@ -10,8 +10,7 @@ std::vector MakePermutationMatrix::MakePermutation(std::vector source, int rank, int size, std::vector> costMatrix){ std::vector returnVector; std::vector localCostVector; - std::size_t counter = 0; - int vectorOffset = (source.size())/size; + int vectorOffset = source.size()/size; std::sort(source.begin(), source.end()); std::vector myPerm = source; std::vector nextPerm = source; @@ -30,16 +29,16 @@ std::vector MakePermutationMatrix::MakePermutation(std::vector sou std::partial_sort(myPerm.begin()+1, myPerm.end(), myPerm.end()); //std::cout << "source.last(): " << source[8].GetName() << std::endl; - std::cout <<"Rank: " << rank << " next perm: "; - for(int i = 0; i < nextPerm.size(); i++){ - std::cout << nextPerm[i].GetName() << " "; - } - std::cout << std::endl; - std::cout <<"Rank: " << rank << " My perm: "; - for(int i = 0; i < myPerm.size(); i++){ - std::cout << myPerm[i].GetName() << " "; - } - std::cout << std::endl; +// std::cout <<"Rank: " << rank << " next perm: "; +// for(int i = 0; i < nextPerm.size(); i++){ +// std::cout << nextPerm[i].GetName() << " "; +// } +// std::cout << std::endl; +// std::cout <<"Rank: " << rank << " My perm: "; +// for(int i = 0; i < myPerm.size(); i++){ +// std::cout << myPerm[i].GetName() << " "; +// } +// std::cout << std::endl; if(rank == size-1){ nextPerm = source; } @@ -48,14 +47,13 @@ std::vector MakePermutationMatrix::MakePermutation(std::vector sou //Add up the cost of the current permutation. // std::cout <<"Rank: " << rank << " Current perm: "; for (int i = 0; i < myPerm.size(); i++) { - // std::cout << myPerm[i].GetName() << " "; + std::cout << "Rank: "<< rank << " i: " << i; cost += costMatrix[myPerm[i].GetName()][myPerm[i-1].GetName()]; } - //std::cout << std::endl << std::endl; + std::cout << std::endl << std::endl; //Push permutation cost to the localCostVector. localCostVector.push_back(cost); - counter++; } while (std::next_permutation(myPerm.begin(), myPerm.end()) && myPerm!=nextPerm); // //find the lowest and add it to a lowest vector.