【路径规划】快速探索随机树算法(Matlab实现)

 💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现

💥1 概述

快速探索随机树(Fast Randomized Trees)算法是一种用于解决近似最近邻搜索(Approximate Nearest Neighbor Search)问题的算法。它通过构建一棵随机树的集合来加速最近邻搜索过程。 近似最近邻搜索是在大规模数据集中寻找最接近给定查询点的数据点的问题。这在许多机器学习和数据挖掘任务中都是一个关键的子问题。 传统的最近邻搜索算法,如线性扫描或KD树,可能在大规模数据集上效率低下。 构建阶段:随机选择数据集的一个子集,并在该子集上构建一棵随机树。重复此过程以构建多棵随机树,形成一个森林。搜索阶段:对于给定的查询点,通过在随机树上进行递归搜索,找到最接近的叶子节点,并检查该叶子节点中的候选点以确定最终的近似最近邻。快速探索随机树算法通过构建多棵随机树来加速最近邻搜索过程,具有较好的效率和可扩展性,适用于处理大规模数据集的近似最近邻搜索问题。

📚2 运行结果

主函数部分代码:

clear all; close all;

K=2000;
xMin=0; xMax=100;
yMin=0; yMax=100;

xInit=0; yInit=0; %initial point for planner
xGoal=100; yGoal=100; %goal for planner
thresh=5;           %acceptable threshold for solution


tree.vertex(1).x = xInit;
tree.vertex(1).y = yInit;
tree.vertex(1).xPrev = xInit;
tree.vertex(1).yPrev = yInit;
tree.vertex(1).dist=0;
tree.vertex(1).ind = 1; tree.vertex(1).indPrev = 0;

xArray=xInit; yArray = yInit;

figure(1); hold on; grid on;
plot(xInit, yInit, 'ko', 'MarkerSize',10, 'MarkerFaceColor','k');
plot(xGoal, yGoal, 'go', 'MarkerSize',10, 'MarkerFaceColor','g');

for iter = 2:K
    xRand = (xMax-xMin)*rand;
    yRand = (yMax-yMin)*rand;
    dist = Inf*ones(1,length(tree.vertex));
    for j = 1:length(tree.vertex)
        dist(j) = sqrt( (xRand-tree.vertex(j).x)^2 + (yRand-tree.vertex(j).y)^2 );
    end
    [val, ind] = min(dist);
       
    tree.vertex(iter).x = xRand; tree.vertex(iter).y = yRand;
    tree.vertex(iter).dist = val;
    tree.vertex(iter).xPrev = tree.vertex(ind).x;
    tree.vertex(iter).yPrev = tree.vertex(ind).y;
    tree.vertex(iter).ind = iter; tree.vertex(iter).indPrev = ind;
    
    if sqrt( (xRand-xGoal)^2 + (yRand-yGoal)^2 ) <= thresh
        plot([tree.vertex(iter).x; tree.vertex(ind).x],[tree.vertex(iter).y; tree.vertex(ind).y], 'r');
        break
    end
    
    plot([tree.vertex(iter).x; tree.vertex(ind).x],[tree.vertex(iter).y; tree.vertex(ind).y], 'r');
    pause(0);
end

if iter < K
    path.pos(1).x = xGoal; path.pos(1).y = yGoal;
    path.pos(2).x = tree.vertex(end).x; path.pos(2).y = tree.vertex(end).y;
    pathIndex = tree.vertex(end).indPrev;

    j=0;
    while 1
        path.pos(j+3).x = tree.vertex(pathIndex).x;
        path.pos(j+3).y = tree.vertex(pathIndex).y;
        pathIndex = tree.vertex(pathIndex).indPrev;
        if pathIndex == 1
            break
        end
        j=j+1;
    end

    path.pos(end+1).x = xInit; path.pos(end).y = yInit;

🎉3 参考文献

文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。

[1]刁存艺,谢乃明,王玉全.面向智能制造车间的物料拣选“订单分批-路径规划”两阶段联合调度方法[J/OL].工业工程与管理:1-16[2024-06-02].http://kns.cnki.net/kcms/detail/31.1738.T.20240530.0920.002.html.

[2]吴学礼,史思远,宋凯,等.基于改进多因素蚁群算法的路径规划研究[J/OL].无线电工程:1-8[2024-06-02].http://kns.cnki.net/kcms/detail/13.1097.tn.20240528.1602.010.html.

🌈4 Matlab代码实现

图片

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值