Auto Commit
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cfloat>
|
#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<double> returnVector;
|
||||||
std::vector<std::size_t> localCostVector;
|
std::vector<std::size_t> localCostVector;
|
||||||
int vectorOffset = source.size()/size;
|
int vectorOffset = source.size()/size;
|
||||||
@@ -77,9 +77,13 @@ std::vector<double> MakePermutationMatrix::MakePermutation(std::vector<City> sou
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
//MPI_Gather(&localCostVector,1, MPI_DOUBLE, &returnVector,1, MPI_DOUBLE,0, MPI_COMM_WORLD);
|
//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){
|
long double MakePermutationMatrix::GetLowestCost(std::vector<City> source, int rank, int size, std::vector<std::vector<double>> costMatrix){
|
||||||
return MakePermutation(source, rank, size, 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];
|
||||||
}
|
}
|
||||||
@@ -10,10 +10,10 @@
|
|||||||
class MakePermutationMatrix
|
class MakePermutationMatrix
|
||||||
{
|
{
|
||||||
public:
|
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:
|
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
|
#endif // HW10_MAKEPERMUTATIONMATRIX_H
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int rank, size, citiesSize;
|
int rank, size, citiesSize;
|
||||||
int data;
|
long double lowestCost = 0;
|
||||||
MPI_Init(&argc, &argv);
|
MPI_Init(&argc, &argv);
|
||||||
MPI_Comm_rank(MCW, &rank);
|
MPI_Comm_rank(MCW, &rank);
|
||||||
MPI_Comm_size(MCW, &size);
|
MPI_Comm_size(MCW, &size);
|
||||||
@@ -56,7 +56,7 @@ int main(int argc, char* argv[])
|
|||||||
//Make permutations
|
//Make permutations
|
||||||
|
|
||||||
}
|
}
|
||||||
costs = MakePermutationMatrix::GetLowestCost(cities, rank, size, costMatrix);
|
lowestCost = MakePermutationMatrix::GetLowestCost(cities, rank, size, costMatrix);
|
||||||
// if(!rank){
|
// if(!rank){
|
||||||
// std::cout << costs.size() << std::endl;
|
// std::cout << costs.size() << std::endl;
|
||||||
// std::cout << costs[0];
|
// std::cout << costs[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user