Auto Commit
This commit is contained in:
@@ -10,23 +10,12 @@
|
||||
std::vector<double> MakePermutationMatrix::MakePermutation(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix){
|
||||
std::vector<double> returnVector;
|
||||
std::vector<double> localCostVector;
|
||||
std::size_t offset = 12;
|
||||
std::size_t counter = 0;
|
||||
int vectorOffset = (source.size()+1)/2;
|
||||
std::sort(source.begin(), source.end());
|
||||
std::vector<City> myPerm = source;
|
||||
std::vector<City> nextPerm = source;
|
||||
|
||||
// if(!rank){
|
||||
// size_t totalNumPermutations = 1;
|
||||
// for(size_t i = 1; i <= source.size(); i++)
|
||||
// totalNumPermutations *= i;
|
||||
// offset = totalNumPermutations/size;
|
||||
// std::cout << "offset: "<<offset <<std::endl;
|
||||
// }
|
||||
//MPI_Bcast(&offset, 1, MPI_LONG_LONG_INT, 0, MPI_COMM_WORLD);
|
||||
|
||||
|
||||
//return vector should be the size of number of processors as they are going to only return their own smallest.
|
||||
returnVector.resize(source.size(), 0);
|
||||
|
||||
@@ -34,18 +23,18 @@ std::vector<double> MakePermutationMatrix::MakePermutation(std::vector<City> sou
|
||||
//std::rotate(nextPerm.begin(), nextPerm.begin()+(rank+1)*offset, nextPerm.end());
|
||||
|
||||
//rotate my perm.
|
||||
std::rotate(myPerm.begin(), myPerm.begin()+vectorOffset*rank,myPerm.end());
|
||||
std::rotate(myPerm.begin(), myPerm.begin()+rank,myPerm.end()+rank+1);
|
||||
//std::cout << "source.last(): " << source[8].GetName() << std::endl;
|
||||
std::cout << "source: ";
|
||||
for(int i = 0; i < source.size(); i++){
|
||||
std::cout << source[i].GetName() << " ";
|
||||
}
|
||||
std::cout << std::endl << 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 << " next perm: ";
|
||||
for(int i = 0; i < nextPerm.size(); i++){
|
||||
std::cout << nextPerm[i].GetName() << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
do {
|
||||
double cost = 0;
|
||||
std::cout <<"Rank: " << rank << " myPerm: ";
|
||||
@@ -63,7 +52,7 @@ std::vector<double> MakePermutationMatrix::MakePermutation(std::vector<City> sou
|
||||
//Push permutation cost to the localCostVector.
|
||||
localCostVector.push_back(cost);
|
||||
counter++;
|
||||
} while (std::next_permutation(myPerm.begin(), myPerm.end()) && counter != offset );
|
||||
} while (std::next_permutation(myPerm.begin()+1, myPerm.end()));
|
||||
|
||||
// //find the lowest and add it to a lowest vector.
|
||||
// auto lowest = std::vector<double>(1,localCostVector[0]);
|
||||
|
||||
Reference in New Issue
Block a user