{"id":334415,"date":"2022-06-13T15:00:58","date_gmt":"2022-06-13T15:00:58","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=334415"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=334415","title":{"rendered":"<span>\u041d\u041a\u0410: \u0438\u0433\u0440\u044b \u0431\u0435\u0437 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0437\u0430\u043c\u044b\u0441\u043b\u0430\u0445 \u0434\u0440\u0443\u0433\u0438\u0445<\/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<p>\u041d\u0430 \u0441\u0442\u0435\u043d\u0435 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c. \u041d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0446\u0435\u043b\u0438, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u0442. \u0427\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c.<\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e. \u041f\u0443\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e {a, b, c, d}. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 {a, b}, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 {c, d}. \u041f\u0443\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u043c: \u0441|d=a(c), \u0441|d=b(c), c=a(d), \u0441|d=b(d).<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c &#171;|&#187; \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 &#171;\u043b\u0438\u0431\u043e&#187;. \u0422\u0430\u043a \u0441|d=b(d) \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442: \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f d \u043f\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438\u0431\u043e c, \u043b\u0438\u0431\u043e d.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u043d\u0430\u0447\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c: \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f {a, c}, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f {b, d}. \u041f\u0443\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u043c: b=a(b), b|d=c(b), d=a(d), b=c(d).<\/p>\n<p>\u0420\u0430\u0437\u043d\u0438\u0446\u0430, \u0435\u0441\u043b\u0438 \u0435\u0435 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438, \u0432\u0437\u044f\u0442\u044b\u0439 \u043a\u0430\u043a \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0431\u044b\u043b\u0438 \u0431\u044b \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b \u043a \u0432\u0441\u0435\u043c \u0441\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u043c\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430\u043c,\u00a0 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 4\/7. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 4\/5. \u0418\u043b\u0438, \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043f\u043e\u0447\u0442\u0438 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439. \u0414\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e.  <\/p>\n<p>\u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0432\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0441\u0442\u0430\u0442\u044c\u0435. \u0415\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f (\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439), \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0430. \u0418 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0433\u0435\u043d\u0442\u043e\u0432, \u0446\u0435\u043b\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041a\u043e\u0442\u043e\u0440\u044b\u0435, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0433\u0443\u0442 \u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c. \u041e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u0438 \u0430\u0433\u0435\u043d\u0442\u044b \u043d\u0435 \u0432\u0435\u0434\u0430\u044e\u0442 \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0430\u0433\u0435\u043d\u0442\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u0445\u043e\u0434\u044b \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0438\u043c\u0438 QL-\u043a\u0430\u0440\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0433\u0435\u043d\u0442\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. <\/p>\n<p>\u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u00a0 \u0438\u0433\u0440\u0430\u043c, \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435 \u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 QL-\u043a\u0430\u0440\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432. \u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043f\u0440\u0438 \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0445\u043e\u0434\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044d\u043c\u043f\u0430\u0442\u0438\u0438. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u0430 \u0442\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0430 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u044b load_file. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u0438\u0433\u0440\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0440\u0438 \u0430\u0433\u0435\u043d\u0442\u0430. \u0426\u0435\u043b\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e &#8212; \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=9. \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=10 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/66b\/593\/b3c\/66b593b3ccbf820b01c21dfbdf769591.jpg\" width=\"1027\" height=\"1030\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/66b\/593\/b3c\/66b593b3ccbf820b01c21dfbdf769591.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0433\u0435\u043d\u0442 \u0441 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c graph_b &#8212; \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c. \u0418\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4 \u0438\u043c\u0435\u0435\u043c \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u044c, \u0442.\u043a. \u043f\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 11 \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=5, \u043b\u0438\u0431\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=1. \u0418\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=3 \u0435\u0435 \u043d\u0435\u0442, \u0442.\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f 11 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043e\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f 13. \u0412\u044b\u0437\u043e\u0432 g2.get_ku() \u0432\u0435\u0440\u043d\u0435\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438 0.917=11\/12. <\/p>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u0433\u0435\u043d\u0442 \u0441 graph_w &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043f\u043e \u0447\u0435\u0440\u043d\u044b\u043c, \u0442\u0430\u043a \u0438 \u043f\u043e \u0441\u0438\u043d\u0438\u043c \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f: g3.get_ku() \u0432\u0435\u0440\u043d\u0435\u0442 0.933. \u041f\u0435\u0440\u0432\u044b\u0439 \u0436\u0435 \u0430\u0433\u0435\u043d\u0442 \u0441 graph_w1 \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u043a \u0443  graph_w \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 9=12(2), \u0442.\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432 9 \u0438\u0437 2 \u043f\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 12 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0435\u0442. \u0415\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0432\u0435\u043d 0.929<\/p>\n<pre><code>{ \"1\": [[\"2\", \"11\"], [\"10\", \"15\"]],  \"2\": [[\"3\", \"11\"]],  \"3\": [[\"4\", \"11\"], [\"2\", \"13\"], [\"6\", \"12\"]],  \"4\": [[\"5|1\", \"11\"]],  \"5\": [[\"6\", \"11\"]],  \"6\": [[\"7\", \"11\"]],  \"7\": [[\"8\", \"11\"], [\"5\", \"12\"]],  \"8\": [[\"9\", \"11\"]],  \"9\": [],  \"10\":[[\"5\", \"15\"]] }  { \"1\": [[\"2\", \"11\"], [\"10\", \"15\"]],  \"2\": [[\"3\", \"11\"]],  \"3\": [[\"4\", \"11\"], [\"2\", \"13\"]],  \"4\": [[\"5|1\", \"11\"]],  \"5\": [[\"6\", \"11\"]],  \"6\": [[\"7\", \"11\"]],  \"7\": [[\"8\", \"11\"]],  \"8\": [[\"9\", \"11\"]],  \"9\": [],  \"10\":[[\"5\", \"15\"]] }  { \"1\": [[\"2\", \"11\"], [\"10\", \"15\"]], \"2\": [[\"3\", \"11\"], [\"9\", \"12\"]],  \"3\": [[\"4\", \"11\"], [\"2\", \"13\"], [\"6\", \"12\"]],  \"4\": [[\"5|1\", \"11\"]],  \"5\": [[\"6\", \"11\"]],  \"6\": [[\"7\", \"11\"]],  \"7\": [[\"8\", \"11\"], [\"5\", \"12\"]],  \"8\": [[\"9\", \"11\"]],  \"9\": [], \"10\":[[\"5\", \"15\"]] }<\/code><\/pre>\n<p>\u0421\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0433\u0435\u043d\u0442\u043e\u0432  [[g1, {e: 5, b: -6}, s, e, 1], [g2, {e: 5, b: -6}, s, e, 1], [g3, {e: 5, b: -6}, s, e, 1]]. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0433\u0440 k=1.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b44\/0e6\/ce8\/b440e6ce83e1d01a16c89d080d0c141a.jpg\" width=\"1021\" height=\"944\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b44\/0e6\/ce8\/b440e6ce83e1d01a16c89d080d0c141a.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0438\u0433\u0440\u043e\u043a who=0 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 QL-\u043a\u0430\u0440\u0442\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043b\u043e\u0436\u0435\u043d \u043c\u0430\u0440\u0448\u0440\u0443\u0442 [1,2,3,6,7,8,9]. \u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0433\u0435\u043d\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u0422\u0440\u0435\u0442\u044c\u0435\u043c\u0443 \u0430\u0433\u0435\u043d\u0442\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442. <\/p>\n<p>\u041f\u0440\u0438 \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0445\u043e\u0434\u043e\u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u043e \u0446\u0435\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0430\u0447\u0435. \u041c\u0430\u0440\u0448\u0440\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u043c\u0438 (\u0430\u0433\u0435\u043d\u0442, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435). \u0418\u0437 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=1 \u0430\u0433\u0435\u043d\u0442 who=0 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=2. \u0414\u0430\u043b\u0435\u0435 who=1 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=3. \u0417\u0430\u0442\u0435\u043c who=2 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0432\u043e\u0435\u0439 QL-\u043a\u0430\u0440\u0442\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0430\u0434 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=2 (\u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0435\u0433\u043e \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c). \u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0433\u0435\u043d\u0442 \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=2 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=3, \u0442.\u043a \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0446\u0435\u043b\u0438 \u0432 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438. <\/p>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4 \u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0433\u0435\u043d\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=1 (\u0432 \u0441\u0438\u043b\u0443 \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4). \u041c\u0430\u0440\u0448\u0440\u0443\u0442 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0433\u0435\u043d\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=5. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=9 \u0441 \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0445\u043e\u0434\u043e\u0432. \u0412 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0433\u0435\u043d\u0442 who=0.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c 100 \u0438\u0433\u0440. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/f27\/2c5\/dbb\/f272c5dbbd94a5a00c381d563c809959.jpg\" width=\"1007\" height=\"931\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f27\/2c5\/dbb\/f272c5dbbd94a5a00c381d563c809959.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0434\u043e \u0446\u0435\u043b\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u0433\u0440\u044b. \u0422\u0430\u043a \u0432\u044b\u0448\u043b\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=3 \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4 ql=1.57, \u0430 \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=2 ql=2.39. \u0418\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f 2 \u0438 3 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a QL-\u043a\u0430\u0440\u0442\u0430 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c? \u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 (\u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e\u0435) \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4.<\/p>\n<p>\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432=4 \u0437\u0430 \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/15e\/7d7\/b5b\/15e7d7b5be84599706eee98d5162b517.jpg\" width=\"1183\" height=\"940\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/15e\/7d7\/b5b\/15e7d7b5be84599706eee98d5162b517.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u0433\u0440\u0435 \u043e\u043d \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 [3, 4, 1, 2]. \u0412 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0435 \u0438\u0437 100 \u0438\u0433\u0440 \u0442\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0445\u043e\u0434\u043e\u0432 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0433\u0435\u043d\u0442.<\/p>\n<p>\u041a\u043e\u0434 \u043d\u0438\u0436\u0435. \u041a\u0430\u043a\u0438\u0445-\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435 \u043d\u0435\u0441\u0435\u0442.<\/p>\n<pre><code>import random, pickle, json  class GenGraph(): def __init__(self, f_list, x_list, n=4): '''f_list - \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, x_list - \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439' \u0426\u0435\u043b\u0435\u0441\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0441\u043e\u0435\u0434\u0435\u043d\u044f\u0442\u044c \u0433\u0440\u0430\u0444\u044b''' self.n = n self.graph = self.initG(f_list, x_list)  def rnd_get(self, v): return random.choice(v.split(\"|\"))  def show(self): for x in self.graph: print(x, \":\", self.graph[x])  def return_graph(self): return self.graph  def get_ku(self): '''return (\u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438, \u0440\u0430\u0437\u043c\u0435\u0440)''' n = 0; u = 0 for x in self.graph: for y in self.graph[x]: u += y[0].count(\"|\") n += 1 if n != 0: return (round(1- u\/(n+u), 3), n)  else: return (None, None)  def initG(self, f_list, x_list): rnd_dict = dict() r = len(x_list) rnd_list = x_list[:]  for x in rnd_list: min21 = random.randint(0, len(rnd_list)\/\/self.n) min22 = random.randint(0, len(rnd_list)\/\/self.n)  if min21 &lt;= min22: k=random.randint(min21, min22) rnd_x = list(set(random.choices(rnd_list, k=k)))  rnd_fx = [(x, random.choice(f_list)) for x in rnd_x] else:  k=random.randint(min22, min21) rnd_x = list(set(random.choices(rnd_list, k=k))) rnd_fx = [(x, random.choice(f_list)) for x in rnd_x] rnd_dict[x] = rnd_fx  return rnd_dict  def add_uncertainty(self, u=0): '''\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043c \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u044c''' for i in range(u): w = random.choice(list(self.graph.keys()))  if self.graph[w] != []: x = random.choice(self.graph[w]) add = random.choice(list(self.graph.keys()))  if add not in x[0].split('|'): x0 = x[0] + '|' + add ind = self.graph[w].index(x) self.graph[w][ind] = [x0, x[1]]  class Ql(GenGraph): def __init__(self, f_list, x_list): super().__init__(f_list, x_list)  self.visited = {} self.ql = {} self.gamma = 0.9  def training(self, target, current=None, depth=1, epochs=1): '''\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c QL-\u043a\u0430\u0440\u0442\u0443: \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441 \u0434\u0438\u0441\u043a\u043e\u043d\u0442\u043e\u043c \u043e\u0442 \u0446\u0435\u043b\u0438''' ls = sorted(list(target.items()), key = lambda t: t[1], reverse = True) if ls[0][0] not in self.graph or current not in self.graph: return  for epoch in range(1, epochs+1): if current == None: current = random.choice(list(self.graph))  if current not in self.visited:  self.visited[current] = 1  self.ql[current] = 0   n = depth while n > 0: if current in target: self.ql[current] = target[current]  if self.graph[current] == []: vs = sorted(self.visited.items(), key = lambda t: t[1]) vs = [x for x in vs if vs[0][1] == x[1]] vq = [x for x in vs if self.ql[x[0]] == 0] if vq: current = vq[0][0] else: current = random.choice(vs)[0] self.visited[current] +=1  neighbors = [random.choice(x[0].split('|')) for x in self.graph[current]]  if not neighbors: n -=1  continue  for x in neighbors: if x not in self.visited: self.visited[x] = 0 self.ql[x] = 0  ql_sort = sorted([(x, self.ql[x]) for x in neighbors], key = lambda t: t[1], reverse=True) ql_max = random.choice([x for x in ql_sort if ql_sort[0][1] == x[1]])  if current not in target: self.ql[current] = round(self.gamma*ql_max[1], 2)  visited_sort = sorted([(x, self.visited[x]) for x in neighbors], key = lambda t: t[1]) visited_min = random.choice([x for x in visited_sort if visited_sort[0][1] == x[1]]) self.visited[visited_min[0]] +=1 current = visited_min[0]  n -=1  return current  def get_ql_path(self, current, target, depth=100): '''\u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u043e \u0446\u0435\u043b\u0438''' path = [current] while depth > 0: if current == None or target not in self.graph: return [] if current == target: return path  mx = 0 neighbor_mx = None neighbors = [random.choice(x[0].split('|')) for x in self.graph[current]]  for neighbor in neighbors: #if neighbor in self.ql and neighbor not in path: if neighbor in self.ql: if self.ql[neighbor] >= mx: mx = self.ql[neighbor] neighbor_mx = neighbor else: continue  current = neighbor_mx path += [current] depth -=1  return []  def save_file(self, name, t_data, t='pickle'): f = open(name, 'wb') if t == 'pickle': if t_data == 'graph': pickle.dump(self.graph, f) if t_data == 'visited': pickle.dump(self.visited, f) if t_data == 'ql': pickle.dump(self.ql, f) if t == 'json': if t_data == 'graph': json.dump(self.graph, open(name, 'w')) if t_data == 'visited': json.dump(self.visited, open(name, 'w')) if t_data == 'ql': json.dump(self.ql, open(name, 'w')) f.close()  def load_file(self, name, t_data, t='pickle'): f = open(name, 'rb') if t == 'pickle': if t_data == 'graph': self.graph = pickle.load(f) if t_data == 'visited': self.visited = pickle.load(f) if t_data == 'ql': self.ql = pickle.load(f) if t == 'json': if t_data == 'graph': self.graph = json.load(open(name)) if t_data == 'visited': self.visited = json.load(open(name)) if t_data == 'ql': self.ql = json.load(open(name)) f.close()  class Game(): def __init__(self, agents, depth=100): self.agents = agents #\u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0433\u0435\u043d\u0442\u043e\u0432 self.depth = depth #\u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u043f\u043e\u0438\u0441\u043a\u0430  def run(self): cur_agent = [None]*len(self.agents) for i in range(len(self.agents)): cur_agent[i] = self.agents[i][2]  for i in range(self.depth): for j in range(len(self.agents)): who = i%len(self.agents) next_who = (i+1)%len(self.agents)  cur = agents[who][0].training(agents[who][1], current=cur_agent[who], depth=1, epochs=1) cur_agent[who] = cur  for i in range(len(agents)): who = i%len(self.agents) next_who = (i+1)%len(self.agents) print() print(\"who = \", who, \" ql = \\n\", agents[who][0].ql) print(\"who = \", who,  \" path = \", agents[who][0].get_ql_path(agents[who][2], agents[who][3], depth=100))  agents[who][0].show() print()  win = [(None, agents[0][2])]  for i in range(self.depth): who = i%len(self.agents) next_who = (i+1)%len(self.agents)  for step in range(1, agents[who][4]+1): path = agents[who][0].get_ql_path(agents[who][2], agents[who][3], depth=100) if path: cur = path[1]  if cur == agents[who][3]:  win.append((who, cur)) return (who, win)  if step == agents[who][4]: agents[next_who][2] = cur win.append((who, cur)) break else: agents[who][2] = cur win.append((who, cur)) else: win.append((who, \"pass\")) self.agents[next_who][2] = self.agents[who][2] break  return (-1, win) #\u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0432\u044b\u0438\u0433\u0430\u043b   if __name__ == \"__main__\": agents_won = [] #\u043a\u0442\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0438\u0433\u0440\u0430\u043b k = 1 #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0433\u0440  #\u0421\u043f\u0438\u0441\u043a\u0438 \u043f\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e #\u043a \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u0435 \u0440\u043e\u043b\u0438 \u043d\u0435 \u0438\u0433\u0440\u0430\u044e\u0442. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0433\u0440\u0430\u0444\u044b for i in range(1, k+1): g1 = Ql([str(f) for f  in range(10, 20)], [str(x) for x  in range(70, 90)]) g2 = Ql([str(f) for f  in range(10, 20)], [str(x) for x  in range(70, 90)]) g3 = Ql([str(f) for f  in range(10, 20)], [str(x) for x  in range(70, 90)])  g1.load_file('graph_w1.json', t_data = 'graph', t='json') g2.load_file('graph_b.json', t_data = 'graph', t='json') g3.load_file('graph_w.json', t_data = 'graph', t='json')  # s - \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, e - \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, b - \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 s = '1'; e = '9'; b = '10' # \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 - \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0437\u0430 \u0440\u0430\u0437 agents = [[g1, {e: 5, b: -6}, s, e, 1], [g2, {e: 5, b: -6}, s, e, 1], [g3, {e: 5, b: -6}, s, e, 1]]  if len(agents_won) != len(agents): agents_won = [0]*len(agents)  gm = Game(agents, depth=100) r = gm.run()  if r[0] > -1: print(\"agent \", r[0], \" won:  \", r[1]) if r[0] == 0: agents_won[0] +=1 if r[0] == 1: agents_won[1] +=1 if r[0] == 2: agents_won[2] +=1 else: print(\"agents won: \", [])  print(\"\\n  The agents won:  \", agents_won)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/671076\/\"> https:\/\/habr.com\/ru\/post\/671076\/<\/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<p>\u041d\u0430 \u0441\u0442\u0435\u043d\u0435 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c. \u041d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0446\u0435\u043b\u0438, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u0442. \u0427\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c.<\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e. \u041f\u0443\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e {a, b, c, d}. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 {a, b}, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 {c, d}. \u041f\u0443\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u043c: \u0441|d=a(c), \u0441|d=b(c), c=a(d), \u0441|d=b(d).<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c &#171;|&#187; \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 &#171;\u043b\u0438\u0431\u043e&#187;. \u0422\u0430\u043a \u0441|d=b(d) \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442: \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f d \u043f\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438\u0431\u043e c, \u043b\u0438\u0431\u043e d.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u043d\u0430\u0447\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c: \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f {a, c}, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f {b, d}. \u041f\u0443\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u043c: b=a(b), b|d=c(b), d=a(d), b=c(d).<\/p>\n<p>\u0420\u0430\u0437\u043d\u0438\u0446\u0430, \u0435\u0441\u043b\u0438 \u0435\u0435 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438, \u0432\u0437\u044f\u0442\u044b\u0439 \u043a\u0430\u043a \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0431\u044b\u043b\u0438 \u0431\u044b \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b \u043a \u0432\u0441\u0435\u043c \u0441\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u043c\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430\u043c,\u00a0 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 4\/7. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 4\/5. \u0418\u043b\u0438, \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043f\u043e\u0447\u0442\u0438 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439. \u0414\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e.  <\/p>\n<p>\u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0432\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0441\u0442\u0430\u0442\u044c\u0435. \u0415\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f (\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439), \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0430. \u0418 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0433\u0435\u043d\u0442\u043e\u0432, \u0446\u0435\u043b\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041a\u043e\u0442\u043e\u0440\u044b\u0435, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0433\u0443\u0442 \u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c. \u041e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u0438 \u0430\u0433\u0435\u043d\u0442\u044b \u043d\u0435 \u0432\u0435\u0434\u0430\u044e\u0442 \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0430\u0433\u0435\u043d\u0442\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u0445\u043e\u0434\u044b \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0438\u043c\u0438 QL-\u043a\u0430\u0440\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0433\u0435\u043d\u0442\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. <\/p>\n<p>\u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u00a0 \u0438\u0433\u0440\u0430\u043c, \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435 \u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 QL-\u043a\u0430\u0440\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432. \u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043f\u0440\u0438 \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0445\u043e\u0434\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044d\u043c\u043f\u0430\u0442\u0438\u0438. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u0430 \u0442\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0430 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u044b load_file. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u0438\u0433\u0440\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0440\u0438 \u0430\u0433\u0435\u043d\u0442\u0430. \u0426\u0435\u043b\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e &#8212; \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=9. \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=10 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0433\u0435\u043d\u0442 \u0441 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c graph_b &#8212; \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c. \u0418\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4 \u0438\u043c\u0435\u0435\u043c \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u044c, \u0442.\u043a. \u043f\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 11 \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=5, \u043b\u0438\u0431\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=1. \u0418\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=3 \u0435\u0435 \u043d\u0435\u0442, \u0442.\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f 11 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043e\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f 13. \u0412\u044b\u0437\u043e\u0432 g2.get_ku() \u0432\u0435\u0440\u043d\u0435\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438 0.917=11\/12. <\/p>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u0433\u0435\u043d\u0442 \u0441 graph_w &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043f\u043e \u0447\u0435\u0440\u043d\u044b\u043c, \u0442\u0430\u043a \u0438 \u043f\u043e \u0441\u0438\u043d\u0438\u043c \u0441\u0442\u0440\u0435\u043b\u043a\u0430\u043c. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f: g3.get_ku() \u0432\u0435\u0440\u043d\u0435\u0442 0.933. \u041f\u0435\u0440\u0432\u044b\u0439 \u0436\u0435 \u0430\u0433\u0435\u043d\u0442 \u0441 graph_w1 \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u043a \u0443  graph_w \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 9=12(2), \u0442.\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432 9 \u0438\u0437 2 \u043f\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 12 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0435\u0442. \u0415\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0432\u0435\u043d 0.929<\/p>\n<pre><code>{ \"1\": [[\"2\", \"11\"], [\"10\", \"15\"]],  \"2\": [[\"3\", \"11\"]],  \"3\": [[\"4\", \"11\"], [\"2\", \"13\"], [\"6\", \"12\"]],  \"4\": [[\"5|1\", \"11\"]],  \"5\": [[\"6\", \"11\"]],  \"6\": [[\"7\", \"11\"]],  \"7\": [[\"8\", \"11\"], [\"5\", \"12\"]],  \"8\": [[\"9\", \"11\"]],  \"9\": [],  \"10\":[[\"5\", \"15\"]] }  { \"1\": [[\"2\", \"11\"], [\"10\", \"15\"]],  \"2\": [[\"3\", \"11\"]],  \"3\": [[\"4\", \"11\"], [\"2\", \"13\"]],  \"4\": [[\"5|1\", \"11\"]],  \"5\": [[\"6\", \"11\"]],  \"6\": [[\"7\", \"11\"]],  \"7\": [[\"8\", \"11\"]],  \"8\": [[\"9\", \"11\"]],  \"9\": [],  \"10\":[[\"5\", \"15\"]] }  { \"1\": [[\"2\", \"11\"], [\"10\", \"15\"]], \"2\": [[\"3\", \"11\"], [\"9\", \"12\"]],  \"3\": [[\"4\", \"11\"], [\"2\", \"13\"], [\"6\", \"12\"]],  \"4\": [[\"5|1\", \"11\"]],  \"5\": [[\"6\", \"11\"]],  \"6\": [[\"7\", \"11\"]],  \"7\": [[\"8\", \"11\"], [\"5\", \"12\"]],  \"8\": [[\"9\", \"11\"]],  \"9\": [], \"10\":[[\"5\", \"15\"]] }<\/code><\/pre>\n<p>\u0421\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0433\u0435\u043d\u0442\u043e\u0432  [[g1, {e: 5, b: -6}, s, e, 1], [g2, {e: 5, b: -6}, s, e, 1], [g3, {e: 5, b: -6}, s, e, 1]]. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0433\u0440 k=1.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0438\u0433\u0440\u043e\u043a who=0 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 QL-\u043a\u0430\u0440\u0442\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043b\u043e\u0436\u0435\u043d \u043c\u0430\u0440\u0448\u0440\u0443\u0442 [1,2,3,6,7,8,9]. \u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0433\u0435\u043d\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u0422\u0440\u0435\u0442\u044c\u0435\u043c\u0443 \u0430\u0433\u0435\u043d\u0442\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442. <\/p>\n<p>\u041f\u0440\u0438 \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0445\u043e\u0434\u043e\u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u043e \u0446\u0435\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0430\u0447\u0435. \u041c\u0430\u0440\u0448\u0440\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u043c\u0438 (\u0430\u0433\u0435\u043d\u0442, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435). \u0418\u0437 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=1 \u0430\u0433\u0435\u043d\u0442 who=0 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=2. \u0414\u0430\u043b\u0435\u0435 who=1 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=3. \u0417\u0430\u0442\u0435\u043c who=2 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0432\u043e\u0435\u0439 QL-\u043a\u0430\u0440\u0442\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0430\u0434 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=2 (\u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0435\u0433\u043e \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c). \u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0433\u0435\u043d\u0442 \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=2 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=3, \u0442.\u043a \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0446\u0435\u043b\u0438 \u0432 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438. <\/p>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4 \u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0433\u0435\u043d\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=1 (\u0432 \u0441\u0438\u043b\u0443 \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4). \u041c\u0430\u0440\u0448\u0440\u0443\u0442 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0433\u0435\u043d\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435=5. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=9 \u0441 \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0445\u043e\u0434\u043e\u0432. \u0412 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0433\u0435\u043d\u0442 who=0.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c 100 \u0438\u0433\u0440. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0434\u043e \u0446\u0435\u043b\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u0433\u0440\u044b. \u0422\u0430\u043a \u0432\u044b\u0448\u043b\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=3 \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4 ql=1.57, \u0430 \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=2 ql=2.39. \u0418\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f 2 \u0438 3 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a QL-\u043a\u0430\u0440\u0442\u0430 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c? \u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 (\u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e\u0435) \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0438\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f=4.<\/p>\n<p>\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432=4 \u0437\u0430 \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u0433\u0440\u0435 \u043e\u043d \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 [3, 4, 1, 2]. \u0412 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0435 \u0438\u0437 100 \u0438\u0433\u0440 \u0442\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0445\u043e\u0434\u043e\u0432 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0433\u0435\u043d\u0442.<\/p>\n<p>\u041a\u043e\u0434 \u043d\u0438\u0436\u0435. \u041a\u0430\u043a\u0438\u0445-\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435 \u043d\u0435\u0441\u0435\u0442.<\/p>\n<pre><code>import random, pickle, json  class GenGraph(): def __init__(self, f_list, x_list, n=4): '''f_list - \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, x_list - \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439' \u0426\u0435\u043b\u0435\u0441\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0441\u043e\u0435\u0434\u0435\u043d\u044f\u0442\u044c \u0433\u0440\u0430\u0444\u044b''' self.n = n self.graph = self.initG(f_list, x_list)  def rnd_get(self, v): return random.choice(v.split(\"|\"))  def show(self): for x in self.graph: print(x, \":\", self.graph[x])  def return_graph(self): return self.graph  def get_ku(self): '''return (\u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u0438, \u0440\u0430\u0437\u043c\u0435\u0440)''' n = 0; u = 0 for x in self.graph: for y in self.graph[x]: u += y[0].count(\"|\") n += 1 if n != 0: return (round(1- u\/(n+u), 3), n)  else: return (None, None)  def initG(self, f_list, x_list): rnd_dict = dict() r = len(x_list) rnd_list = x_list[:]  for x in rnd_list: min21 = random.randint(0, len(rnd_list)\/\/self.n) min22 = random.randint(0, len(rnd_list)\/\/self.n)  if min21 &lt;= min22: k=random.randint(min21, min22) rnd_x = list(set(random.choices(rnd_list, k=k)))  rnd_fx = [(x, random.choice(f_list)) for x in rnd_x] else:  k=random.randint(min22, min21) rnd_x = list(set(random.choices(rnd_list, k=k))) rnd_fx = [(x, random.choice(f_list)) for x in rnd_x] rnd_dict[x] = rnd_fx  return rnd_dict  def add_uncertainty(self, u=0): '''\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043c \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u044c''' for i in range(u): w = random.choice(list(self.graph.keys()))  if self.graph[w] != []: x = random.choice(self.graph[w]) add = random.choice(list(self.graph.keys()))  if add not in x[0].split('|'): x0 = x[0] + '|' + add ind = self.graph[w].index(x) self.graph[w][ind] = [x0, x[1]]  class Ql(GenGraph): def __init__(self, f_list, x_list): super().__init__(f_list, x_list)  self.visited = {} self.ql = {} self.gamma = 0.9  def training(self, target, current=None, depth=1, epochs=1): '''\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c QL-\u043a\u0430\u0440\u0442\u0443: \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441 \u0434\u0438\u0441\u043a\u043e\u043d\u0442\u043e\u043c \u043e\u0442 \u0446\u0435\u043b\u0438''' ls = sorted(list(target.items()), key = lambda t: t[1], reverse = True) if ls[0][0] not in self.graph or current not in self.graph: return  for epoch in range(1, epochs+1): if current == None: current = random.choice(list(self.graph))  if current not in self.visited:  self.visited[current] = 1  self.ql[current] = 0   n = depth while n > 0: if current in target: self.ql[current] = target[current]  if self.graph[current] == []: vs = sorted(self.visited.items(), key = lambda t: t[1]) vs = [x for x in vs if vs[0][1] == x[1]] vq = [x for x in vs if self.ql[x[0]] == 0] if vq: current = vq[0][0] else: current = random.choice(vs)[0] self.visited[current] +=1  neighbors = [random.choice(x[0].split('|')) for x in self.graph[current]]  if not neighbors: n -=1  continue  for x in neighbors: if x not in self.visited: self.visited[x] = 0 self.ql[x] = 0  ql_sort = sorted([(x, self.ql[x]) for x in neighbors], key = lambda t: t[1], reverse=True) ql_max = random.choice([x for x in ql_sort if ql_sort[0][1] == x[1]])  if current not in target: self.ql[current] = round(self.gamma*ql_max[1], 2)  visited_sort = sorted([(x, self.visited[x]) for x in neighbors], key = lambda t: t[1]) visited_min = random.choice([x for x in visited_sort if visited_sort[0][1] == x[1]]) self.visited[visited_min[0]] +=1 current = visited_min[0]  n -=1  return current  def get_ql_path(self, current, target, depth=100): '''\u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u043e \u0446\u0435\u043b\u0438''' path = [current] while depth > 0: if current == None or target not in self.graph: return [] if current == target: return path  mx = 0 neighbor_mx = None neighbors = [random.choice(x[0].split('|')) for x in self.graph[current]]  for neighbor in neighbors: #if neighbor in self.ql and neighbor not in path: if neighbor in self.ql: if self.ql[neighbor] >= mx: mx = self.ql[neighbor] neighbor_mx = neighbor else: continue  current = neighbor_mx path += [current] depth -=1  return []  def save_file(self, name, t_data, t='pickle'): f = open(name, 'wb') if t == 'pickle': if t_data == 'graph': pickle.dump(self.graph, f) if t_data == 'visited': pickle.dump(self.visited, f) if t_data == 'ql': pickle.dump(self.ql, f) if t == 'json': if t_data == 'graph': json.dump(self.graph, open(name, 'w')) if t_data == 'visited': json.dump(self.visited, open(name, 'w')) if t_data == 'ql': json.dump(self.ql, open(name, 'w')) f.close()  def load_file(self, name, t_data, t='pickle'): f = open(name, 'rb') if t == 'pickle': if t_data == 'graph': self.graph = pickle.load(f) if t_data == 'visited': self.visited = pickle.load(f) if t_data == 'ql': self.ql = pickle.load(f) if t == 'json': if t_data == 'graph': self.graph = json.load(open(name)) if t_data == 'visited': self.visited = json.load(open(name)) if t_data == 'ql': self.ql = json.load(open(name)) f.close()  class Game(): def __init__(self, agents, depth=100): self.agents = agents #\u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0433\u0435\u043d\u0442\u043e\u0432 self.depth = depth #\u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u043f\u043e\u0438\u0441\u043a\u0430  def run(self): cur_agent = [None]*len(self.agents) for i in range(len(self.agents)): cur_agent[i] = self.agents[i][2]  for i in range(self.depth): for j in<\/code><\/pre>\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-334415","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334415","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=334415"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334415\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}