资源简介
TSP的并行解决,关于虚拟机ubuntu MPI程序代码。TSP的并行解决,关于虚拟机ubuntu MPI程序代码。TSP的并行解决,关于虚拟机ubuntu MPI程序代码。TSP的并行解决,关于虚拟机ubuntu MPI程序代码。
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef struct
{
int *cities;
int num_cities;
int cost;
} Tour;
#define City_count(tour) (tour->num_cities)
#define Tour_cost(tour) (tour->cost)
#define Last_city(tour) (tour->cities[(tour->num_cities)-1])
#define Tour_city(touri) (tour->cities[(i)])
#define Cost_c(length i city) (length+Cost[i][city])
int comm_sz; // número de nós de processamento
queue local_queue;
int n E;
int minPath = INT_MAX;
int **adj = NULL; // Matriz de Adjacentes
int **Cost = NULL; // Matriz de Custos
int my_rank;
int best_global;
#define TOUR 2
int Cost_Calculate(int *path int num_cities);
void visit(const int city int hops int length int *path);
void process_tree(int *bufrecv int size int cities);
inline bool visited(Tour *tour int city);
Tour* addCity(Tour *tour int newcity);
bool IsBestCost(const int &Curr_tourCost);
int Create_Queues();
inline void Free(Tour *tour);
inline void Free(Tour *tour)
{
if(tour != NULL)
{
if(tour->cities != NULL)
{
free(tour->cities);
}
free(tour);
}
}
int main(int argc char *argv[])
{
int bufrecv[10000];
int quotient remainder;
int a b d;
double start finish;
int required=MPI_THREAD_SERIALIZED;
int provided;
MPI_Init_thread(&argc &argv required &provided);
MPI_Comm_size(MPI_COMM_WORLD &comm_sz);
MPI_Comm_rank(MPI_COMM_WORLD &my_rank);
if (provided < required)
{
// Insufficient support degrade to 1 thread and warn the user
if (my_rank == 0)
{
cout << “Warning: This MPI implementation provides insufficient“ << “ threading support.“ << endl;
} omp_set_num_threads(1);
}
if(my_rank ==0)
{
cin >> n >> E;
}
MPI_Bcast(&n 1 MPI_INT 0 MPI_COMM_WORLD);
adj = new int*[n];
Cost = new int*[n];
for(int i = 0; i < n; i++)
{
adj[i] = new int[n];
Cost[i] = new int[n];
memset(adj[i] 0 n*sizeof(int));
memset(Cost[i] 0 n*sizeof(int));
}
if(my_rank == 0)
{
for(int i = 0; i < E; i++)
{
cin >> a >> b >> d;
Cost[a][b] = d;
Cost[b][a] = d;
adj[a][b] = 1;
adj[b][a] = 1;
}
}
for(int i = 0; i < n; i++)
MPI_Bcast(&(Cost[i][0]) n MPI_INT 0 MPI_COMM_WORLD);
for(int i = 0; i < n; i++)
MPI_Bcast(&(adj[i][0]) n MPI_INT 0 MPI_COMM_WORLD);
if(my_rank == 0)
{
int queue_size = Create_Queues();
vector tours;
while(!local_queue.empty())
{
Tour *temp = local_queue.front();
local_queue.pop();
for(int j=0;j
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-07-17 09:47 MPI_tsp-master\
文件 960 2016-07-17 09:47 MPI_tsp-master\README.md
文件 10514 2016-07-17 09:47 MPI_tsp-master\main.cpp
相关资源
- impinj Speedway配置
- VTSP题库VTSP的题库
- 经验模式分解(Empirical Mode Decomposit
- DUMPIT.exe
- 旅行商TSP问题的Lingo程序
- Rtsp流媒体PC端和手机网页直播代码
- SystemHooksCompiledOnly
- rtsp解析实现音视频实时传输
- iDreamPiano用的lyt大全
- 旅行商问题的数学规划模型
- nbody的mpi&openmp实现源码
- Live555基于h264嵌入式linux下rtsp项目的裁
- TSP CHC144
- Hopfield人工神经网络求解TSP问题附论文
- QT编写的RTSP播放器各QT版本可完整编译
- 遗传算法和蚂蚁算法求解TSP旅行商问
- onvif设备发现+鉴权认证+RTSP地址获取
- TSP问题的benchmark库
- LTspice双脉冲波形发生器
- 利用遗传算法解决TSP并实现可视化程
- VTSP-DV 2016
- python tsp 求解VRP问题的经典算法
- Engineering a Compiler
- Quick Batch File Compilerregister
- Blow up for the solutions of the Euler-Poisson
- One new subgenus and one record species of Rha
- RTSPVGA录制,以及推流小工具
- 基于easydarwin实现rtsp拉流新
- RTSP服务器及客户端测试源代码
- 海思hi3520 rtsp源码
评论
共有 条评论