poj 2349 Arctic Network

本文探讨了在给定卫星频道和固定通信距离限制下,如何通过Prim算法构建最小生成树来优化北极通信网络中不同基站间的通信路径。通过计算不同基站间通信路径的最小总距离,实现网络效率最大化。

Arctic Network

Time Limit: 2000MS

Memory Limit: 65536K

Total Submissions: 5764

Accepted: 2007

题目链接:http://poj.org/problem?id=2349

Description

The Department of NationalDefence (DND) wishes to connect several northern outposts by a wirelessnetwork. Two different communication technologies are to be used inestablishing the network: every outpost will have a radio transceiver and someoutposts will in addition have a satellite channel.
Any two outposts with a satellite channel can communicate via the satellite,regardless of their location. Otherwise, two outposts can communicate by radioonly if the distance between them does not exceed D, which depends of the powerof the transceivers. Higher power yields higher D but costs more. Due topurchasing and maintenance considerations, the transceivers at the outpostsmust be identical; that is, the value of D is the same for every pair ofoutposts.

Your job is to determine the minimum D required for the transceivers. Theremust be at least one communication path (direct or indirect) between every pairof outposts.

Input

The first line of inputcontains N, the number of test cases. The first line of each test case contains1 <= S <= 100, the number of satellite channels, and S < P <= 500,the number of outposts. P lines follow, giving the (x,y) coordinates of eachoutpost in km (coordinates are integers between 0 and 10,000).

Output

For each case, output shouldconsist of a single line giving the minimum D required to connect the network.Output should be specified to 2 decimal points.

Sample Input

1

2 4

0 100

0 300

0 600

150 750

Sample Output

212.13

Source

Waterloolocal 2002.09.28

 

题意:

         m个坐标点,没两个点之间通信,如果某两个点有卫星频道,,那么这两个点可以无限距离通信,如果没有,那么只能在一定范围D内通信,问D的最大值是多少

解题思路:

         m各坐标点抽象成一张完全图图,再用prim算法计算其最小生成树,记录最小生成树每条边的权值,在对边进行从大到小排序,在取该数组中的n个值即可

 

代码:

#include <iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAX 1003
#define VALUE 999999999
using namespace std;


struct distinct
{
    int x;
    int y;
};

double g[MAX][MAX];
double minCost[MAX];
int visited[MAX];
double arr[MAX];
//求两点之间的距离
double dis(int x1,int y1,int x2,int y2)
{
    return sqrt((x2-x1)*(x2-x1)*1.0+(y2-y1)*(y2-y1)*1.0);
}

//求最小生成树
void prim(int n)
{
    int i;
	int temp=0;
    for(i=0;i<n;i++)
    {
        visited[i]=0;
        minCost[i]=g[0][i];
		arr[i]=0;
    }
    minCost[0]=0;
    while(true)
    {
        int t=-1;
        for(i=0;i<n;i++)
        {
            if(visited[i]==0 && (t==-1 || minCost[i]<minCost[t]))
            {
                t=i;
            }
        }
        if(t==-1)
            break;
        visited[t]=1;
		arr[temp]=minCost[t];//保存每一条最短路径
		temp++;
        //printf("%d\t",minCost[t]);
        for(i=0;i<n;i++)
        {
            if(minCost[i]>g[i][t] && g[i][t]!=0)
            {
                minCost[i]=g[i][t];
            }
        }
    }
}

bool cmp(double i,double j)    //比较函数。
{
	return i>j;
}


int main()
{
    int ts;
    int i,j;
    scanf("%d",&ts);
    while(ts--)
    {
        memset(g,0,sizeof(g));
        int n,m;
        distinct d[MAX];
        memset(d,0,sizeof(d));
        scanf("%d%d",&n,&m);
        for(i=0;i<m;i++)
        {
            scanf("%d%d",&d[i].x,&d[i].y);
            for(j=0;j<i;j++)
            {//建立无向完全图
                g[i][j]=dis(d[i].x,d[i].y,d[j].x,d[j].y);
                g[j][i]=g[i][j];
            }
        }
       prim(m);

	   //对数组minCost进行从大到小排序
	   sort(arr,arr+m,cmp);



	   if(n==0)
	   {
	       printf("%.2lf\n",arr[0]);
	   }
	   else
		   printf("%.2lf\n",arr[n-1]);
    }
    return 0;
}


 

内容概要:本研究聚焦于绿电直连型电氢氨园区的优化运行,提出一种集成绿色电力直接供给、电解水制氢及氢气合成氨工艺的综合能源系统架构。通过建立包含风光发电、电解槽、氨合成反应器、储氢罐、电网交互及多类型负荷在内的系统模型,综合考虑绿电直供优先、能量梯级利用与多能互补原则,构建以系统综合运行成本最小化为目标的优化调度模型。研究采用Matlab与Python工具进行算法求解和仿真分析,利用实际气象与负荷数据完成案例验证,评估了不同运行策略下系统的经济性、可再生能源消纳能力与碳减排效益,为新型电氢氨一体化园区的规划与运行提供了理论依据和技术支撑。; 适合人群:具备一定电力系统、新能源或化工背景的研究生、科研人员及从事综合能源系统规划与优化工作的工程技术人员。; 使用场景及目标:①用于科研学习,理解电-氢-氨多能转换系统的建模与优化方法;②为工业园区的低碳化、智能化改造提供技术参考与决策支持;③作为开发类似综合能源管理系统的理论基础。; 阅读建议:此资源包含完整的模型代码、数据与论文,使用者应结合代码仔细研读论文中的模型构建部分,重点关注目标函数与约束条件的设计逻辑,并尝试修改参数进行仿真,以深入掌握优化算法在实际系统中的应用。
内容概要:本文深入探讨了RS485通信协议在芯片行业自动化测试系统中的实际开发与应用,涵盖其关键概念、电气特性、通信机制及与Modbus RTU协议的结合使用。文章重点介绍了差分信号完整性设计、主从时序控制、CRC校验与重传机制等核心技术要点,并通过一个基于Python的完整代码实例,展示了如何实现RS485主站对探针台、自动分选机等芯片测试设备的控制与数据采集。此外,还分析了RS485在晶圆探针台、ATE设备集群和环境监控等典型场景的应用,并展望了其与工业以太网融合、智能化诊断、高速化及AI集成的发展趋势。; 适合人群:具备一定嵌入式系统或工业通信基础,从事芯片测试、自动化设备开发及相关领域的研发人员,尤其是工作1-3年希望提升现场总线应用能力的工程师。; 使用场景及目标:①理解RS485在高干扰芯片测试环境中稳定通信的设计原理;②掌握Modbus RTU协议在Python下的实现方法,用于实际控制探针台、Handler等设备;③构建可靠的数据采集与设备控制系统,支持CRC校验、异常处理和日志追踪;④为后续向高速通信和智能诊断系统升级提供技术储备。; 阅读建议:此资源强调实战开发,建议结合硬件环境动手调试代码,重点关注线程锁、CRC计算、帧解析和超时控制等关键环节,在真实产线中验证通信稳定性,并利用日志系统进行故障分析与优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

疯的世界

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值