当前位置: 首页 > news >正文

网站建设毕业设计个人总结wordpress 所有分类

网站建设毕业设计个人总结,wordpress 所有分类,dw网页设计期末作业源代码,代写1000字多少钱文章目录 一、A星算法简介二、A星算法思想三、A星算法 java代码四、测试 一、A星算法简介 A*算法是一种静态路网中求解最短路径最有效的直接搜索方法#xff0c;也是解决许多搜索问题的有效算法。算法中的距离估算值与实际值越接近#xff0c;最终搜索速度越快。 二、A星算… 文章目录 一、A星算法简介二、A星算法思想三、A星算法 java代码四、测试 一、A星算法简介 A*算法是一种静态路网中求解最短路径最有效的直接搜索方法也是解决许多搜索问题的有效算法。算法中的距离估算值与实际值越接近最终搜索速度越快。 二、A星算法思想 A星A-Star)算法是一种静态路网中求解最短路径最有效的直接搜索方法也是许多其他问题的常用启发式算法。注意——是最有效的直接搜索算法之后涌现了很多预处理算法如CH在线查询效率是A*算法的数千甚至上万倍。 A*算法通过下面这个函数来计算每个节点的优先级 f ( n ) f(n) f(n) 越小状态 n n n 被选择的优先级就越大 公式表示为 f ( n ) g ( n ) h ′ ( n ) f(n)g(n)h(n) f(n)g(n)h′(n), f ( n ) f(n) f(n) 是从初始状态经由状态 n n n 到目标状态的最小代价估计 g ( n ) g(n) g(n) 是在状态空间中从初始状态到状态 n n n 的最小代价 h ′ ( n ) h(n) h′(n) 是从状态 n n n 到目标状态的路径的最小估计代价。对于路径搜索问题状态就是图中的节点代价就是距离 假设 h ( n ) h(n) h(n) 为状态 n n n 到目标状态的路径的最小真实代价。 则保证找到最短路径最优解的条件关键在于估价函数 f ( n ) f(n) f(n) 的选取或者说 h ′ ( n ) h(n) h′(n) 的选取。 以 h ′ ( n ) h(n) h′(n) 表达状态 n n n 到目标状态估计的距离那么 h ′ ( n ) h(n) h′(n) 的选取大致有如下三种情况 如果 h ′ ( n ) h ( n ) h(n) h(n) h′(n)h(n) 这种情况下搜索的点数多搜索范围大效率低。但能得到最优解。如果 h ′ ( n ) h ( n ) h(n)h(n) h′(n)h(n) 此时的搜索效率是最高的。如果 h ′ ( n ) h ( n ) h(n)h(n) h′(n)h(n) 搜索的点数少搜索范围小效率高但不能保证得到最优解。 三、A星算法 java代码 Data public class AStar {// 0是路 1是墙 2是起点 3是终点private int[][] map;// 起点坐标int startI;int startJ;// 终点坐标int endI;int endJ;public AStar(int[][] map) {this.map map;// 获取起点和终点坐标for (int i 0; i map.length; i) {for (int j 0; j map[i].length; j) {if(map[i][j]2){startI i;startJ j;}if(map[i][j]3){endI i;endJ j;}}}}public void solve(){boolean[][] active new boolean[map.length][map[0].length];PriorityBlockingQueueNode priorityBlockingQueue new PriorityBlockingQueue();// 从起点出发ArrayListint[] initPath new ArrayList();initPath.add(new int[]{startI,startJ});priorityBlockingQueue.add(new Node(startI,startJ,initPath,caculateDistance(startI,startJ)));active[startJ][startJ] true;// 开始循环while (!priorityBlockingQueue.isEmpty()){Node node priorityBlockingQueue.poll();if(node.getI()endI node.getJ()endJ){for (int[] p : node.getPath()) {System.out.println(Arrays.toString(p));}System.out.println(最短路长度为node.getPath().size());break;}// 向四周进行扩充// 上int i1 node.getI()-1;int j1 node.getJ();if(isAble(i1,j1,active)){ArrayListint[] path new ArrayList(node.getPath());path.add(new int[]{i1,j1});priorityBlockingQueue.add(new Node(i1,j1,path,caculateDistance(i1,j1)));active[i1][j1] true;}// 下int i2 node.getI()1;int j2 node.getJ();if(isAble(i2,j2,active)){ArrayListint[] path new ArrayList(node.getPath());path.add(new int[]{i2,j2});priorityBlockingQueue.add(new Node(i2,j2,path,caculateDistance(i2,j2)));active[i2][j2] true;}// 左int i3 node.getI();int j3 node.getJ()-1;if(isAble(i3,j3,active)){ArrayListint[] path new ArrayList(node.getPath());path.add(new int[]{i3,j3});priorityBlockingQueue.add(new Node(i3,j3,path,caculateDistance(i3,j3)));active[i3][j3] true;}// 右int i4 node.getI();int j4 node.getJ()1;if(isAble(i4,j4,active)){ArrayListint[] path new ArrayList(node.getPath());path.add(new int[]{i4,j4});priorityBlockingQueue.add(new Node(i4,j4,path,caculateDistance(i4,j4)));active[i4][j4] true;}}}// 判断坐标是否可行private boolean isAble(int i,int j,boolean[][] active){if(i0 || imap.length){return false;}if(j0 || j map[0].length){return false;}if(map[i][j]1 || active[i][j]){return false;}return true;}// 计算距离终点的曼哈顿private int caculateDistance(int i,int j){return Math.abs(i-endI)Math.abs(j-endJ);}DataNoArgsConstructorAllArgsConstructorclass Node implements ComparableNode{int i;int j;Listint[] path;// 距离终点的曼哈顿距离int lenToEnd;Overridepublic int compareTo(Node o) {return Integer.compare(lenToEndpath.size(),o.lenToEndo.path.size());}Overridepublic String toString() {return Node{ i i , j j , lenToEnd lenToEnd };}} }四、测试 public class Test {public static void main(String[] args) {long start System.currentTimeMillis();int[][] map new int[][]{{1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0},{0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0},{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0},{0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0},{0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0},{0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0},{0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0},{0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0},{0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0},{0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0},{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0},{0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0},{0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0},{0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0},{0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0},{0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1},{0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1},{0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1},{0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0},};new AStar(map).solve();System.out.println(用时(System.currentTimeMillis()-start)ms);} }控制台输出 [1, 4] [1, 5] [1, 6] [1, 7] [1, 8] [1, 9] [2, 9] [2, 10] [2, 11] [3, 11] [4, 11] [5, 11] [6, 11] [7, 11] [8, 11] [9, 11] [10, 11] [10, 12] [11, 12] [12, 12] [12, 11] [13, 11] [14, 11] [15, 11] [16, 11] [17, 11] [17, 12] [17, 13] [17, 14] [18, 14] [19, 14] [19, 13] [19, 12] 最短路长度为33 用时6ms上面输出的例如 [1, 4] [1, 5] [1, 6] 的文字代表最短路径从上往下看 即从14点走到15点再从15点走到16点
http://www.hkea.cn/news/14575659/

