hdu 4318 (最短路)

本文介绍了一种解决电力传输中能量损失最小化的算法。通过将能量损失转换为对数形式,利用最短路径算法来找到从一个节点到另一个节点的最优路径。具体实现采用Dijkstra算法并结合对数运算。

Power transmission

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1649    Accepted Submission(s): 615


Problem Description
The project West-East power transmission is famous around the world. It transmits the electricity from western areas to east China. There are many nodes in the power system. Each node is connected with several other nodes in the system by cable. Power can be only transmitted between two connected nodes. For each node, it can’t send power to two or more other nodes at the same time. 
As we have all known, power will be loss during the transmission. Bob is the chief engineer of the project. He wants to build a transmission line which send power from one node to another node and minimize the power loss at the same time. Now he asks you to help him solve the problem.
 

Input
There are several test cases. For each test case, the first line contains an integer N (0 < N ≤ 50000) which represents the number of nodes in the power system. Then there will be N groups of data following. For the i-th(0 < i ≤ N) group, the first line is an integer ki (ki ≤ 50), which means the node i is connected with ki nodes. The rest of the i-th group data are divided into ki lines. Each line contains an integer ai (0 < ai ≤ N, ai ≠ i) and an integer bi (0 ≤ bi ≤ 100), which represents power can be transmitted from node i to ai and will loss bi% while transmitting. The last line of input data contains three integers separated by single spaces. The first one is s, the second is t (0 < s, t ≤ N), and the third is the total power M (0 < M ≤ 10^6) at node s.
 

Output
For each test case, output the minimum of loss power while transmitting from node s to node t. The result should be printed with two digits to the right of the decimal point. If power cannot be transmitted from node s to node t, output “IMPOSSIBLE!” in a line.
 

Sample Input
  
4 2 2 50 3 70 2 1 30 4 20 2 1 10 4 40 0 1 4 100
 

Sample Output
  
60.00
Hint
In the sample, the best transmission line is 1 -> 2 -> 4, loss power is 100 * 50% + 100 * (100%-50%)*20% = 60.00
 

Author
TJU
 

Source
 

Recommend
zhuyuanchen520
 
每条边经过后有一个百分比的损耗,求从起点到终点最多剩余能量。开始想用dp的记忆化搜索写,爆栈了。因为最后的结果是整条路径上所有百分比的乘积,对于这种连乘的最优化问题可以通过取对数转化为为累加的最优化问题,这样就把问题转化成最短路了。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<set>
#include<cmath>
using namespace std;
typedef long long LL;
typedef pair<double,int> P;
const int maxn = 50000 + 5;
const int INF = 1000000000;

int n;
struct Edge{
    int to;
    double dis;
    Edge(int to,double dis){
        this -> to = to;
        this -> dis = dis;
    }
};

double d[maxn];
int vis[maxn];
vector<Edge> G[maxn];

void Dij(int x){
    priority_queue<P,vector<P>,greater<P> > Q;
    memset(vis,0,sizeof(vis));
    for(int i = 0;i <= n;i++) d[i] = 10000.0;
    Q.push(P(0,x));
    while(!Q.empty()){
        P p = Q.top();Q.pop();
        int id = p.second;
        double dis = p.first;
        if(vis[id] == 1) continue;
        vis[id] = 1;
        d[id] = dis;
        for(int i = 0;i < G[id].size();i++){
            Edge edgs = G[id][i];
            int to = edgs.to;
            double der = edgs.dis;
            if(d[to] > d[id] + der){
                d[to] = d[id] + der;
                Q.push(P(d[to],to));
            }
        }
    }
}

int main(){
    while(scanf("%d",&n) != EOF){
        for(int i = 0;i < maxn;i++) G[i].clear();
        for(int i = 1;i <= n;i++){
            int x;scanf("%d",&x);
            while(x--){
                int to;
                double dis;
                scanf("%d%lf",&to,&dis);
                G[i].push_back(Edge(to,-log(1.0-dis/100)));
            }
        }
        int s,t,total;
        scanf("%d%d%d",&s,&t,&total);
        Dij(s);
        double ans = d[t];
        printf("%.2lf\n",total*(1-exp(-ans)));
    }
    return 0;
}


【无人机】基于改进粒子群算法的无人机路径规划研究[和遗传算法、粒子群算法进行比较](Matlab代码实现)内容概要:本文围绕基于改进粒子群算法的无人机路径规划展开研究,重点探讨了在复杂环境中利用改进粒子群算法(PSO)实现无人机三维路径规划的方法,并将其与遗传算法(GA)、标准粒子群算法等传统优化算法进行对比分析。研究内容涵盖路径规划的多目标优化、避障策略、航路点约束以及算法收敛性和寻优能力的评估,所有实验均通过Matlab代码实现,提供了完整的仿真验证流程。文章还提到了多种智能优化算法在无人机路径规划中的应用比较,突出了改进PSO在收敛速度和全局寻优方面的优势。; 适合人群:具备一定Matlab编程基础和优化算法知识的研究生、科研人员及从事无人机路径规划、智能优化算法研究的相关技术人员。; 使用场景及目标:①用于无人机在复杂地形或动态环境下的三维路径规划仿真研究;②比较不同智能优化算法(如PSO、GA、蚁群算法、RRT等)在路径规划中的性能差异;③为多目标优化问题提供算法选型和改进思路。; 阅读建议:建议读者结合文中提供的Matlab代码进行实践操作,重点关注算法的参数设置、适应度函数设计及路径约束处理方式,同时可参考文中提到的多种算法对比思路,拓展到其他智能优化算法的研究与改进中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值