Auto Commit
This commit is contained in:
@@ -13,7 +13,7 @@ set(HEADER_FILES
|
||||
set(SOURCE_FILES
|
||||
MakePermutationMatrix.cpp
|
||||
ReadFromFile.cpp
|
||||
CostMatrixGenerator.cpp CostMatrixGenerator.h ParseMatrixForMPI.h SerializeCities.h)
|
||||
CostMatrixGenerator.cpp CostMatrixGenerator.h ParseMatrixForMPI.h SerializeCities.h partialPermutation.h)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
add_executable(HW10 ${HEADER_FILES} ${SOURCE_FILES} main.cpp)
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Hashes of file build rules.
|
||||
26a2bad7d1d2da4c60ef59c8ea5c8e8f CMakeFiles/ClangFormat
|
||||
71b71fb7cf28045cfbac6c20a4ae1c66 CMakeFiles/ClangFormat
|
||||
|
||||
@@ -54,7 +54,7 @@ CMAKE_BINARY_DIR = /Users/bradybodily/Repositories/CS5500_Parallel_Programming/H
|
||||
include CMakeFiles/ClangFormat.dir/progress.make
|
||||
|
||||
CMakeFiles/ClangFormat:
|
||||
/usr/local/bin/clang-format -i -style=file /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/MakePermutationMatrix.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/ReadFromFile.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/City.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/MakePermutationMatrix.cpp /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/ReadFromFile.cpp /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/CostMatrixGenerator.cpp /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/CostMatrixGenerator.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/ParseMatrixForMPI.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/SerializeCities.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/main.cpp
|
||||
/usr/local/bin/clang-format -i -style=file /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/MakePermutationMatrix.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/ReadFromFile.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/City.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/MakePermutationMatrix.cpp /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/ReadFromFile.cpp /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/CostMatrixGenerator.cpp /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/CostMatrixGenerator.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/ParseMatrixForMPI.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/SerializeCities.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/partialPermutation.h /Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/main.cpp
|
||||
|
||||
ClangFormat: CMakeFiles/ClangFormat
|
||||
ClangFormat: CMakeFiles/ClangFormat.dir/build.make
|
||||
|
||||
@@ -124,6 +124,9 @@
|
||||
<Unit filename="/Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/main.cpp">
|
||||
<Option target="HW10"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/partialPermutation.h">
|
||||
<Option target="HW10"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/bradybodily/Repositories/CS5500_Parallel_Programming/HW10/CMakeLists.txt">
|
||||
<Option virtualFolder="CMake Files\"/>
|
||||
</Unit>
|
||||
|
||||
12
HW10/partialPermutation.h
Normal file
12
HW10/partialPermutation.h
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Created by Brady Bodily on 3/30/20.
|
||||
//
|
||||
#include <iostream>
|
||||
#ifndef HW10_PARTIALPERMUTATION_H
|
||||
#define HW10_PARTIALPERMUTATION_H
|
||||
template<typename BidiIt>
|
||||
bool next_partial_permutation(BidiIt first, BidiIt middle, BidiIt last) {
|
||||
std::reverse(middle, last);
|
||||
return std::next_permutation(first, last);
|
||||
}
|
||||
#endif //HW10_PARTIALPERMUTATION_H
|
||||
Reference in New Issue
Block a user