Auto Commit

This commit is contained in:
2020-03-31 00:36:16 -06:00
parent 86a5371fb1
commit 30458e0e6d
3 changed files with 12 additions and 8 deletions

View File

@@ -8,7 +8,7 @@
#include <iostream>
#include <cfloat>
std::vector<double> MakePermutationMatrix::MakePermutation(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix){
long double MakePermutationMatrix::MakePermutation(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix){
std::vector<double> returnVector;
std::vector<std::size_t> localCostVector;
int vectorOffset = source.size()/size;
@@ -77,9 +77,13 @@ std::vector<double> MakePermutationMatrix::MakePermutation(std::vector<City> sou
std::cout << std::endl;
//MPI_Gather(&localCostVector,1, MPI_DOUBLE, &returnVector,1, MPI_DOUBLE,0, MPI_COMM_WORLD);
return returnVector;
return lowest;
}
std::vector<double> MakePermutationMatrix::GetLowestCost(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix){
return MakePermutation(source, rank, size, costMatrix);
long double MakePermutationMatrix::GetLowestCost(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix){
std::vector<long double> l(size,0);
auto lowest = MakePermutation(source, rank, size, costMatrix);
MPI_Gather(&lowest,1,MPI_LONG_DOUBLE,l.data(),1,MPI_LONG_DOUBLE,0,MPI_COMM_WORLD);
std::sort(l.begin(), l.end());
return l[l.size()-1];
}

View File

@@ -10,10 +10,10 @@
class MakePermutationMatrix
{
public:
static std::vector<double> GetLowestCost(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix);
long double GetLowestCost(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix);
private:
static std::vector<double> MakePermutation(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix);
long double MakePermutation(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix);
};
#endif // HW10_MAKEPERMUTATIONMATRIX_H

View File

@@ -9,7 +9,7 @@
int main(int argc, char* argv[])
{
int rank, size, citiesSize;
int data;
long double lowestCost = 0;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MCW, &rank);
MPI_Comm_size(MCW, &size);
@@ -56,7 +56,7 @@ int main(int argc, char* argv[])
//Make permutations
}
costs = MakePermutationMatrix::GetLowestCost(cities, rank, size, costMatrix);
lowestCost = MakePermutationMatrix::GetLowestCost(cities, rank, size, costMatrix);
// if(!rank){
// std::cout << costs.size() << std::endl;
// std::cout << costs[0];