资源简介
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
相关资源
- 连续hopfield神经网络解决TSP问题
- 用8位spi实现16位spi
- TSP问题城市数据及最优解
- Exact Conditions of Blow-up and Global Existen
- doneex xcell compiler 2.1.2.9绿色汉化版(
- onvif协议视频转码推流网页播放
- 流媒体相关协议标准RTP/RTSP/RTCP PDF文档
- 山东大学编译原理PL/0语言 compiler实验
- Hopfield神经网络解决 TSP问题
- H264实时编码RTSP直播
- 三种解决TSP问题的近似算法的实现
- TSP城市问题145个城市数据及其相应的
- 遗传算法解决TSP旅行商问题程序开源
- 三维可压缩流场MPI+OpenMP混合并行算法
- Wind River Diab Compiler for PowerPC
- MPI和CUDA在多层快速多极子中的应用
- 论文研究 - 开放性试验研究Yokukansan
- 将rtsp转码为flv格式用于h5播放前端使
- 5种多旅行商问题(MTSP)的遗传算法
- FFT并行MPI实现
- Design_compiler经典教程
- 龙书《编译原理》(Compilers:Principle
- rtsp-h264.zip
- 免疫算法求解TSP问题详解
- websocket-rtsp-proxy-test.zip
- Writing A Compiler In Go.pdf
- TSP问题测试数据集
- DFT Compiler Scan User Guide Version E-2010.12
- MP4v2录制rtsp流存为MP4文件
- rtsp摄像头推流上云使用浏览器播放
评论
共有 条评论