知情搜索(二)-找到最优解

普通分支界定算法

分支界定算法是努力寻找一条最优路径,为了确保找到一条到达目的地的路径,它找到路径后会继续生成部分路径,直到每条路径的代价大于或等于所找到的路径的代价。不具备启发值。

伪代码如下:

//Branch Bound Search
Branch_Bound(Root_Node, goal)
{
    Create Queue Q
    Insert Root Node into Q
    while(Q_Is_Not)
    {
        G = Remove from Q
        If(G=goal) Return the path from Root_Node to G;
        else
        Insert children of G into the Q
        Sort Q by path length
    }//and while
    Return failure
}

使用低估值的分支定界法

具有低估值的分支界定法是获得最佳解且具备启发性的方式。

 

采用动态规划的分支界定法

该算法给出如下建议:如果两条或者多条路径到达一个公共节点,只有到达这个公共节点具有最小代价的路径才被保存(其他路径删除)。

伪代码如下:

// Branch and Bound with Dynamic Programming
B_B_W_Dynamic_Programming (Root_Node, goal)
{
    Create Queue Q
    Insert Root_Node into Q
    while(Q_Is_Not_Empty)
    {
        G = Remove from Q
        Mark G visited
            If this mode has been visited previously, retain only the shortest path to G
        If(G = goal) Return the Path from Root_Node to G
        Insert the children of G which have not been previously visited into the Q 
    }
    return failure
}

 

A*搜索 

该方法采用具有剩余距离估计值和动态规划的分支定界法。

伪代码如下:

// A* Search
A* Search (Root_Node, Goal)
{
    Create Queue Q
    Insert Root_Node into Q
    while(Q_Is_Not_Empty)
    {
        G = Remove from Q
        Mark G visited
        If(G=goal) Return the path from Root_Node to G;
        Else
        Add each child node's estimated distance to current distance
        Insert the children of G which have not been previously visited into the Q 
        Sort Q by the path length;
    } 
    Return failure
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Travis.X

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

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

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

打赏作者

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

抵扣说明:

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

余额充值