相关文章:

  • 做网站好看的背景图片免费网站软件大全
  • 2021年十大购物网站排名用手机搭建网站
  • 医院网站建设的特点网站建设容易出现的问题
  • 建设银行网站首页如何网站托管
  • 网站平台建设是什么外贸客户搜索软件
  • 网站免费视频网站建设制作公司知道万维科技
  • 网站导航三角怎么做做网站写的代号好跟不好的区别
  • 深圳nft网站开发公司镇海企业建站
  • git网站开发中国制造网效果怎么样
  • 网站的域名都有哪些问题影视网站建设目的
  • 服务器与网站吗大连旅顺房价
  • 做网站建设找哪家好win8.1 做网站服务器
  • 软件开发全流程网站优化最为重要的内容是
  • wordpress 做网课网站科技类特长生有哪些项目
  • 长沙市做网站的网站吉林省交通建设集团有限公司网站
  • 网站栏目设置完整度建设小白怎么做网页
  • 设计logo网站知乎招聘网站做销售
  • 怎么优化网站排名才能起来广东vs北控直播
  • 湖南高端网站制作公司如何制作一网站
  • 沈阳做网站在哪桂林红豆网论坛
  • 网站建设常用的6大布局加代码网页游戏大全slg
  • 中跃建设集团网站吗WordPress怎么两个标题
  • 精准扶贫网站建设的意义windows优化大师的作用
  • 商丘做网站公司新站seo快速收录网站内容页wordpress响应式
  • 个人免费网站平台哪个好网站建设开发协议
  • 手机网站页面设计要求seo比较好的优化
  • 长春网页建站模板厦门网站设计大概多少钱
  • 决定网站打开的速度网站系统建设需要什么资质
  • 网页与网站设计实验总结大连网络seo公司
  • 做物流的网站有哪些功能四川省建筑施工企业安全员考试