{"id":348594,"date":"2023-06-09T21:00:42","date_gmt":"2023-06-09T21:00:42","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=348594"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=348594","title":{"rendered":"<span>\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u2014 \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ce\/764\/303\/8ce764303dcfa462f9adbe86a3322342.png\" width=\"950\" height=\"611\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ce\/764\/303\/8ce764303dcfa462f9adbe86a3322342.png\"\/><\/figure>\n<blockquote>\n<p><em>\u0412\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0441\u0430\u043c\u044b\u0439 \u0442\u0440\u0443\u0434\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u2014 \u043d\u0430 \u043d\u0435\u043c \u0432\u044b \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043e\u0432.<\/em><\/p>\n<p><em>\u0428\u0430\u0440\u043b\u044c \u0434\u0435 \u0413\u043e\u043b\u043b\u044c<\/em><\/p>\n<\/blockquote>\n<p>\u0418 \u0441\u043d\u043e\u0432\u0430 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430. \u041c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0432 \u043c\u0438\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/711708\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435<\/a> \u043c\u044b \u0443\u0436\u0435 \u0443\u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432 \u0433\u0440\u0430\u0444\u0435 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0435\u043d \u0432\u0435\u0440\u0448\u0438\u043d. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0445\u043e\u0447\u0443 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0443\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0435\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044e \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445 \u043e\u0442 \u0442\u044b\u0441\u044f\u0447\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<hr\/>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 n x n, \u0433\u0434\u0435 n \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0430, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c. <\/p>\n<pre><code class=\"python\">[[  0 106  71  81  75 140 108 146 262 174]  [106   0 162 184  92 130  36 157 270 204]  [ 71 162   0  38  88 134 151 123 223 130]  [ 81 184  38   0 121 171 179 161 257 164]  [ 75  92  88 121   0  65  69  77 196 118]  [140 130 134 171  65   0  96  33 140  84]  [108  36 151 179  69  96   0 124 235 173]  [146 157 123 161  77  33 124   0 119  52]  [262 270 223 257 196 140 235 119   0  93]  [174 204 130 164 118  84 173  52  93   0]]<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0432 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u043e\u0439 \u0442\u043e\u0447\u0435\u043a.<\/p>\n<pre><code class=\"python\">def distance(point1, point2):     return math.hypot(point2[0] - point1[0], point2[1] - point1[1])<\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u043b\u0435\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u044e\u0449\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0431\u044b\u043b\u0430 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438, \u0430 \u0441\u0430\u043c\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u043d\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444:<\/p>\n<pre><code class=\"python\">import networkx as nx init_graph = nx.complete_graph(n)<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">def matrix_count(a):     # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0451\u0431\u0435\u0440 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b      return (a * a - a) \/\/ 2 <\/code><\/pre>\n<p>\u041f\u0440\u0438 n = 1000 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f 499500 \u0440\u0451\u0431\u0435\u0440, \u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<p>\u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (LP), \u0432\u0435\u0434\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u044d\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0432 \u0440\u0430\u0441\u0447\u0451\u0442\u0430\u0445. <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435\u044f\u0432\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c n&#8217; x m&#8217;, \u0433\u0434\u0435 m&#8217; > n&#8217;, n&#8217; &#8212; \u0447\u0438\u0441\u043b\u043e \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, m&#8217; &#8212; \u0447\u0438\u0441\u043b\u043e \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432. (\u0417\u0434\u0435\u0441\u044c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B8%D0%BC%D0%BF%D0%BB%D0%B5%D0%BA%D1%81-%D0%BC%D0%B5%D1%82%D0%BE%D0%B4\" rel=\"noopener noreferrer nofollow\">\u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441 \u043c\u0435\u0442\u043e\u0434<\/a> \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0431\u0430\u0437\u0438\u0441\u043e\u043c. \u0425\u043e\u0442\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0441 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0431\u0430\u0437\u0438\u0441\u043e\u043c, \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043d\u0435\u0442.)<\/p>\n<p>\u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 LP \u0441 \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430, \u0430 \u044d\u0442\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0413\u0431\u0430\u0439\u0442.<\/p>\n<p>\u041c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441 \u043e\u0431\u044a\u0451\u043c\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<\/li>\n<\/ol>\n<ol>\n<li>\n<p>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0438\u0436\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e. \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b (\u0420\u0430\u0437\u0440\u0435\u0436\u0451\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u00a0\u2014\u00a0\u043c\u0430\u0442\u0440\u0438\u0446\u0430\u00a0\u0441 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438).<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">[[1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 0 0]  [1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 1 0]  [0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1]  [0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 1]  [0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]  [0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]  [0 0 1 1 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 1 0 1 1 1 0 1 0 1 0 0 1 0 0 1 1 0]]<\/code><\/pre>\n<p>\u0412 \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e \u0432 python \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 scipy \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438, \u043d\u043e \u0438 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u0438 \u0437\u0430\u0434\u0430\u0447 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0446\u0435\u043b\u0435\u0439, \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u043f\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u044f \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0432\u0435\u0441\u043e\u043c\u044b\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445, \u043a\u0430\u043a \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b, \u0442\u0430\u043a \u0438 \u043f\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>a) <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.optimize.linprog.html\" rel=\"noopener noreferrer nofollow\">scipy.optimize.linprog<\/a><br \/>b) <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.optimize.milp.html\" rel=\"noopener noreferrer nofollow\">scipy.optimize.milp<\/a><\/p>\n<p>\u041e\u0431\u0430 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/sparse.html\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u0442\u0440\u0438\u0446<\/a>.<\/p>\n<pre><code class=\"python\">res = optimize.linprog(c=objective_function, bounds=variable_bounds, A_eq=equality_a, b_eq=equality_b, A_ub=inequalities_a, b_ub=inequalities_b, method='highs', integrality=1, options={'disp':True}) res = optimize.milp(c=objective_function, bounds=variable_bounds, constraints=optimize.LinearConstraint(matrix_a, lower_bound, upper_bound), integrality=1, options={'disp':True})<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e linprog \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0430 \u0434\u0432\u0430 \u0431\u043b\u043e\u043a\u0430: \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430. Milp \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0434\u0438\u043d \u0431\u043b\u043e\u043a \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432 \u0441 \u0432\u0435\u0440\u0445\u043d\u0438\u043c \u0438 \u043d\u0438\u0436\u043d\u0438\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c (\u0434\u043b\u044f \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u0435 \u0438 \u043d\u0438\u0436\u043d\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c).<\/p>\n<ol start=\"2\">\n<li>\n<p>\u0423\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0443, \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0440\u0451\u0431\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438. \u0422\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0431\u044a\u0451\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0441\u0447\u0451\u0442.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4df\/2f5\/535\/4df2f5535ae615d95c5b9d5598272f8a.png\" alt=\"\u041f\u043e\u043b\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, n = 100\" title=\"\u041f\u043e\u043b\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, n = 100\" width=\"950\" height=\"548\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4df\/2f5\/535\/4df2f5535ae615d95c5b9d5598272f8a.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u043b\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, n = 100<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u0438 \u0441\u043f\u0440\u043e\u0441\u0438\u043c \u0441\u0435\u0431\u044f: \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u043e\u043d\u043e \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c? <\/p>\n<p>\u041c\u043e\u044f \u0431\u0438\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442, \u043d\u043e \u0435\u0441\u0442\u044c \u043b\u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u0423 \u043c\u0435\u043d\u044f \u043d\u0435\u0442 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0445\u043e\u0434\u0435 \u0441\u043e\u0442\u0435\u043d \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u0443\u0442\u0438 \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0438\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u0430\u0444\u043e\u0440 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0445 \u0441\u0432\u043e\u0438 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f. <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0433\u0440\u0430\u0444\u0430 &#8212; \u044d\u0442\u043e \u0446\u0435\u043d\u0442\u0440\u044b \u0433\u0440\u0430\u0432\u0438\u0442\u0430\u0446\u0438\u0438 \u2013 \u201c\u0437\u0432\u0451\u0437\u0434\u044b\u201d, \u0447\u0435\u043c \u043e\u043d\u0438 \u0431\u043b\u0438\u0436\u0435 \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0438\u0445 \u043e\u0431\u0449\u0435\u0435 \u0440\u0435\u0431\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u0437\u0432\u0435\u0437\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e \u0434\u0432\u0430 \u201c\u043b\u0443\u0447\u0430\u201d. \u041f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043d\u0438\u0445 \u043c\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043c \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443, \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0432\u044b\u0445\u043e\u0434\u0438\u043c. \u0422\u0430\u043a \u043a\u0430\u043a \u0433\u0440\u0430\u0444 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c \u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0432\u0451\u0437\u0434\u044b \u0438\u043c\u0435\u044e\u0442 \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0440\u0430\u0434\u0438\u0443\u0441, \u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043d\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0437\u0430 \u0441\u043e\u0431\u043e\u0439, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0451\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043d\u0430 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u043b\u0443\u0447\u0435\u0439 (Ray Tracing) \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440.<\/p>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043c \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432\u0435\u0440\u0448\u0438\u043d, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442 \u0433\u0440\u0430\u0444 (\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u0438\u043d\u0430 \u0440\u0451\u0431\u0435\u0440, \u0437\u0430\u0434\u0430\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0435\u0439. <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u043e\u0439 \u0441\u0442\u0430\u043b\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u043e\u043d \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u0420\u0430\u0434\u0438\u0443\u0441\u044b \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043d\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u043e\u0449\u0430\u0434\u044c \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c15\/d12\/55f\/c15d1255f05826b8f48f15b61b7d1cdd.png\" alt=\"\u0417\u043e\u043d\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d\" title=\"\u0417\u043e\u043d\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d\" width=\"950\" height=\"636\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c15\/d12\/55f\/c15d1255f05826b8f48f15b61b7d1cdd.png\"\/><\/p>\n<div><figcaption>\u0417\u043e\u043d\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0432\u044b\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0443\u044e \u201c\u0442\u0435\u043d\u044c\u201d. \u041e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0435\u043d\u0438 \u043e\u0442 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044b \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0430\u043a, \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0442\u0435\u043d\u0438, \u043d\u043e \u0440\u0435\u0431\u0440\u043e \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0434\u0432\u0435 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0435\u0442, \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0431\u0440\u043e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b (\u043c\u0435\u0442\u0430\u0444\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438, \u043b\u0443\u0447 \u043e\u0442\u0440\u0430\u0436\u0451\u043d\u043d\u044b\u0439 \u043e\u0442 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0441\u044f \u043a \u0441\u0432\u043e\u0438\u043c \u0441\u043e\u0441\u0435\u0434\u044f\u043c).<\/p>\n<p>\u0424\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c. <em>\u0412 \u043f\u043e\u043b\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0451\u0431\u0440\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0451\u0431\u0440\u0430 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u043d\u044b \u0438\u0437 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0451\u0431\u0440\u0430 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u0440\u0430\u0441\u0447\u0451\u0442\u0430\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0439\u0442\u0438 \u0432 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/em> (\u041f\u043e\u043d\u0438\u043c\u0430\u044e, \u0442\u0443\u0442 \u0441\u043f\u043e\u0440\u043d\u043e, \u0447\u0451\u0442\u043a\u043e\u0433\u043e \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0442.)<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0432 4-6 \u0440\u0430\u0437.<\/p>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442? \u041d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u044b \u0432\u0435\u0440\u0448\u0438\u043d AB \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0442\u0440\u0435\u0442\u044c\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 C \u0441 \u0440\u0430\u0434\u0438\u0443\u0441\u043e\u043c r, \u0442\u0430\u043a\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 ABC \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u0432\u0441\u0435 \u0440\u0451\u0431\u0440\u0430 \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u044b\u0435, AB \u2013 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430, \u0432\u044b\u0441\u043e\u0442\u0430 CH > r. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0421, \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0421 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0435\u0442 AB.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ed7\/e03\/032\/ed7e0303215e1c76e0696ff06b5034bf.png\" width=\"978\" height=\"385\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ed7\/e03\/032\/ed7e0303215e1c76e0696ff06b5034bf.png\"\/><\/figure>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0435\u0449\u0451 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445? \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u201c\u0446\u0435\u043d\u0442\u0440\u044b \u043c\u0430\u0441\u0441\u201d \u043c\u043e\u0433\u0443\u0442 \u0432\u0437\u0430\u0438\u043c\u043d\u043e \u043f\u0440\u043e\u043d\u0438\u043a\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d5d\/233\/e12\/d5d233e12e8a259f2c1c2352bc82b2a4.png\" alt=\"F(1,1)\" title=\"F(1,1)\" width=\"794\" height=\"559\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d5d\/233\/e12\/d5d233e12e8a259f2c1c2352bc82b2a4.png\"\/><\/p>\n<div><figcaption>F(1,1)<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0434\u0438\u0443\u0441 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u0417\u0430\u043c\u0435\u0442\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u043e\u0442\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438, \u0434\u0430\u044e\u0449\u0435\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u043e\u0442\u043d\u0443\u044e \u0442\u0435\u043d\u044c, \u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0431\u043e\u043b\u0435\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u043e\u0442\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u043e\u0442\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u201c\u043b\u0443\u0447\u0443\u201d \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f \u0435\u0433\u043e \u0443\u0433\u0430\u0441\u0448\u0438\u043c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0441 \u0435\u0449\u0451 \u043b\u0443\u0447\u0448\u0438\u043c\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438 \u043e\u0442\u0441\u0435\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>F(\u0427\u0438\u0441\u043b\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439 \u0434\u043e \u043e\u0431\u0440\u044b\u0432\u0430 \u043b\u0443\u0447\u0430)<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/882\/75b\/bb0\/88275bbb0cf1554b4c1849b9cee2079c.png\" alt=\"F(2,2)\" title=\"F(2,2)\" width=\"950\" height=\"636\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/882\/75b\/bb0\/88275bbb0cf1554b4c1849b9cee2079c.png\"\/><\/p>\n<div><figcaption>F(2,2)<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0443\u0442\u0451\u043c \u0431\u044b\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u044b \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044e\u0449\u0438\u0445 \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441 \u043c\u0435\u0442\u043e\u0434\u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439, \u043d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: F(1,1), F(2,2), F(3,4), F(4,5), F(5,7).<\/p>\n<p>\u041d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0431\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442 F(4,5). \u041b\u0443\u0447\u0448\u0435\u0435 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432 \u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432. (\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0438\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u043d\u0435 \u0443\u0447\u0442\u0451\u043d\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u0440\u043e\u043c). <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0442\u0430\u043a\u0443\u044e \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0443, \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u043e\u0447\u0435\u043a \u043d\u0443\u0436\u043d\u043e \u0432 20-50 \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0440\u0430\u0441\u0447\u0451\u0442\u044b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/55d\/ecc\/76b\/55decc76b58e05368c8dbaa8834a5b8b.png\" width=\"950\" height=\"636\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/55d\/ecc\/76b\/55decc76b58e05368c8dbaa8834a5b8b.png\"\/><\/figure>\n<p>\u0420\u0430\u0434\u0438\u0443\u0441\u044b \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0435\u0439 &#8212; \u044d\u0442\u043e \u0434\u043b\u0438\u043d\u044b \u0441\u0430\u043c\u044b\u0445 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0440\u0451\u0431\u0435\u0440 \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u0420\u0430\u0441c\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"python\">    # \u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0430\u0444 \u043a\u0430\u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438        adjacency_matrix = nx.adjacency_matrix(init_graph, dtype=np.float64).todense()     # \u0421\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c     adjacency_matrix.sort(axis=1)     # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b         vertex_array = adjacency_matrix[:, 1:circles + 1]<\/code><\/pre>\n<hr\/>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043f\u0440\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438. \u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043a\u0440\u0430\u0442\u043a\u043e \u043e\u0431\u0440\u0438\u0441\u043e\u0432\u0430\u043b, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u0422\u0443\u0442 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0430\u0442\u0435\u043b\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f, \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u0438\u043d \u0440\u0451\u0431\u0435\u0440 \u0433\u0440\u0430\u0444\u0430, \u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0438\u0449\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<p>objective_function \u2013 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0434\u043b\u0438\u043d\u044b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u0431\u0440\u0430<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u0435\u0441\u0442\u0438 \u0440\u043e\u0432\u043d\u043e \u0434\u0432\u0430 \u043f\u0443\u0442\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432 \u0434\u0432\u0443\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0433\u0440\u0430\u0444\u0435.<\/p>\n<p>equality_a \u2013 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439<br \/>equality_b \u2013 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0442\u0443\u0442 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u044b 2<\/p>\n<p>\u0422\u0440\u0435\u0442\u044c\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0411\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0438\u043c\u0435\u0442\u044c \u043f\u0443\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0448\u0430\u0433\u0430, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f.<\/p>\n<p>\u0430) variable_bounds = (0, 1) \u2013 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b 0, 1 (\u0440\u0435\u0431\u0440\u043e \u043b\u0438\u0431\u043e \u0432\u044b\u0431\u0435\u0440\u0435\u0442\u0441\u044f, \u043b\u0438\u0431\u043e \u043d\u0435\u0442)<br \/>\u0431) variable_bounds = (0, None) \u2013 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b 0, 1, 2 (\u0440\u0435\u0431\u0440\u043e \u043b\u0438\u0431\u043e \u0432\u044b\u0431\u0435\u0440\u0435\u0442\u0441\u044f, \u043b\u0438\u0431\u043e \u043d\u0435\u0442, \u043b\u0438\u0431\u043e \u0432\u044b\u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b) <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/525\/b25\/423\/525b25423e17df3500ac5848e954fc60.gif\" alt=\"variable_bounds = (0, 1)\" title=\"variable_bounds = (0, 1)\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/525\/b25\/423\/525b25423e17df3500ac5848e954fc60.gif\"\/><\/p>\n<div><figcaption>variable_bounds = (0, 1)<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/edb\/7fd\/493\/edb7fd493388bb06ebec77ce3b02037c.gif\" alt=\"variable_bounds = (0, None)\" title=\"variable_bounds = (0, None)\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/edb\/7fd\/493\/edb7fd493388bb06ebec77ce3b02037c.gif\"\/><\/p>\n<div><figcaption>variable_bounds = (0, None)<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u0435\u0440\u0445\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043d\u0435\u044f\u0432\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430, \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e \u0448\u0430\u0433\u043e\u0432 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0442\u0430\u043a \u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u044f\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>\u041a\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0441\u044f. \u0412 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u0442\u043e \u043e\u0434\u043d\u043e, \u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432. \u041f\u043e\u043a\u0430 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0443\u0441\u0442\u044b, \u043c\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u0445 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u043f\u0440\u0438 \u0432\u0432\u043e\u0434\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>inequalities_a \u2013 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432<br \/>inequalities_b \u2013 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">res = optimize.linprog(c=objective_function, bounds=variable_bounds, A_eq=equality_a, b_eq=equality_b, A_ub=inequalities_a, b_ub=inequalities_b, method='highs', integrality=1)  # \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430 \u0441\u0432\u044f\u0437\u0435\u0439 graph_resilt = nx.Graph() for i, val in enumerate(res.x):     if round(val) >= 1:         graph_resilt.add_edge(*array_index[i])  # \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0430\u0444 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430  result_sets = list(nx.connected_components(graph_resilt)) qty_sets = len(result_sets)<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430, \u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0421\u0432\u044f\u0437\u0430\u0442\u044c \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0432 \u0435\u0434\u0438\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0432\u0443\u043c\u044f \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0441\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u0438\u0445 \u0441\u043b\u043e\u0432\u043d\u043e \u0441\u043a\u043e\u0442\u0447.<\/p>\n<p><em>\u041a\u0430\u0436\u0434\u043e\u0435 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u0441\u044f \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0434\u0432\u0443\u043c\u044f \u0441\u0432\u044f\u0437\u044f\u043c\u0438.<\/em><\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0435\u0433\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0435\u0435 \u0437\u0432\u0435\u043d\u043e \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435.<\/p>\n<p><em>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0447\u0438\u0441\u043b\u043e \u0441\u0432\u044f\u0437\u0435\u0439 \u0432 \u043d\u0451\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043d\u0430 \u043e\u0434\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435.<\/em><\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u043d\u0430\u043a \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u2265, \u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u2264, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u043b\u0435\u0432\u043e\u0439 \u0438 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u043a \u043d\u0430 \u043c\u0438\u043d\u0443\u0441. \u0414\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u044d\u0442\u043e \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u043d\u0430\u043a \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u2264.<\/p>\n<p>\u041c\u044b \u0432 \u043f\u0440\u0430\u0432\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043e\u0434\u043d\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 (\u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043e\u0431\u0430, \u0435\u0441\u043b\u0438 \u0443\u0433\u043e\u0434\u043d\u043e), \u0434\u0430\u0436\u0435 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. \u0422\u0430\u043a \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0432 \u0433\u0440\u0430\u0444\u0435 \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043e\u043c\u044b\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c.<\/p>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0438\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043d\u043e\u0432\u044b\u0439 \u0448\u0430\u0433 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e, \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>\u041f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b, \u0442\u0430\u043a \u0438 \u043f\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u044b \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432.<\/p>\n<p>\u041e\u0446\u0435\u043d\u0438\u0432\u0430\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430 \u043d\u0430\u0431\u043e\u0440\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u0430\u043a O(n**3), \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 Concorde, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a O(n**2.2).<\/p>\n<hr\/>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043f\u0440\u043e <a href=\"https:\/\/math.uwaterloo.ca\/tsp\/concorde\/index.html\" rel=\"noopener noreferrer nofollow\">Concorde<\/a>, \u044d\u0442\u043e \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0418\u0434\u0435\u0438, \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0435 \u0432 \u043d\u0451\u043c, \u0434\u0430\u044e\u0442 \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0412\u044b\u0440\u0430\u0436\u0430\u044e \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/William_J._Cook\" rel=\"noopener noreferrer nofollow\">William J. Cook<\/a> \u0437\u0430 \u0435\u0433\u043e \u0432\u044b\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u0435\u043d.<\/p>\n<p>\u0425\u043e\u0442\u044f \u043e\u0431\u0449\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043f\u043e\u043d\u044f\u0442\u043d\u044b, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u041a\u043e\u043d\u043a\u043e\u0440\u0434, \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0438 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0439, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0445\u0443\u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0443\u043c\u0435\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u0435\u043d \u0448\u0430\u0433 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%93%D0%BE%D0%BC%D0%BE%D1%80%D0%B8\" rel=\"noopener noreferrer nofollow\">\u0413\u043e\u043c\u043e\u0440\u0438<\/a>. \u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0438\u0441\u044c \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0411\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0443\u0439\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0430\u043c\u0443 \u0438\u0434\u0435\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445 \u0441\u043e\u043b\u0432\u0435\u0440\u043e\u0432 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0413\u043e\u043c\u043e\u0440\u0438, \u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Branch_and_cut\" rel=\"noopener noreferrer nofollow\">Branch and cut<\/a>, \u0430 \u043a\u0430\u043a \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043e\u043d \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u043a\u043e\u0433\u0434\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e.<\/p>\n<hr\/>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0442\u0440\u0443\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0441\u043a\u043e\u0435 \u043f\u0435\u0440\u0435\u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043f\u043e \u0442\u0435\u043c\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0438 \u0438 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u0431\u0435\u0437\u043e\u0433\u043e\u0432\u043e\u0440\u043e\u0447\u043d\u0443\u044e \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u043f\u043e\u043f\u0440\u0430\u0432\u044c\u0442\u0435 \u0430\u0432\u0442\u043e\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u0441\u0435\u044f\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u0432\u0435\u0436\u0435\u0441\u0442\u0432\u043e. <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439 GNU GPL  <\/p>\n<pre><code class=\"python\">#------------------------------------------------------------------------------------ # TSP - traveling salesman problem integer linear programming method # \u0420\u0435\u0448\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u0438\u0432\u043e\u044f\u0436\u043e\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f # Rebuilder 09.06.2023 https:\/\/habr.com\/ru\/publication\/edit\/740984\/ #------------------------------------------------------------------------------------ import numpy as np import random import matplotlib.pyplot as plt from scipy import optimize from scipy import sparse import networkx as nx from datetime import datetime import math #------------------------------------------------------------------------------------ def distance(point1, point2):     # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u0442 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438      return math.hypot(point2[0] - point1[0], point2[1] - point1[1]) #------------------------------------------------------------------------------------ def matrix_count(a):     # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u043b\u043e\u0441\u043a\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b      return((a * a - a) \/\/ 2) #------------------------------------------------------------------------------------ def triangle_intersection(a, b, c, vertex_array, val):     # \u041d\u0443\u0436\u043d\u043e \u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u0440\u0435\u0431\u0440\u043e         if (b > a) or (c > a) or (a &lt; 0.000001):         return val           cross_size = len(vertex_array)          key = [True] * cross_size     for i in range(cross_size):         if (b == vertex_array[i]):             key[i] = False            p = 0.5 * (a + b + c)     s = p * (p - a) * (p - b) * (p - c)     r = 2 * np.sqrt(abs(s)) \/ a     for i in range(cross_size):         if key[i] and vertex_array[i] >= r:                 val += 1         return val #------------------------------------------------------------------------------------ def algorithm_evaluation(array_key, result_sets, k):     # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u0442 \u043e\u0446\u0435\u043d\u043a\u0443 \u043a\u0430\u043a\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0435\u0434\u0438\u043d\u0438\u0446     set1 = set()     set2 = set()          for i in result_sets[k]:             for j in result_sets[k]:                 if i > j and (i, j) in array_key:                     set1.add(array_key[(i, j)])      for l, val_l in enumerate(result_sets):         if l != k:             for i in result_sets[k]:                 for j in val_l:                     key = (i, j) if i > j else (j, i)                     if (key in array_key):                         set2.add(array_key[key])                              if len(set1) &lt;= len(set2):         return True, set1     else:         return False, set2 # ==================================================================================================================== def TSP_linprog(init_graph, circles, cross):     # \u041d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432 \u0433\u0440\u0430\u0444\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f              print('Run TSP linprog', end='')            n = len(init_graph)     # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043b\u0432\u0435\u0440\u0430     flat_n = matrix_count(n)     # \u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0430\u0444 \u043a\u0430\u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438        adjacency_matrix = nx.adjacency_matrix(init_graph, dtype=np.float64).todense()     # \u0421\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c     adjacency_matrix.sort(axis=1)     # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b         vertex_array = adjacency_matrix[:,1:circles + 1]     del adjacency_matrix      graph_of_neighbors = nx.Graph(())         for i in range(n):         for j in range(n):             if i > j:                                 value = 0                 for k in range(n):                     if (k != i) and (k != j):                          value = triangle_intersection(init_graph[i][j]['weight'], init_graph[i][k]['weight'], init_graph[j][k]['weight'], vertex_array[k], value)                         if value > cross:                             break                 if value &lt;= cross:                     graph_of_neighbors.add_edge(i, j)     del vertex_array            graph_united = nx.Graph(())         for i, j in list(graph_of_neighbors.edges()):               for k in list(graph_of_neighbors.adj[i]):             if j != k and not graph_united.has_edge(j, k):                 graph_united.add_edge(j, k)         for k in list(graph_of_neighbors.adj[j]):             if i != k and not graph_united.has_edge(i, k):                 graph_united.add_edge(i, k)                      for i, j in list(graph_of_neighbors.edges()):         if not graph_united.has_edge(i, j):             graph_united.add_edge(i, j)     del graph_of_neighbors          # \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0434\u0438\u0430\u043f\u043f\u0430\u0437\u043e\u043d \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445     variable_bounds = (0, 1) #     variable_bounds = (0, None)           # \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b     edges_list = list(graph_united.edges())     n_var = len(edges_list)     array_index = {}     array_key = {}     objective_function = np.empty(n_var, dtype=np.float64)           # \u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439     equality_a = sparse.lil_matrix((n, n_var), dtype=np.int8)     equality_b = [2] * n     inequalities_a = sparse.lil_matrix((0, n_var), dtype=np.int8)     inequalities_b = []          for i, val in enumerate(edges_list):         key = (val[0], val[1]) if val[0] > val[1] else (val[1], val[0])         array_key[key] = i         array_index[i] = key         objective_function[i] = init_graph[key[0]][key[1]]['weight']         equality_a[key[0], i] = 1         equality_a[key[1], i] = 1     del graph_united      constraints = 0     step = 0     while True:                # \u0418\u0449\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435            res = optimize.linprog(c=objective_function, bounds=variable_bounds, A_eq=equality_a, b_eq=equality_b, A_ub=inequalities_a, b_ub=inequalities_b, method='highs', integrality=1, options={'disp':True})            step += 1         print('.', end='')                  # \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430 \u0441\u0432\u044f\u0437\u0435\u0439         graph_resilt = nx.Graph()         for i, val in enumerate(res.x):             if round(val) >= 1:                 graph_resilt.add_edge(*array_index[i])          # \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0430\u0444 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430          result_sets = list(nx.connected_components(graph_resilt))         qty_sets = len(result_sets)          # \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0435\u0441\u043b\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e          if qty_sets == 1:             break          # \u0415\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0438\u0445 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e         if qty_sets == 2:             inequalities_a.resize((constraints + 1, n_var))             inequalities_b += [-2]             for i in result_sets[0]:                  for j in result_sets[1]:                     key = (i, j) if i > j else (j, i)                     if key in array_key:                         inequalities_a[constraints, array_key[key]] = -1             constraints += 1             continue                      # \u0412\u0432\u043e\u0434\u0438\u043c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432         inequalities_a.resize((constraints + qty_sets, n_var))         for i, val_i in enumerate(result_sets):             # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443             value, add_set = algorithm_evaluation(array_key, result_sets, i)             if value:                 inequalities_b += [len(val_i) - 1]                 for j in add_set:                     inequalities_a[constraints + i, j] = 1             else:                 inequalities_b += [-2]                 for j in add_set:                     inequalities_a[constraints + i, j] = -1          constraints += qty_sets     print()      return {'length' : res.fun, 'graph' : graph_resilt, 'constraints' : constraints, 'steps' : step} # ==================================================================================================================== def TSP_milp(init_graph, circles, cross):     # \u041d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432 \u0433\u0440\u0430\u0444\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f              print('Run TSP milp', end='')       n = len(init_graph)     # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043b\u0432\u0435\u0440\u0430         flat_n = matrix_count(n)     # \u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0430\u0444 \u043a\u0430\u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438        adjacency_matrix = nx.adjacency_matrix(init_graph, dtype=np.float64).todense()     # \u0421\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c     adjacency_matrix.sort(axis=1)     # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b         vertex_array = adjacency_matrix[:,1:circles + 1]     del adjacency_matrix          graph_of_neighbors = nx.Graph(())         for i in range(n):         for j in range(n):             if i > j:                                 value = 0                 for k in range(n):                     if (k != i) and (k != j):                          value = triangle_intersection(init_graph[i][j]['weight'], init_graph[i][k]['weight'], init_graph[j][k]['weight'], vertex_array[k], value)                         if value > cross:                             break                 if value &lt;= cross:                     graph_of_neighbors.add_edge(i, j)     del vertex_array            graph_united = nx.Graph(())     for i, j in list(graph_of_neighbors.edges()):          for k in list(graph_of_neighbors.adj[i]):             if j != k and not graph_united.has_edge(j, k):                 graph_united.add_edge(j, k)         for k in list(graph_of_neighbors.adj[j]):             if i != k and not graph_united.has_edge(i, k):                 graph_united.add_edge(i, k)                      for i, j in list(graph_of_neighbors.edges()):         if not graph_united.has_edge(i, j):             graph_united.add_edge(i, j)     del graph_of_neighbors              # \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b     edges_list = list(graph_united.edges())     n_var = len(edges_list)     array_index = {}     array_key = {}     matrix_a = sparse.lil_matrix((n, n_var), dtype=np.int8)         objective_function = np.empty(n_var, dtype=np.float64)         for i, val in enumerate(edges_list):         key = (val[0], val[1]) if val[0] > val[1] else (val[1], val[0])         array_key[key] = i         array_index[i] = key         objective_function[i] = init_graph[key[0]][key[1]]['weight']         matrix_a[key[0], i] = 1         matrix_a[key[1], i] = 1     del graph_united      # \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0434\u0438\u0430\u043f\u043f\u0430\u0437\u043e\u043d \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445     variable_bounds = (0, 1) #     variable_bounds = (0, np.inf)      # \u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438         lower_bound  = [2] * n     upper_bound  = [2] * n          constraints = 0     step = 0     while True:                # \u0418\u0449\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435         res = optimize.milp(c=objective_function, constraints=optimize.LinearConstraint(matrix_a, lower_bound, upper_bound), bounds=variable_bounds, integrality=1, options={'disp':True})         step += 1         print('.', end='')                  # \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430 \u0441\u0432\u044f\u0437\u0435\u0439         graph_resilt = nx.Graph()         for i, val in enumerate(res.x):             if round(val) >= 1:                 graph_resilt.add_edge(*array_index[i])          # \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0430\u0444 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430          result_sets = list(nx.connected_components(graph_resilt))         qty_sets = len(result_sets)                  # \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0435\u0441\u043b\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e          if qty_sets == 1:             break          # \u0415\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0438\u0445 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e         if qty_sets == 2:             matrix_a.resize((n + constraints + 1, n_var))             lower_bound += [2]             upper_bound += [np.inf]             for i in result_sets[0]:                  for j in result_sets[1]:                     key = (i, j) if i > j else (j, i)                     if key in array_key:                         matrix_a[n + constraints, array_key[key]] = 1             constraints += 1             continue                      # \u0412\u0432\u043e\u0434\u0438\u043c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432         matrix_a.resize((n + constraints + qty_sets, n_var))         for i, val_i in enumerate(result_sets):             # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443             value, add_set = algorithm_evaluation(array_key, result_sets, i)             if value:                 lower_bound += [0]                 upper_bound += [len(val_i) - 1]             else:                 lower_bound += [2]                 upper_bound += [np.inf]             for j in add_set:                 matrix_a[n + constraints + i, j] = 1         constraints += qty_sets     print()          return {'length' : res.fun, 'graph' : graph_resilt, 'constraints' : constraints, 'steps' : step} # ==================================================================================================================== n = 200 # random.seed(1) points = [(round(random.randint(0, 300)), round(random.randint(0, 200))) for i in range(n)]  init_graph = nx.complete_graph(n) for i, j in init_graph.edges():     if j > i:         init_graph[i][j]['weight'] = distance(points[i], points[j])  plt.figure(figsize=(12, 9)) plt.axis(\"equal\")  start_time = datetime.now() res = TSP_linprog(init_graph, 4, 5) # res = TSP_milp(init_graph, 4, 5) date_diff = (datetime.now() - start_time).total_seconds() print('time =', date_diff) nx.draw(init_graph, points, width=0, with_labels=True, node_size=0, font_size=6, font_color=\"black\") nx.draw(res[\"graph\"], points, width=1, edge_color=\"red\", style=\"-\", with_labels=False, node_size=0) plt.show() # ====================================================================================================================<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0430, n = 1200 (\u041e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u0442\u0440\u0430\u0444\u0438\u043a)<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/83d\/3b4\/690\/83d3b4690bdab903022b9f98313ad852.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/83d\/3b4\/690\/83d3b4690bdab903022b9f98313ad852.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/23e\/249\/51a\/23e24951a39fc529e2b398c2fdcba2e8.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/23e\/249\/51a\/23e24951a39fc529e2b398c2fdcba2e8.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f56\/5e9\/e74\/f565e9e74bc2c84d7b15468e112a0132.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f56\/5e9\/e74\/f565e9e74bc2c84d7b15468e112a0132.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/029\/4f7\/f91\/0294f7f918a54a00289a6c7c928e75a5.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/029\/4f7\/f91\/0294f7f918a54a00289a6c7c928e75a5.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7d8\/f96\/531\/7d8f96531a80f0709a139b6e61273981.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7d8\/f96\/531\/7d8f96531a80f0709a139b6e61273981.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d82\/e79\/f76\/d82e79f76020c0b054c326e6da61bb1e.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d82\/e79\/f76\/d82e79f76020c0b054c326e6da61bb1e.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/706\/9ad\/23e\/7069ad23e70f6f25ecc3eb79035a6393.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/706\/9ad\/23e\/7069ad23e70f6f25ecc3eb79035a6393.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/019\/bad\/aa4\/019badaa45511f1b8c9b44519630b45e.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/019\/bad\/aa4\/019badaa45511f1b8c9b44519630b45e.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/407\/f93\/967\/407f9396707dbfc40343a5d61189bd47.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/407\/f93\/967\/407f9396707dbfc40343a5d61189bd47.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0be\/068\/ba3\/0be068ba3b09c22f4b9bdcbfe1281e87.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0be\/068\/ba3\/0be068ba3b09c22f4b9bdcbfe1281e87.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/954\/b62\/712\/954b62712764a21cac50b9da5f8da607.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/954\/b62\/712\/954b62712764a21cac50b9da5f8da607.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/027\/acb\/a0b\/027acba0b6e210a6e5666d05acf0bb4e.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/027\/acb\/a0b\/027acba0b6e210a6e5666d05acf0bb4e.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/629\/d16\/e83\/629d16e833a1b3fb57643e0f1d1b7911.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/629\/d16\/e83\/629d16e833a1b3fb57643e0f1d1b7911.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e8d\/9d8\/f5f\/e8d9d8f5f1300c2fcb5822805c7a61cf.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e8d\/9d8\/f5f\/e8d9d8f5f1300c2fcb5822805c7a61cf.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/66a\/378\/276\/66a378276e35c6cb67d71497a8b72439.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/66a\/378\/276\/66a378276e35c6cb67d71497a8b72439.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a44\/97e\/ef8\/a4497eef80d4aa1b6b0bde28d3e9483a.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a44\/97e\/ef8\/a4497eef80d4aa1b6b0bde28d3e9483a.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/62b\/a6f\/d04\/62ba6fd04b208ddba1a145b8d5b580da.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/62b\/a6f\/d04\/62ba6fd04b208ddba1a145b8d5b580da.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3a3\/4cf\/cb0\/3a34cfcb031205427cb626ba4c0db273.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3a3\/4cf\/cb0\/3a34cfcb031205427cb626ba4c0db273.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/814\/345\/705\/814345705eb8611faabb79692de80c7f.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/814\/345\/705\/814345705eb8611faabb79692de80c7f.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ad\/916\/fc6\/1ad916fc6ae62f6d7b02d02319c03c74.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ad\/916\/fc6\/1ad916fc6ae62f6d7b02d02319c03c74.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cc2\/ce1\/f5b\/cc2ce1f5bb38ee6cbf843a31ed0ea66c.png\" width=\"717\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc2\/ce1\/f5b\/cc2ce1f5bb38ee6cbf843a31ed0ea66c.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/740984\/\"> https:\/\/habr.com\/ru\/articles\/740984\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<blockquote>\n<p><em>\u0412\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0441\u0430\u043c\u044b\u0439 \u0442\u0440\u0443\u0434\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u2014 \u043d\u0430 \u043d\u0435\u043c \u0432\u044b \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043e\u0432.<\/em><\/p>\n<p><em>\u0428\u0430\u0440\u043b\u044c \u0434\u0435 \u0413\u043e\u043b\u043b\u044c<\/em><\/p>\n<\/blockquote>\n<p>\u0418 \u0441\u043d\u043e\u0432\u0430 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430. \u041c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0432 \u043c\u0438\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/711708\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435<\/a> \u043c\u044b \u0443\u0436\u0435 \u0443\u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432 \u0433\u0440\u0430\u0444\u0435 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0435\u043d \u0432\u0435\u0440\u0448\u0438\u043d. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0445\u043e\u0447\u0443 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0443\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0435\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044e \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445 \u043e\u0442 \u0442\u044b\u0441\u044f\u0447\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<hr\/>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 n x n, \u0433\u0434\u0435 n \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0430, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c. <\/p>\n<pre><code class=\"python\">[[  0 106  71  81  75 140 108 146 262 174]  [106   0 162 184  92 130  36 157 270 204]  [ 71 162   0  38  88 134 151 123 223 130]  [ 81 184  38   0 121 171 179 161 257 164]  [ 75  92  88 121   0  65  69  77 196 118]  [140 130 134 171  65   0  96  33 140  84]  [108  36 151 179  69  96   0 124 235 173]  [146 157 123 161  77  33 124   0 119  52]  [262 270 223 257 196 140 235 119   0  93]  [174 204 130 164 118  84 173  52  93   0]]<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0432 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u043e\u0439 \u0442\u043e\u0447\u0435\u043a.<\/p>\n<pre><code class=\"python\">def distance(point1, point2):     return math.hypot(point2[0] - point1[0], point2[1] - point1[1])<\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u043b\u0435\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u044e\u0449\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0431\u044b\u043b\u0430 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438, \u0430 \u0441\u0430\u043c\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u043d\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444:<\/p>\n<pre><code class=\"python\">import networkx as nx init_graph = nx.complete_graph(n)<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">def matrix_count(a):     # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0451\u0431\u0435\u0440 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b      return (a * a - a) \/\/ 2 <\/code><\/pre>\n<p>\u041f\u0440\u0438 n = 1000 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f 499500 \u0440\u0451\u0431\u0435\u0440, \u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<p>\u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (LP), \u0432\u0435\u0434\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u044d\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0432 \u0440\u0430\u0441\u0447\u0451\u0442\u0430\u0445. <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435\u044f\u0432\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c n&#8217; x m&#8217;, \u0433\u0434\u0435 m&#8217; > n&#8217;, n&#8217; &#8212; \u0447\u0438\u0441\u043b\u043e \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, m&#8217; &#8212; \u0447\u0438\u0441\u043b\u043e \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432. (\u0417\u0434\u0435\u0441\u044c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B8%D0%BC%D0%BF%D0%BB%D0%B5%D0%BA%D1%81-%D0%BC%D0%B5%D1%82%D0%BE%D0%B4\" rel=\"noopener noreferrer nofollow\">\u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441 \u043c\u0435\u0442\u043e\u0434<\/a> \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0431\u0430\u0437\u0438\u0441\u043e\u043c. \u0425\u043e\u0442\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0441 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0431\u0430\u0437\u0438\u0441\u043e\u043c, \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043d\u0435\u0442.)<\/p>\n<p>\u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 LP \u0441 \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430, \u0430 \u044d\u0442\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0413\u0431\u0430\u0439\u0442.<\/p>\n<p>\u041c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441 \u043e\u0431\u044a\u0451\u043c\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<\/li>\n<\/ol>\n<ol>\n<li>\n<p>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0438\u0436\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e. \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b (\u0420\u0430\u0437\u0440\u0435\u0436\u0451\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u00a0\u2014\u00a0\u043c\u0430\u0442\u0440\u0438\u0446\u0430\u00a0\u0441 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438).<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">[[1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 0 0]  [1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 1 0]  [0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1]  [0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 1]  [0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]  [0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]  [0 0 1 1 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 1 0 1 1 1 0 1 0 1 0 0 1 0 0 1 1 0]]<\/code><\/pre>\n<p>\u0412 \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e \u0432 python \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 scipy \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438, \u043d\u043e \u0438 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u0438 \u0437\u0430\u0434\u0430\u0447 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0446\u0435\u043b\u0435\u0439, \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u043f\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u044f \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0432\u0435\u0441\u043e\u043c\u044b\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445, \u043a\u0430\u043a \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b, \u0442\u0430\u043a \u0438 \u043f\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>a) <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.optimize.linprog.html\" rel=\"noopener noreferrer nofollow\">scipy.optimize.linprog<\/a><br \/>b) <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.optimize.milp.html\" rel=\"noopener noreferrer nofollow\">scipy.optimize.milp<\/a><\/p>\n<p>\u041e\u0431\u0430 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/sparse.html\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u0442\u0440\u0438\u0446<\/a>.<\/p>\n<pre><code class=\"python\">res = optimize.linprog(c=objective_function, bounds=variable_bounds, A_eq=equality_a, b_eq=equality_b, A_ub=inequalities_a, b_ub=inequalities_b, method='highs', integrality=1, options={'disp':True}) res = optimize.milp(c=objective_function, bounds=variable_bounds, constraints=optimize.LinearConstraint(matrix_a, lower_bound, upper_bound), integrality=1, options={'disp':True})<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e linprog \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0430 \u0434\u0432\u0430 \u0431\u043b\u043e\u043a\u0430: \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430. Milp \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0434\u0438\u043d \u0431\u043b\u043e\u043a \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432 \u0441 \u0432\u0435\u0440\u0445\u043d\u0438\u043c \u0438 \u043d\u0438\u0436\u043d\u0438\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c (\u0434\u043b\u044f \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u0435 \u0438 \u043d\u0438\u0436\u043d\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c).<\/p>\n<ol start=\"2\">\n<li>\n<p>\u0423\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0443, \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0440\u0451\u0431\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438. \u0422\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0431\u044a\u0451\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0441\u0447\u0451\u0442.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u043e\u043b\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, n = 100<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u0438 \u0441\u043f\u0440\u043e\u0441\u0438\u043c \u0441\u0435\u0431\u044f: \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u043e\u043d\u043e \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c? <\/p>\n<p>\u041c\u043e\u044f \u0431\u0438\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442, \u043d\u043e \u0435\u0441\u0442\u044c \u043b\u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u0423 \u043c\u0435\u043d\u044f \u043d\u0435\u0442 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0445\u043e\u0434\u0435 \u0441\u043e\u0442\u0435\u043d \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u0443\u0442\u0438 \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0438\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u0430\u0444\u043e\u0440 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0445 \u0441\u0432\u043e\u0438 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f. <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0433\u0440\u0430\u0444\u0430 &#8212; \u044d\u0442\u043e \u0446\u0435\u043d\u0442\u0440\u044b \u0433\u0440\u0430\u0432\u0438\u0442\u0430\u0446\u0438\u0438 \u2013 \u201c\u0437\u0432\u0451\u0437\u0434\u044b\u201d, \u0447\u0435\u043c \u043e\u043d\u0438 \u0431\u043b\u0438\u0436\u0435 \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0438\u0445 \u043e\u0431\u0449\u0435\u0435 \u0440\u0435\u0431\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u0437\u0432\u0435\u0437\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e \u0434\u0432\u0430 \u201c\u043b\u0443\u0447\u0430\u201d. \u041f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043d\u0438\u0445 \u043c\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043c \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443, \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0432\u044b\u0445\u043e\u0434\u0438\u043c. \u0422\u0430\u043a \u043a\u0430\u043a \u0433\u0440\u0430\u0444 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c \u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0432\u0451\u0437\u0434\u044b \u0438\u043c\u0435\u044e\u0442 \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0440\u0430\u0434\u0438\u0443\u0441, \u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043d\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0437\u0430 \u0441\u043e\u0431\u043e\u0439, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0451\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043d\u0430 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u043b\u0443\u0447\u0435\u0439 (Ray Tracing) \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440.<\/p>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043c \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432\u0435\u0440\u0448\u0438\u043d, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442 \u0433\u0440\u0430\u0444 (\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u0438\u043d\u0430 \u0440\u0451\u0431\u0435\u0440, \u0437\u0430\u0434\u0430\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0435\u0439. <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u043e\u0439 \u0441\u0442\u0430\u043b\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u043e\u043d \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u0420\u0430\u0434\u0438\u0443\u0441\u044b \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043d\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u043e\u0449\u0430\u0434\u044c \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0417\u043e\u043d\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0432\u044b\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0443\u044e \u201c\u0442\u0435\u043d\u044c\u201d. \u041e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0435\u043d\u0438 \u043e\u0442 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044b \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0430\u043a, \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0442\u0435\u043d\u0438, \u043d\u043e \u0440\u0435\u0431\u0440\u043e \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0434\u0432\u0435 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0435\u0442, \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0431\u0440\u043e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b (\u043c\u0435\u0442\u0430\u0444\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438, \u043b\u0443\u0447 \u043e\u0442\u0440\u0430\u0436\u0451\u043d\u043d\u044b\u0439 \u043e\u0442 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0441\u044f \u043a \u0441\u0432\u043e\u0438\u043c \u0441\u043e\u0441\u0435\u0434\u044f\u043c).<\/p>\n<p>\u0424\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c. <em>\u0412 \u043f\u043e\u043b\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0451\u0431\u0440\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0451\u0431\u0440\u0430 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u043d\u044b \u0438\u0437 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0451\u0431\u0440\u0430 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u0440\u0430\u0441\u0447\u0451\u0442\u0430\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0439\u0442\u0438 \u0432 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/em> (\u041f\u043e\u043d\u0438\u043c\u0430\u044e, \u0442\u0443\u0442 \u0441\u043f\u043e\u0440\u043d\u043e, \u0447\u0451\u0442\u043a\u043e\u0433\u043e \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0442.)<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0432 4-6 \u0440\u0430\u0437.<\/p>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442? \u041d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u044b \u0432\u0435\u0440\u0448\u0438\u043d AB \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0442\u0440\u0435\u0442\u044c\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 C \u0441 \u0440\u0430\u0434\u0438\u0443\u0441\u043e\u043c r, \u0442\u0430\u043a\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 ABC \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u0432\u0441\u0435 \u0440\u0451\u0431\u0440\u0430 \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u044b\u0435, AB \u2013 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430, \u0432\u044b\u0441\u043e\u0442\u0430 CH > r. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0421, \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0421 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0435\u0442 AB.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0435\u0449\u0451 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445? \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u201c\u0446\u0435\u043d\u0442\u0440\u044b \u043c\u0430\u0441\u0441\u201d \u043c\u043e\u0433\u0443\u0442 \u0432\u0437\u0430\u0438\u043c\u043d\u043e \u043f\u0440\u043e\u043d\u0438\u043a\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>F(1,1)<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0434\u0438\u0443\u0441 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u0417\u0430\u043c\u0435\u0442\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u043e\u0442\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438, \u0434\u0430\u044e\u0449\u0435\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u043e\u0442\u043d\u0443\u044e \u0442\u0435\u043d\u044c, \u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0431\u043e\u043b\u0435\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u043e\u0442\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u043e\u0442\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u201c\u043b\u0443\u0447\u0443\u201d \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f \u0435\u0433\u043e \u0443\u0433\u0430\u0441\u0448\u0438\u043c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-348594","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=348594"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348594\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=348594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=348594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=348594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}