{"id":983,"date":"2016-12-05T15:29:00","date_gmt":"2016-12-05T07:29:00","guid":{"rendered":"http:\/\/yaochenkun.site\/?p=983"},"modified":"2024-11-23T15:54:02","modified_gmt":"2024-11-23T07:54:02","slug":"generesult_article","status":"publish","type":"post","link":"http:\/\/yaochenkun.site\/index.php\/2016\/12\/05\/generesult_article\/","title":{"rendered":"\u9057\u4f20\u7b97\u6cd5\u89e3 TSP3-\u6548\u679c\u9a8c\u8bc1"},"content":{"rendered":"<h3>\u5f15\u8a00<\/h3>\n<p style=\"text-align: justify;\">\u672c\u7ae0\u662f\u9057\u4f20\u7b97\u6cd5\u6c42\u89e3TSP\u95ee\u9898\u7684\u6700\u540e\u4e00\u7ae0\uff0c\u4e3b\u8981\u505a\u4e00\u4e9b\u6536\u5c3e\u7684\u5de5\u4f5c\u3002\u4ecb\u7ecd\u4e00\u4e0b\u5982\u4f55\u7528GeneticAlgorithm\u8fd9\u4e2a\u7c7b\u53bb\u9a71\u52a8\u9057\u4f20\u7b97\u6cd5\u5de5\u4f5c\u6d41\u7a0b\u7684\u6267\u884c\uff0c\u4ee5\u53ca\u9057\u4f20\u7b97\u6cd5\u6240\u6d89\u53ca\u7684\u53ef\u914d\u7f6e\u53c2\u6570Constant\uff0c\u6700\u540e\u7ed9\u51fa\u9057\u4f20\u7b97\u6cd5\u5206\u522b\u572810\u4e2a\u57ce\u5e02\u300120\u4e2a\u57ce\u5e02\u548c31\u4e2a\u57ce\u5e02\u7684TSP\u95ee\u9898\u4e2d\u7684\u6548\u679c\u8868\u73b0\u3002<\/p>\n<h3>\u5de5\u4f5c\u6d41\u7a0b<\/h3>\n<p style=\"text-align: justify;\">\u6b63\u5982\u524d\u9762\u63d0\u5230\u8fc7\u7684\uff0c\u9057\u4f20\u7b97\u6cd5\u5148\u540e\u7ecf\u8fc7\u521d\u59cb\u5316\u79cd\u7fa4\u3001\u8ba1\u7b97\u9002\u5e94\u5ea6\u3001\u9009\u62e9\u64cd\u4f5c\u3001\u4ea4\u53c9\u64cd\u4f5c\u3001\u53d8\u5f02\u64cd\u4f5c\u548c\u6536\u655b\u6761\u4ef6\u5224\u65ad\uff0c\u6700\u540e\u9009\u51fa\u9002\u5e94\u5ea6\u6700\u4f18\u7684\u4e2a\u4f53\u4f5c\u4e3a\u6700\u7ec8\u89e3\u3002\u6240\u4ee5\u73b0\u5728\u6211\u4eec\u9700\u8981\u628a\u524d\u9762\u7684\u5404\u79cd\u64cd\u4f5c\u7ec4\u5408\u8d77\u6765\uff0c\u4f7f\u5f97\u80fd\u5b8c\u6574\u5730\u6267\u884c\u4e00\u8f6e\u9057\u4f20\u7b97\u6cd5\u7684\u5de5\u4f5c\u6d41\u7a0b\uff0c\u5728\u8fd9\u4e2a\u57fa\u7840\u4e0a\uff0c\u518d\u8fed\u4ee3\uff08\u9057\u4f20\uff09\u82e5\u5e72\u4ee3\uff0c\u6700\u540e\u6536\u655b\u5230\u67d0\u4e2a\u8f83\u4f18\u89e3\u3002<\/p>\n<p style=\"text-align: justify;\">\u843d\u5b9e\u5230\u4ee3\u7801\u4e0a\uff0c\u6211\u4eec\u4ecd\u91c7\u7528\u9762\u5411\u5bf9\u8c61\u601d\u60f3\uff0c\u5c06initSpeciesList()\u3001calFitness()\u3001select()\u3001cross()\u548cmutate()\u8fd9\u4e9b\u65b9\u6cd5\u5f52\u5728GeneticAlogrithm\u7c7b\u4e2d\uff0c\u7136\u540e\u987a\u6b21\u8c03\u7528\uff0c\u5982\u4e0b\u9762\u6240\u793a\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/\/\u5f00\u59cb\u9057\u4f20\r\nSpeciesNode run()\r\n{\r\n    \/\/\u521b\u5efa\u521d\u59cb\u79cd\u7fa4\r\n    List&lt;SpeciesNode&gt; speciesList = initSpeciesList();\r\n    \r\n    \/\/\u9057\u4f20\u8fed\u4ee3\r\n    for(int i=1;i&lt;=Constant.DEVELOP_NUM;i++)\r\n    {\r\n        \/\/\u9009\u62e9\r\n        select(speciesList);\r\n        \r\n        \/\/\u4ea4\u53c9\r\n        crossover(speciesList);\r\n        \r\n        \/\/\u53d8\u5f02\r\n        mutate(speciesList);\r\n    }\t\r\n    \r\n    \/\/\u8fd4\u56de\u6700\u4f18\u89e3\r\n    return getBest(speciesList);\r\n}<\/pre>\n<h3 style=\"text-align: justify;\">\u53c2\u6570\u914d\u7f6e<\/h3>\n<p style=\"text-align: justify;\">\u4ece\u524d\u9762\u5bf9\u9057\u4f20\u7b97\u6cd5\u7684\u8bb2\u8ff0\u4e2d\u4e0d\u96be\u53d1\u73b0\uff0c\u7b97\u6cd5\u6d89\u53ca\u8bb8\u591a\u4e0d\u53d8\u7684\u5e38\u91cf\uff0c\u6bd4\u5982\u5730\u56fe\u6570\u636e\u3001\u79cd\u7fa4\u6570\u3001\u8fdb\u5316\u4ee3\u6570\u3001\u4ea4\u53c9\u6982\u7387\u3001\u53d8\u5f02\u6982\u7387\uff0c\u751a\u81f3\u66f4\u591a\u5bf9\u9057\u4f20\u7b97\u6cd5\u6539\u8fdb\u540e\u6d89\u53ca\u7684\u53c2\u6570\uff0c\u5199\u51fa\u6765\u5c31\u50cf\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/\/\u5e38\u91cf\u7c7b\r\npublic class Constant \r\n{\r\n    \/\/\u9057\u4f20\u7b97\u6cd5\u53c2\u6570\r\n    static final int SPECIES_NUM = 200; \/\/\u79cd\u7fa4\u6570\r\n    static final int DEVELOP_NUM = 100; \/\/\u8fdb\u5316\u4ee3\u6570\r\n    static final float tp = 0.25; \/\/\u7cbe\u82f1\u590d\u5236\u6bd4\u91cd\r\n    static final float pcl = 0.6f, pch = 0.95f;\/\/\u4ea4\u53c9\u6982\u7387\r\n    static final float pm = 0.4f;\/\/\u53d8\u5f02\u6982\u7387\r\n    \r\n\u00a0\u00a0\u00a0\u00a0\/\/\u5730\u56fe\u6570\u636e\r\n\u00a0\u00a0\u00a0\u00a0static\u00a0int\u00a0CITY_NUM;\u00a0\/\/\u57ce\u5e02\u6570\r\n\u00a0\u00a0\u00a0\u00a0static\u00a0final\u00a0float[][]\u00a0disMap;\u00a0\/\/\u8def\u7ebf\u957f\u5ea6\r\n    static\r\n    {\r\n        \/\/\u57ce\u5e02\u5750\u6807\r\n        int[][] cityPosition={\r\n                {60,200},{180,200},{80,180},{140,180},\r\n                {20,160},{100,160},{200,160},{140,140},\r\n                {40,120},{100,120},{180,100},{60,80},\r\n                {120,80},{180,60},{20,40},{100,40},\r\n                {200,40},{20,20},{60,20},{160,20}}; \/\/20\u4e2a\u57ce\u5e02\uff08\u6700\u4f18\u89e3:870\uff09\r\n\r\n        \/\/\u521d\u59cb\u5316\u8ba1\u7b97\u5b8c\u5168\u56fe\u6240\u6709\u8def\u7ebf\u957f\u5ea6\r\n        CITY_NUM=cityPosition.length;\r\n        disMap=new float[CITY_NUM][CITY_NUM];\r\n        for(int i=0;i&lt;CITY_NUM;i++)\r\n        {\r\n            for(int j=i;j&lt;CITY_NUM;j++)\r\n            {\r\n                float dis = (float) Math.sqrt(Math.pow((cityPosition[i][0] - cityPosition[j][0]),2) + Math.pow((cityPosition[i][1] - cityPosition[j][1]),2));\r\n                \r\n                disMap[i][j]=dis;\r\n                disMap[j][i]=disMap[i][j];\r\n            }\r\n        }\t\r\n    }\r\n}<\/pre>\n<h3>\u5b9e\u9a8c\u7ed3\u679c<\/h3>\n<p style=\"text-align: justify;\">Constant\u7c7b\u4e2d\u7684cityPosition\u53c2\u6570\u7528\u6765\u914d\u7f6e\u57ce\u5e02\u7684\u5750\u6807\u6570\u636e\uff0c\u6240\u4ee5\u6211\u5206\u522b\u9009\u53d6\u4e86\u7f51\u4e0a\u4e00\u4e9b\u516c\u8ba4\u768410\u4e2a\u57ce\u5e02\u300120\u4e2a\u57ce\u5e02\u548c31\u4e2a\u57ce\u5e02\u7684\u5750\u6807\u6570\u636e\uff0c\u53ca\u5b83\u4eec\u7684\u6700\u4f18\u89e3\uff0c\u6765\u4e0e\u6211\u5199\u7684\u9057\u4f20\u7b97\u6cd5\u5f97\u5230\u7684\u89e3\u8fdb\u884c\u5bf9\u6bd4\u3002\u4e0b\u9762\u662f\u516c\u8ba4\u7684\u5730\u56fe\u6570\u636e\uff1a<\/p>\n\n<table id=\"tablepress-3\" class=\"tablepress tablepress-id-3\">\n<thead>\n<tr class=\"row-1 odd\">\n\t<th class=\"column-1\">\u57ce\u5e02\u6570<\/th><th class=\"column-2\">\u5750\u6807\u96c6\u5408<\/th><th class=\"column-3\">\u6700\u4f18\u89e3<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-hover\">\n<tr class=\"row-2 even\">\n\t<td class=\"column-1\">10<\/td><td class=\"column-2\">(0,0),(12,32),(5,25),(8,45),(33,17),<br \/>\n(25,7),(15,15),(15,25),(25,15),(41,12)<\/td><td class=\"column-3\">147.34<\/td>\n<\/tr>\n<tr class=\"row-3 odd\">\n\t<td class=\"column-1\">20<\/td><td class=\"column-2\">(60,200),(180,200),(80,180),(140,180),(20,160),<br \/>\n(100,160),(200,160),(140,140),(40,120),(100,120),<br \/>\n(180,100),(60,80),(120,80),(180,60),(20,40),<br \/>\n(100,40),(200,40),(20,20),(60,20),(160,20)<\/td><td class=\"column-3\">870.26<\/td>\n<\/tr>\n<tr class=\"row-4 even\">\n\t<td class=\"column-1\">31<\/td><td class=\"column-2\">(1304,2312),(3639,1315),(4177,2244),(3712,1399),(3488,1535),<br \/>\n(3326,1556),(3238,1229),(4196,1004),(4312,790),(4386,570),<br \/>\n(3007,1970),(2562,1756),(2788,1491),(2381,1676),(1332,695),<br \/>\n(3715,1678),(3918,2179),(4061,2370),(3780,2212),(3676,2578),<br \/>\n(4029,2838),(4263,2931),(3429,1908),(3507,2367),(3394,2643),<br \/>\n(3439,3201),(2935,3240),(3140,3550),(2545,2357),(2778,2826),<br \/>\n(2370,2975)<\/td><td class=\"column-3\">14705.55<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<!-- #tablepress-3 from cache -->\n<p>\u4e0b\u9762\u662f\u672c\u6587\u9057\u4f20\u7b97\u6cd5\u6c42\u5f97\u7684\u6700\u77ed\u8def\u7ebf\u53ca\u957f\u5ea6\u6570\u636e\uff1a<\/p>\n\n<table id=\"tablepress-4\" class=\"tablepress tablepress-id-4\">\n<thead>\n<tr class=\"row-1 odd\">\n\t<th class=\"column-1\">\u57ce\u5e02\u6570<\/th><th class=\"column-2\">\u6700\u77ed\u8def\u957f(\u6700\u4f18\u89e3)<\/th><th class=\"column-3\">\u6700\u77ed\u8def\u957f(\u9057\u4f20\u7b97\u6cd5)<\/th><th class=\"column-4\">\u6700\u77ed\u8def\u5f84(\u9057\u4f20\u7b97\u6cd5)<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-hover\">\n<tr class=\"row-2 even\">\n\t<td class=\"column-1\">10<\/td><td class=\"column-2\">147.34<\/td><td class=\"column-3\">147.34<\/td><td class=\"column-4\">8,7,9,5,10,6,1,3,4,2,8<\/td>\n<\/tr>\n<tr class=\"row-3 odd\">\n\t<td class=\"column-1\">20<\/td><td class=\"column-2\">870.26<\/td><td class=\"column-3\">897.53<\/td><td class=\"column-4\">6,3,1,5,9,10,13,12,15,18,<br \/>\n19,16,20,17,14,11,7,2,4,8,6<\/td>\n<\/tr>\n<tr class=\"row-4 even\">\n\t<td class=\"column-1\">31<\/td><td class=\"column-2\">14705.55<\/td><td class=\"column-3\">15647.02<\/td><td class=\"column-4\">2,4,16,5,6,23,11,26,21,22,<br \/>\n18,3,17,19,24,20,25,30,29,28,<br \/>\n27,31,1,15,14,12,13,7,10,9,8,2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<!-- #tablepress-4 from cache -->\n<h3>\u7ed3\u8bed<\/h3>\n<p style=\"text-align: justify;\">\u4ece\u4e0a\u8868\u4e0d\u96be\u53d1\u73b0\uff0c\u968f\u7740\u95ee\u9898\u89c4\u6a21\u7684\u6269\u5927\uff0c\u9057\u4f20\u7b97\u6cd5\u53d1\u73b0\u5168\u5c40\u6700\u4f18\u89e3\u7684\u51e0\u7387\u4ecd\u7136\u5f88\u5927\uff08\u901a\u8fc7\u5bf9\u6bd4\u540e\u7eed\u6587\u7ae0<span style=\"color: #7cc576;\"><a style=\"color: #7cc576;\" href=\"http:\/\/yaochenkun.site\/index.php\/2016\/12\/12\/ant3_article\/\">\u8681\u7fa4\u7b97\u6cd5\u89e3TSP(3)-\u6548\u679c\u9a8c\u8bc1<\/a><\/span>\u53ef\u4ee5\u53d1\u73b0\uff09\uff0c\u8fd9\u4e0d\u5931\u4e3a\u5b83\u7684\u4f18\u70b9\u3002\u4f46\u7f3a\u70b9\u662f\u6536\u655b\u6027\u4e0d\u9ad8\uff0c\u8fd9\u662f\u56e0\u4e3a\u53d7\u9009\u62e9\u7b97\u5b50\u3001\u4ea4\u53c9\u7b97\u5b50\u3001\u53d8\u5f02\u7b97\u5b50\u7684\u5f71\u54cd\u8f83\u5927\uff0c\u89e3\u7fa4\u5bb9\u6613\u6ce2\u52a8\uff0c\u6545\u800c\u4e0d\u592a\u7a33\u5b9a\uff0c\u6709\u65f6\u9700\u8981\u6d88\u8017\u66f4\u591a\u7684\u8ba1\u7b97\u65f6\u95f4\u53bb\u5f25\u8865\u6536\u655b\u6027\u4e0d\u597d\u7684\u7f3a\u9677\u3002<\/p>\n<p style=\"text-align: justify;\">\u9057\u4f20\u7b97\u6cd5\u7684\u7528\u9014\u663e\u7136\u4e0d\u4ec5\u9650\u4e8eTSP\u95ee\u9898\uff0c\u4efb\u4f55\u9700\u8981\u4f18\u5316\u6a21\u578b\u53c2\u6570\u7684\u95ee\u9898\u90fd\u53ef\u4ee5\u7528\u5b83\u6765\u89e3\u51b3\uff0c\u6bd4\u5982\u6392\u8bfe\u6392\u73ed\u3001\u673a\u5668\u4eba\u8def\u5f84\u89c4\u5212\u751a\u81f3\u5e94\u7528\u4e8e\u4eba\u5de5\u795e\u7ecf\u7f51\u7edc\u7b49\uff0c\u4ece\u800c\u66f2\u7ebf\u5f0f\u5730\u907f\u514d\u4e86\u5229\u7528\u7a77\u4e3e\u65b9\u6cd5\u4ea7\u751f\u7684\u9ad8\u6602\u6210\u672c\u4e0e\u4f4e\u6548\u3002<\/p>\n<p style=\"text-align: justify;\">\u9057\u4f20\u7b97\u6cd5\u6c42\u89e3TSP\u95ee\u9898\u7684\u76f8\u5173\u5185\u5bb9\u5c31\u5199\u5230\u8fd9\u91cc\u5566\u3002\u5f53\u7136\u9700\u8981\u58f0\u660e\u7684\u662f\uff0c\u672c\u6587\u4ec5\u4ec5\u662f\u7ed9\u51fa\u4e86\u4e00\u4e2a\u6734\u7d20\u9057\u4f20\u7b97\u6cd5\u7684\u5b9e\u73b0\u65b9\u6848\uff0c\u66f4\u591a\u5bf9\u5176\u4f18\u5316\u7684\u65b9\u6848\u53ef\u4ee5\u53bb\u7f51\u4e0a\u67e5\u9605\uff0c\u76f8\u4fe1\u90a3\u91cc\u80af\u5b9a\u8fd8\u6709\u4e00\u7247\u65b0\u7684\u5929\u5730\u3002\u7136\u540e\u6ce8\u610f\u672c\u6587\u7ed9\u51fa\u7684\u4ee3\u7801\u90fd\u662f\u4e00\u4e9b\u4ee3\u7801\u7247\u6bb5\uff0c\u5e76\u4e0d\u80fd\u5b8c\u6574\u8fd0\u884c\uff0c\u6709\u7684\u5730\u65b9\u4e0d\u662f\u63a2\u8ba8\u7684\u6838\u5fc3\u5185\u5bb9\uff0c\u6240\u4ee5\u751a\u81f3\u7d22\u6027\u7701\u53bb\u4e86\u3002\u5982\u679c\u9700\u8981\u5b8c\u6574\u4ee3\u7801\u53ef\u4ee5\u5728<span style=\"color: #7cc576;\"><a style=\"color: #7cc576;\" href=\"https:\/\/github.com\/yaochenkun\/TSP-GeneticAlgorithm\">\u6211\u7684GitHub<\/a><\/span>\u4e0a\u4e0b\u8f7d\u3002\u540e\u7eed\u4f1a\u518d\u5199\u4e00\u4e2a\u7528\u201c\u8681\u7fa4\u7b97\u6cd5\u201d\u6c42\u89e3TSP\u95ee\u9898\u7684\u7cfb\u5217\u6587\u7ae0\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00 \u672c\u7ae0\u662f\u9057\u4f20\u7b97\u6cd5\u6c42\u89e3TSP\u95ee\u9898\u7684\u6700\u540e\u4e00\u7ae0\uff0c\u4e3b\u8981\u505a\u4e00\u4e9b\u6536\u5c3e\u7684\u5de5\u4f5c\u3002\u4ecb\u7ecd\u4e00\u4e0b\u5982\u4f55\u7528GeneticAlgorit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56,46],"tags":[],"_links":{"self":[{"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/posts\/983"}],"collection":[{"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/comments?post=983"}],"version-history":[{"count":24,"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/posts\/983\/revisions"}],"predecessor-version":[{"id":3175,"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/posts\/983\/revisions\/3175"}],"wp:attachment":[{"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/media?parent=983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/categories?post=983"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yaochenkun.site\/index.php\/wp-json\/wp\/v2\/tags?post=983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}