{"id":331687,"date":"2022-04-08T09:00:46","date_gmt":"2022-04-08T09:00:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331687"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331687","title":{"rendered":"<span>\u00ab\u042d\u0432\u043e\u043b\u044e\u0446\u0438\u044f \u043f\u0440\u043e\u0442\u0438\u0432 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432\u00bb \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043e \u0440\u0430\u043d\u0446\u0435. \u041c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u043b\u0438 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043b\u0443\u0447\u0448\u0435? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/afc\/ccc\/003\/afcccc003d1b46a095ffb4a92cafdefd.png\" alt=\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 ruDALL-E XL\" title=\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 ruDALL-E XL\" width=\"1281\" height=\"720\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/afc\/ccc\/003\/afcccc003d1b46a095ffb4a92cafdefd.png\"\/><figcaption>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 ruDALL-E XL<\/figcaption><\/figure>\n<p>\u00a0\u041c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u043e\u0431\u0449\u0435\u043f\u0440\u0438\u0437\u043d\u0430\u043d\u043d\u044b\u0445 \u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u043b\u0438\u0434\u0435\u0440\u043e\u0432 \u043f\u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 (\u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438). \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435, \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u2014 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439. \u041a\u0430\u043a\u043e\u0439 \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c \u0438\u0445 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u043c\u0435\u043d\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u2014 \u0437\u0430\u0434\u0430\u0447\u0435 \u043e \u0440\u0430\u043d\u0446\u0435.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043e \u0440\u0430\u043d\u0446\u0435 \u0438\u043b\u0438 knapsack problem \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0442\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u0438 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445. \u0421\u043b\u043e\u0436\u043d\u043e? \u041f\u0440\u043e\u0449\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445.<\/p>\n<p>\u041f\u0440\u0438\u0445\u043e\u0434\u044f \u0432 \u0441\u0443\u043f\u0435\u0440\u043c\u0430\u0440\u043a\u0435\u0442 \u043c\u044b \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0435\u0448\u0430\u0435\u043c: \u00ab\u0427\u0435\u0433\u043e \u0431\u044b \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u0443\u043f\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0446\u0435\u043b\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u043d\u0435 \u043a\u0430\u0442\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0433\u043e\u0440\u043e\u0434\u0430 \u0440\u0430\u0434\u0438 \u0448\u043e\u043f\u0438\u043d\u0433\u0430, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043c \u0432\u0441\u0435\u0439 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u044b?\u00bb \u0418\u043b\u0438, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0443\u0434\u0430\u0447\u043d\u043e \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u043a\u0440\u043e\u0432\u043d\u043e \u043d\u0430\u0436\u0438\u0442\u044b\u0435. \u0417\u0430\u0445\u043e\u0434\u0438\u0442\u0435 \u0432 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0431\u0430\u043d\u043a\u0430, \u0438 \u0433\u043b\u0430\u0437\u0430 \u0440\u0430\u0437\u0431\u0435\u0433\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0435\u043d\u044c\u0433\u0438. \u0410 \u043d\u0430\u0448\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043a \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u043c\u0443 \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043d\u0435 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b. \u0412\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0445\u043e\u0434\u0438\u0442\u0435 \u0437\u0430 \u043f\u043e\u043a\u0443\u043f\u043a\u0430\u043c\u0438 \u0438\u043b\u0438 \u0440\u0435\u0448\u0430\u0435\u0442\u0435, \u043a\u0443\u0434\u0430 \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0435\u043d\u044c\u0433\u0438? \u041d\u0435\u0442, \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0422\u043e \u0435\u0441\u0442\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0442\u0430\u043a \u2013 \u043e\u0431\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442\u0435 \u0441\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440. \u041d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u0432\u044b \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 knapsack problem.<\/p>\n<p>\u041f\u043e\u0434\u044b\u0442\u043e\u0436\u0438\u043c: \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u0432\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u2014 \u0432\u0435\u0441 \u0438 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c. \u0420\u0430\u043d\u0435\u0446, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b, \u0438\u043c\u0435\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0435\u0441\u0443. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u044e\u043a\u0437\u0430\u043a\u0435.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u043d\u043e \u043e\u0442 \u0442\u043e\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u2014 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439 \u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u043e\u043d\u0438\u0438 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u043f\u0440\u0438 \u0434\u043e\u0431\u044b\u0447\u0435 \u0438\u043c\u0438 \u043f\u0438\u0449\u0438. \u0412 \u043f\u0430\u0440\u0435 \u0441\u043b\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0434\u0435\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0442\u0430\u043a: \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043f\u0438\u0449\u0438 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u0441\u043b\u0435\u0434 \u0438\u0437 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043f\u0443\u0442\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u043e\u0432, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u0438. \u0421\u0440\u0430\u0437\u0443 \u0436\u0435 \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043e\u043f\u0435\u0440\u0435\u0436\u0430\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u0430\u043a\u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u043f\u043e\u0434 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432, \u0445\u043e\u0442\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430\u043c \u043d\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u0432 \u0440\u0430\u043d\u0435\u0446 &#8212; \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u043c\u043a\u0430 \u0432\u044b\u0434\u0435\u0440\u0436\u0430\u043b\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u0443\u0440\u0430\u0432\u044c\u044f, \u043a\u0430\u043a \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0430\u043d\u043a\u0430, \u0442\u0430\u043a\u043e\u0433\u043e \u00ab\u0438\u043d\u0432\u0435\u0441\u0442\u043e\u0440\u0430\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442, \u0432\u043e \u0447\u0442\u043e \u0435\u043c\u0443 \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0435\u043d\u044c\u0433\u0438.<\/p>\n<p>\u042d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0438\u043b\u0438 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u0432\u044f\u0437\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0431\u043e\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u044b\u0435 \u043e\u0441\u043e\u0431\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0436\u0438\u0442\u044c \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u043e\u0442\u043e\u043c\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u044b\u043c, \u0447\u0435\u043c \u0438\u0445 \u043f\u0440\u0435\u0434\u043a\u0438.<\/p>\n<p>\u0425\u0432\u0430\u0442\u0438\u0442 \u0441 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c \u0432 \u0442\u0435\u043e\u0440\u0438\u044e \u2014 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043a\u043e\u0434\u0443!<\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u041e\u041e\u041f. \u0412 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u043b\u0430\u0441\u0441\u044b Investment, Ant \u0438 AntAlgorithm. Investment \u2014 \u044d\u0442\u043e \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430 \u0438\u0437 \u0440\u0430\u043d\u0446\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0438 (\u0438\u043b\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442 \u043c\u0443\u0440\u0430\u0432\u0435\u0439), \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u043d\u0430\u0448\u0435\u0439 \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0438 (\u0432\u0435\u0441 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430), \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430 \u0438 id.<\/p>\n<pre><code class=\"python\">class Investment:     def __init__(self, id, cost, profit):         self._id = id         self._cost = cost         self._profit = profit         self._pheromone = 1.0<\/code><\/pre>\n<p>Ant \u2014 \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043c\u0443\u0440\u0430\u0432\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043d\u0438\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u043b\u043e\u0436\u0438\u0442\u044c (\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u044e\u043a\u0437\u0430\u043a\u0430), \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043d\u0435\u0433 \u043e\u043d \u0443\u0436\u0435 \u0432\u043b\u043e\u0436\u0438\u043b, \u0441\u0432\u043e\u0439 \u0434\u043e\u0445\u043e\u0434 (\u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0445 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u043c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432) \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u043d\u0430\u0431\u043e\u0440 \u044d\u0442\u0438\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 (\u0438\u043b\u0438 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0439).<\/p>\n<pre><code class=\"python\">\u043cclass Ant:     def __init__(self, max_cost):         self._max_cost = max_cost         self._cost = 0         self._profit = 0         self._portfolio = []<\/code><\/pre>\n<p>\u0418 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 AntAlgorithm.<\/p>\n<pre><code class=\"python\">class AntAlgorithm:     def __init__(self, count_ants, count_iteration, max_ant_cost, items, evaporation_coefficient):         self._count_ants = count_ants         self._count_iteration = count_iteration         self._max_ant_cost = max_ant_cost         self._items = items         self._evaporation_coefficient = evaporation_coefficient<\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u044e\u043a\u0437\u0430\u043a\u0430 (\u043e\u043d\u0430 \u0436\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0439 \u043c\u0443\u0440\u0430\u0432\u044c\u044f), \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 (\u0432\u0435\u0441\u0430, \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 id \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445) \u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0438\u0441\u043f\u0430\u0440\u0435\u043d\u0438\u044f.<\/p>\n<p>\u00ab\u041f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u0447\u0442\u043e \u0437\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0438\u0441\u043f\u0430\u0440\u0435\u043d\u0438\u044f?\u00bb &#8212; \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b. \u0421\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c \u0434\u043e \u0435\u0434\u044b, \u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0441\u0432\u043e\u0439 \u0444\u0435\u0440\u043e\u043c\u043e\u043d \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438. \u041e\u0442 \u044d\u0442\u043e\u0433\u043e \u0435\u0433\u043e \u043d\u0430\u0441\u044b\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u0436\u0435, \u0447\u0435\u043c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c \u043f\u0443\u0442\u0438 \u0434\u043e \u00ab\u0431\u043b\u044e\u0434\u0430\u00bb, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0443\u0442\u044c. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0444\u0435\u0440\u043e\u043c\u043e\u043d \u043d\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0434\u043e\u0440\u043e\u0433\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u0430\u0440\u044f\u0435\u0442\u0441\u044f. \u0418 \u0438\u0441\u043f\u0430\u0440\u044f\u0435\u0442\u0441\u044f \u043e\u043d \u0442\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u043f\u0443\u0442\u044c. \u0422\u0430\u043a \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u0441\u043f\u0430\u0440\u0435\u043d\u0438\u044e, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0443\u0442\u044f\u0445. <\/p>\n<p>\u041d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c! \u041c\u044b \u0443\u0436\u0435 \u043d\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0438, \u0438\u0449\u0443\u0449\u0438\u0435 \u0434\u043e\u0440\u043e\u0433\u0443 \u0434\u043e \u043f\u0438\u0449\u0438, \u043c\u044b \u043c\u0443\u0440\u0430\u0432\u044c\u0438-\u0438\u043d\u0432\u0435\u0441\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435, \u0430 \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435! \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u043c\u0435\u0442, \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0438\u0436\u0435, \u043d\u043e \u0435\u0449\u0451 \u0438 \u0434\u043e\u0445\u043e\u0434 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0448\u0435, \u0442.\u0435. \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043a \u0432\u0435\u0441\u0443 \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0438 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/e28\/210\/13a\/e2821013a3dbdeadf9457cee21df8632.jpg\" width=\"789\" height=\"333\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e28\/210\/13a\/e2821013a3dbdeadf9457cee21df8632.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u00ab\u0432\u043a\u043b\u0430\u0434\u044b\u00bb, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0444\u0435\u0440\u043e\u043c\u043e\u043d \u043d\u0430 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/46e\/fc0\/778\/46efc0778f602d8b1f1bb01feac9ff13.png\" width=\"678\" height=\"218\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46e\/fc0\/778\/46efc0778f602d8b1f1bb01feac9ff13.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0442\u0430\u043a \u0432\u043e\u0442 \u0438 \u0432\u0441\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u0441 \u0441\u0430\u043c\u044b\u043c \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043e\u0445\u043e\u0434\u0430 \u043a \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u044e\u043a\u0437\u0430\u043a\u0430. \u0411\u0438\u043d\u0433\u043e! \u041d\u043e \u043d\u0435 \u0432\u0441\u0451 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u0427\u0430\u0441\u0442\u043e \u0432 \u0445\u043e\u0434\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u044b \u2014 \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445, \u043d\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u0442\u0430\u043a\u0438\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u044b, \u043b\u0438\u0431\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0432\u043e\u0434\u044f\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u00ab\u044d\u043b\u0438\u0442\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432\u00bb \u2014 \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u043f\u0443\u0442\u0451\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u0441\u0432\u043e\u0439 \u0441\u0447\u0451\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u043e\u0432 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0443\u0442\u044f\u0445. \u0422\u0430\u043a\u0438\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c, \u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u044b.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u041d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0451 WolfWallStreet<\/p>\n<pre><code class=\"python\">def WolfWallStreet (self):<\/code><\/pre>\n<p>\u0412 \u043d\u0451\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0432\u043a\u043b\u0430\u0434\u043e\u0432.<\/p>\n<pre><code class=\"python\">inventory = [] i = 0 while (i &lt; len(self._items[0])):     inventory.append(Investment(self._items[2][i], self._items[0][i], self._items[1][i]))     i += 1<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u00ab\u044d\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u044f\u00bb \u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0446\u0438\u043a\u043b \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<pre><code class=\"python\">i = 0 best_ant = Ant(self._max_ant_cost) while (self._count_iteration > i):<\/code><\/pre>\n<p>\u0412\u0432\u0435\u0434\u0451\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e sum \u0434\u043b\u044f \u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0441\u0443\u043c\u043c\u044b <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d33\/cda\/eef\/d33cdaeef59a1a253862a568a0b73415.png\" width=\"140\" height=\"39\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d33\/cda\/eef\/d33cdaeef59a1a253862a568a0b73415.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u00a0\u0438\u0437 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0451. \u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432.<\/p>\n<pre><code class=\"python\">sum = 0 j = 0 while (j &lt; len(inventory)):     sum += (inventory[j].pheromone ** P) * ((inventory[j].profit \/ inventory[j].cost) ** Q)     j += 1<\/code><\/pre>\n<p>\u0418 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"python\">j = 1 investment_probability = [] investment_probability.append((inventory[0].pheromone ** P) * ((inventory[0].profit \/ inventory[0].cost) ** Q) \/ sum) while (j &lt; len(inventory)):     investment_probability.append(         investment_probability[j - 1] + ((inventory[j].pheromone ** P) * (((inventory[j].profit \/ inventory[j].cost) ** Q) \/ sum)))     j += 1 <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0430\u0434 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0432\u044b\u0431\u0440\u0430\u043b \u0441\u0432\u043e\u0438 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Ant \u00ab\u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0435\u0433\u043e \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c\u00bb.<\/p>\n<pre><code class=\"python\">def BuildPortfolio(self, investment_probability, inventory):     min_cost_investment = inventory[0].cost # \u0412\u043a\u043b\u0430\u0434 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043e\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e     min_cost_iter = 0 # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u043a\u043b\u0430\u0434\u0430 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043e\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e     investment_availability = [1] * len(inventory) # \u0421\u043f\u0438\u0441\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0432\u043a\u043b\u0430\u0434\u0430     while ((self._max_cost - self._cost) >= min_cost _investment):         rand = random.random()# \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e          k = 0         while (k &lt; (len(inventory))):             if ((investment_probability[k] >= rand) &amp; ((investment_availability[k] == 0) | ((self._max_cost - self._cost) &lt; inventory[k].cost))):                 break # \u0415\u0441\u043b\u0438 \u0432\u043a\u043b\u0430\u0434 \u043c\u044b \u0443\u0436\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u044f             if ((investment_probability[k] >= rand) &amp; (investment_availability[k] == 1) &amp; ((self._max_cost - self._cost) >= inventory[k].cost)): # \u041d\u0430\u0448\u043b\u0438 \u0431\u043b\u044e\u0434\u043e                 investment_availability[k] = 0 # \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u043a\u043b\u0430\u0434\u0430                 self._portfolio.append(inventory[k]) # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u00ab\u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c\u00bb                 self._cost += inventory[k].cost # \u041f\u043e\u0432\u044b\u0448\u0430\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438                 self._profit += inventory[k].profit # \u0418 \u0434\u043e\u0445\u043e\u0434\u0430                 if (k == min_cost _iter): # \u0415\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u043a\u043b\u0430\u0434 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0432\u043a\u043b\u0430\u0434\u043e\u043c \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u2014 \u0438\u0449\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432\u043a\u043b\u0430\u0434                     investment_availability[min_cost_iter] = 0                     min_cost_iter = next((j for j, x in enumerate(investment_availability) if x), None)                     if (min_cost_iter != None):                         min_cost_investment = inventory[min_cost_iter].cost                     else:                         break                 break             k += 1     return self<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0438 \u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u0438, \u043f\u043e\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u0438\u044e \u043d\u0430 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441 AntAlgorithm \u0438 \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044e \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432; \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u044d\u043b\u0438\u0442\u043d\u043e\u0433\u043e.<\/p>\n<pre><code class=\"python\">j = 0 ant_population = [] while (self._count_ants > j):     ant_population.append(Ant(self._max_ant_cost).BuildPortfolio(investment_probability, inventory))     if (best_ant.profit &lt; ant_population[j].profit):         best_ant = ant_population[j]     j += 1<\/code><\/pre>\n<p>\u041c\u0443\u0440\u0430\u0432\u044c\u0438 \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0432\u043a\u043b\u0430\u0434\u044b, \u044d\u043b\u0438\u0442\u043d\u044b\u0439 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0432\u044b\u0431\u0440\u0430\u043d, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u2014 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0444\u0435\u0440\u043e\u043c\u043e\u043d. \u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0430: \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043a\u043b\u0430\u0434 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u0434\u043e\u0445\u043e\u0434\u0430 \u0438 \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0440\u0430\u0442\u0438\u0442 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430 \u043d\u0451\u043c. \u0422\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u044b \u0441 \u044d\u043b\u0438\u0442\u043d\u044b\u043c \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u043c, \u0447\u0442\u043e\u0431\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0442\u0435\u0445 \u0432\u043a\u043b\u0430\u0434\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u044b \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0438.<\/p>\n<pre><code class=\"python\">while (self._count_ants > j):     sum_function = 0 # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0451\u0442\u0430 \u0441\u0443\u043c\u043c\u044b \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u0432\u044b\u0433\u043e\u0434\u044b \u043a \u0437\u0430\u0442\u0440\u0430\u0442\u0430\u043c     y = 0     while (y &lt; len(ant_population[j].portfolio)):         sum_function += ant_population[j].portfolio[y].profit \/ ant_population[j].portfolio[y].cost         y += 1     y = 0     pheromone_coefficient = ant_population[j].profit \/ best_ant.profit # \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0433\u043e\u0434\u0443 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044f \u043c\u0443\u0440\u0430\u0432\u044c\u044f \u0441 \u0432\u044b\u0433\u043e\u0434\u043e\u0439 \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0439 \u044d\u043b\u0438\u0442\u043d\u043e\u0433\u043e     while (y &lt; len(ant_population[j].portfolio)):         inventory[ant_population[j].portfolio[y].id].pheromone += pheromone_coefficient \/ sum_function * (inventory[             ant_population[j].portfolio[y].id].profit \/ inventory[ant_population[j].portfolio[y].id].cost) # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u043a\u043b\u0430\u0434\u0443 \u0444\u0435\u0440\u043e\u043c\u043e\u043d         y += 1     j += 1 <\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0438\u0442\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u0434\u043b\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430 \u043d\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0438 \u0432\u043a\u043b\u0430\u0434\u0430\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439<\/p>\n<pre><code class=\"python\">j = 0 while (j &lt; len(best_ant.portfolio)):     sum_function += best_ant.portfolio[j].profit \/ best_ant.portfolio[j].cost     j += 1<\/code><\/pre>\n<p>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0435\u0440\u043e\u043c\u043e\u043d.<\/p>\n<pre><code class=\"python\">j = 0 while (j &lt; len(best_ant.portfolio)):     inventory [best_ant.portfolio[j].id].pheromone += i * sum_function * \\         (inventory [best_ant.portfolio[j].id].profit \/ inventory[best_ant.portfolio[j].id].cost)     j += 1<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u2014 \u0438\u0441\u043f\u0430\u0440\u0435\u043d\u0438\u0435 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430. <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1fb\/991\/34c\/1fb99134ca213e1d183d9bef244e1e24.png\" width=\"121\" height=\"35\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1fb\/991\/34c\/1fb99134ca213e1d183d9bef244e1e24.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u00a0\u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u0432 \u0445\u043e\u0434\u0435 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043d\u0430 <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4ee\/8e2\/17a\/4ee8e217a560fcd9b2ed24bad3b5be69.png\" width=\"93\" height=\"35\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4ee\/8e2\/17a\/4ee8e217a560fcd9b2ed24bad3b5be69.png\"\/><figcaption><\/figcaption><\/figure>\n<pre><code class=\"python\">j = 0 while (len(inventory) > j):     inventory[j].pheromone = (1 - self._evaporation_coefficient) * inventory[j].pheromone     j += 1<\/code><\/pre>\n<p>\u0417\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u044d\u043b\u0438\u0442\u043d\u044b\u0439 \u043c\u0443\u0440\u0430\u0432\u0435\u0439.<\/p>\n<pre><code class=\"python\">    i += 1 best_ant.ShowMeYourPortfolio () result = [best_ant.cost, best_ant.profit, best_ant. InvestmentsToItems()] return result<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 ShowMeYourPortfolio \u0438 InvestmentsToItems \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Ant \u0434\u043b\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 Investment \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043b\u0438\u0441\u0442\u044b.<\/p>\n<pre><code class=\"python\">def ShowMeYourPorttfolio(self):     portfolio_id = '[ '     i = 0     while (len(self._portfolio) > i):         portfolio_id = portfolio_id + str(self._portfolio[i].id) + ' '         i += 1     portfolio_id = portfolio_id + ']'     print(f'weight = {self._cost } value = {self._profit} {portfolio_id}') def InvestmentsToItems(self):     i = 0     items = []     while (len(self._portfolio) > i):         items.append(self._portfolio[i].id)         i += 1     return items<\/code><\/pre>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430\u0448\u0438\u0445 \u0442\u0440\u0443\u0434\u043e\u0432. \u0412 main \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432\u0435\u0441\u0430, \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e id. \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u0432\u0435\u0441\u0430.<\/p>\n<pre><code class=\"python\">items = [[1, 3, 4, 4, 5, 5, 6, 7, 8, 10, 12, 17], # \u0432\u0435\u0441          [6, 2, 4, 10, 5, 17, 13, 9, 7, 16, 25, 33], # \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c          [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]] # id<\/code><\/pre>\n<p>\u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<pre><code class=\"python\">AntAlgorithm(COUNTANTS, COUNTITERATIONFORANTS, MAXWEIGHTKNAPSACK, items,  EVAPORATIONCOEFFICIENT).WolfWallStreet()<\/code><\/pre>\n<p>\u0421\u043e\u0432\u0435\u0442\u0443\u044e \u0432\u0441\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442.<\/p>\n<pre><code class=\"python\">MAXWEIGHTKNAPSACK = 30 COUNTANTS = 5000 COUNTITERATIONFORANTS = 30 EVAPORATIONCOEFFICIENT = 0.08 <\/code><\/pre>\n<p>\u041d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<pre><code class=\"python\">weight = 28 value = 71 [ 0 3 5 6 10 ]<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0431\u043e\u0439\u0446\u0443 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u0440\u0438\u043d\u0433\u0430 \u2014 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443.<\/p>\n<p>\u0414\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c 3 \u043a\u043b\u0430\u0441\u0441\u0430: EvolutionAlgorithm, Genotype, Gene. Gene \u044d\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u0438\u0435 Investment, \u043d\u043e \u0431\u0435\u0437 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430.<\/p>\n<pre><code class=\"python\">class Gene:     def __init__(self, id,  weight, value):         self._id = id         self._weight = weight         self._value = value<\/code><\/pre>\n<p>Genotype \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u044d\u0442\u0438\u0445 \u0433\u0435\u043d\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0441\u043e\u0431\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043f\u043e\u043c\u0438\u043c\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0433\u0435\u043d\u043e\u0432, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0432\u0435\u0441, \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u0435\u0441 \u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"python\">class Genotype:     def __init__(self, maxWeight):         self._genes = []         self._maxWeight = maxWeight         self._weight = 0         self._value = 0<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0438 \u0432\u044b\u0432\u043e\u0434.<\/p>\n<pre><code class=\"python\">def GenesToItems(self):     i = 0     items = []     while (len(self._genes) > i):         items.append(self._genes[i].id)         i += 1     return items  def ShowMeYourGenes(self):     genesId = '[ '     i = 0     while (len(self._genes) > i):         genesId = genesId + str(self._genes[i].id) + ' '         i += 1     genesId = genesId + ']'<\/code><\/pre>\n<p>\u0412 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0435 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0433\u0435\u043d\u043e\u043c, \u0430 \u0441 \u0446\u0435\u043b\u044b\u043c\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0430\u043c\u0438, \u0433\u0435\u043d\u043e\u0442\u0438\u043f\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0445\u043e\u0434\u0435 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0431\u043e\u0440\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u044d\u0442\u0430\u043f\u044b \u0441\u0435\u043b\u0435\u043a\u0446\u0438\u0438, \u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043c\u0443\u0442\u0430\u0446\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u0441\u043e\u0431\u0438 \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e. <\/p>\n<pre><code class=\"python\">def Born(self, genes):     minWeightGenes = genes[0].weight # Gene \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0435\u0441\u043e\u043c     minWeightIter = 0     geneAvailability = [1] * len(genes) # \u0421\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 Gene     probability = 1\/len(genes) # \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 Gene     while ((self._maxWeight - self._weight) >= minWeightGenes):         i = int(random.random()\/probability) # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 Gene         if ((geneAvailability[i] == 1) &amp; ((self._maxWeight - self._weight) >= genes[i].weight)): # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0433\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435             geneAvailability[i] = 0 # \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043b\u0438\u0441\u0442\u0435, \u0435\u0441\u043b\u0438 \u0433\u0435\u043d \u043d\u0430\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442             self._genes.append(genes[i]) # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0433\u0435\u043d\u043e\u0442\u0438\u043f \u0433\u0435\u043d             self._weight += genes[i].weight # \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0435\u0441\u0430             self._value += genes[i].value # \u0418 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438             if (i == minWeightIter): # \u0415\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u0433\u0435\u043d \u2013 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439                 geneAvailability[minWeightIter] = 0                 minWeightIter = next((j for j, x in enumerate(geneAvailability) if x), None)                 if(minWeightIter != None):                     minWeightGenes = genes[minWeightIter].weight                 else:                     break     return self<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443. \u041a\u043b\u0430\u0441\u0441 EvolutionAlgorithm \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u0435\u043b\u0435\u043a\u0446\u0438\u0438, \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0440\u0435\u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0438\u0438, \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043c\u0443\u0442\u0430\u0446\u0438\u0438, \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u044e\u043a\u0437\u0430\u043a\u0430.<\/p>\n<pre><code class=\"python\">class EvolutionAlgorithm:     def __init__(self, countFirstGeneration, countIteration, countSelection, countReproduction, countMutation, items, maxGenotypeWeight):         self._countFirstGeneration = countFirstGeneration         self._countIteration = countIteration         self._countSelection = countSelection         self._countReproduction = countReproduction         self._countMutation = countMutation         self._items = items         self._maxGenotypeWeight = maxGenotypeWeight         self._genes = []<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044e.<\/p>\n<pre><code class=\"python\">def TheEvolutionBegins(self):     self._genes = TransformationGenes(self._items)     population = []     while (len(population) &lt; self._countFirstGeneration):         population.append(Genotype(self._maxGenotypeWeight).Born(self._genes))<\/code><\/pre>\n<p>\u0421\u0435\u043b\u0435\u043a\u0446\u0438\u044f \u2014 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u043c\u0438\u0440\u0430\u043d\u0438\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439. \u041f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0438 \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e value. \u0427\u0435\u043c \u0432\u044b\u0448\u0435 value, \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a \u0441\u0435\u043b\u0435\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043c\u0443\u0442\u0430\u0446\u0438\u0435\u0439, \u043d\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0438\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445. \u0412 \u0441\u0435\u043b\u0435\u043a\u0446\u0438\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u0442\u0443\u0440\u043d\u0438\u0440\u043d\u043e\u0439 \u2014 \u0431\u0443\u0434\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0437 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0432\u0435 \u043e\u0441\u043e\u0431\u0438 \u0438 \u0438\u0437 \u043d\u0438\u0445 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u0443, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 value \u0432\u044b\u0448\u0435.<\/p>\n<pre><code>\u0421\u0435\u043b\u0435\u043a\u0446\u0438\u044f \u2014 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u043c\u0438\u0440\u0430\u043d\u0438\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439. \u041f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0438 \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e value. \u0427\u0435\u043c \u0432\u044b\u0448\u0435 value, \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a \u0441\u0435\u043b\u0435\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043c\u0443\u0442\u0430\u0446\u0438\u0435\u0439, \u043d\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0438\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445. \u0412 \u0441\u0435\u043b\u0435\u043a\u0446\u0438\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u0442\u0443\u0440\u043d\u0438\u0440\u043d\u043e\u0439 \u2014 \u0431\u0443\u0434\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0437 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0432\u0435 \u043e\u0441\u043e\u0431\u0438 \u0438 \u0438\u0437 \u043d\u0438\u0445 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u0443, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 value \u0432\u044b\u0448\u0435.<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0438\u0434 \u0441\u0435\u043b\u0435\u043a\u0446\u0438\u0438, \u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 EvolutionAlgorithm.<\/p>\n<pre><code class=\"python\">def TournamentSel(self, population, countAlive):     newPopulation = [] # \u041f\u0443\u0441\u0442\u043e\u0439 list \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438     genotypeAvailability = [1] * len(population) # \u0421\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438     probability = 1\/len(population) # \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u0441\u043e\u0431\u0438 \u0434\u043b\u044f \u043e\u0442\u0431\u043e\u0440\u0430     i = 0     while (i &lt; countAlive):         first = int(random.random() \/ probability) # \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430 \u043d\u0430 \u0432\u044b\u0436\u0438\u0432\u0430\u043d\u0438\u0435         second = int(random.random() \/ probability) ) # \u0418\u043d\u0434\u0435\u043a\u0441 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430 \u043d\u0430 \u0432\u044b\u0436\u0438\u0432\u0430\u043d\u0438\u0435         if ((first != second)&amp;(genotypeAvailability[first] == 1)&amp;(genotypeAvailability[second] == 1)):             if (population[first].value >= population[second].value):                 genotypeAvailability[first] = 0                 newPopulation.append(population[first])             if (population[first].value &lt; population[second].value):                 genotypeAvailability[second] = 0                 newPopulation.append(population[second])             i += 1     return newPopulation <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0435\u043b\u0435\u043a\u0446\u0438\u0438 \u0438\u0434\u0451\u0442 \u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435. <\/p>\n<pre><code class=\"python\">parentAvailability = [1] * len(population) ) # \u0421\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438 countChildren = int(self._countReproduction * len(population) \/ 2) # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u043e\u0432\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0445\u043e\u0434\u0435 \u0440\u0435\u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0438\u0438 population = EvolutionAlgorithm.PanmixiaRep(self, population, parentAvailability, countChildren)<\/code><\/pre>\n<p>\u0411\u0435\u0440\u0443\u0442\u0441\u044f 2 \u043e\u0441\u043e\u0431\u0438 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u043d\u043e\u0432\u0443\u044e \u043e\u0441\u043e\u0431\u044c \u0432 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0433\u0435\u043d\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0431\u043e\u0440\u044b \u00ab\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439\u00bb. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043a\u0430\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439, \u0442\u0430\u043a \u0438 \u0438\u0445 \u0433\u0435\u043d\u044b, \u043d\u043e \u043c\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u2014 \u043f\u0430\u043d\u043c\u0438\u043a\u0441\u0438\u0438 (\u0432\u044b\u0431\u043e\u0440 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u0435\u043d).<\/p>\n<pre><code class=\"python\">def PanmixiaRep(self, population, parentAvailability, countChildren):     i = 0     parentProbability = [] # \u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u0441\u043e\u0431\u0438 \u0434\u043b\u044f \u0441\u043f\u0430\u0440\u0438\u0432\u0430\u043d\u0438\u044f     probability = 1 \/ len(population) # \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c     for i in parentProbability:         i = probability * (i + 1) # \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439      while (i &lt; countChildren):         firstParent = int(random.random()\/probability) # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e         if ((parentAvailability[firstParent] == 1)):             secondParent = int(random.random() \/ probability) # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439             if((firstParent != secondParent)): # \u041e\u0431\u0430 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442                  j = 0                 parentsGenes = [] # \u041d\u0430\u0431\u043e\u0440 \u0433\u0435\u043d\u043e\u0432 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u00ab\u0440\u0435\u0431\u0451\u043d\u043a\u0430\u00bb                 while (j &lt; len(population[firstParent].genes)):                     parentsGenes.append(population[firstParent].genes[j])                     j += 1 # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0433\u0435\u043d\u044b \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f                 j = 0                 while (j &lt; len(population[secondParent].genes)):                     parentsGenes.append(population[secondParent].genes[j])                     j += 1 # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0433\u0435\u043d\u044b \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f                 parentsGenes = list(set(parentsGenes)) # \u0423\u0431\u0438\u0440\u0430\u0435\u043c \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b \u0433\u0435\u043d\u043e\u0432                 parentsGenes = SortingGenes(parentsGenes) # \u0421\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0433\u0435\u043d\u044b population.append(Genotype(self._maxGenotypeWeight).Born(parentsGenes)) # \u00ab\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u043c\u00bb \u043d\u043e\u0432\u0443\u044e \u043e\u0441\u043e\u0431\u044c                 i += 1     return population<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0433\u0435\u043d\u043e\u0432.<\/p>\n<pre><code class=\"python\">def SortingGenes(genes):     i = 0     j = 1     while i &lt; (len(genes)-1):         mini = i         while j &lt; (len(genes)):             if genes[j].weight &lt; genes[mini].weight:                 mini = j             j+=1         if mini != i:             a = genes[i]             genes[i] = genes[mini]             genes[mini] = a         i+=1         j = i+1         #print(items)     return genes<\/code><\/pre>\n<p>\u0418 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043c\u0443\u0442\u0430\u0446\u0438\u044e \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c. \u041c\u0443\u0442\u0430\u0446\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0435 \u0441\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u043a \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u043e\u0432\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439.   <\/p>\n<pre><code class=\"python\">countMutant = int(self._countMutation * len(population)) # \u041d\u043e\u0432\u044b\u0435 \u043e\u0441\u043e\u0431\u0438 population = EvolutionAlgorithm.RandomMut(self, population, countMutant)<\/code><\/pre>\n<pre><code class=\"python\">def RandomMut(self, population, countMutant):     i = 0     while (i &lt; countMutant):         population.append(Genotype(self._maxGenotypeWeight).Born(self._genes))         i += 1     return population<\/code><\/pre>\n<p>\u0418 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0442\u0430\u043a\u0438\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b, \u0447\u0442\u043e \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u043e\u0441\u043e\u0431\u044c, \u043d\u043e \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0432\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">while (j &lt; len(population)):     Genotype.ShowMeYourGenes(population[j])     j += 1 result = [population[0].weight, population[0].value, population[0].GenesToItems()] return result<\/code><\/pre>\n<p>\u0418 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435.<\/p>\n<pre><code class=\"python\">MAXWEIGHTKNAPSACK = 30 COUNTFIRSTGENERATION = 100000 COUNTITERATIONFOREVOLUTION = 100 COUNTSELECTION = 0.52 COUNTREPRODUCTION = 0.9 COUNTMUTATION = 0.1<\/code><\/pre>\n<pre><code class=\"python\">items_result.append(EvolutionAlgorithm(COUNTFIRSTGENERATION, COUNTITERATIONFOREVOLUTION, COUNTSELECTION, COUNTREPRODUCTION, COUNTMUTATION, items, MAXWEIGHTKNAPSACK).TheEvolutionBegins())<\/code><\/pre>\n<p>\u041d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442! \u041d\u043e \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (50, 100, 500) \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0443\u0436\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043b\u0443\u0447\u0448\u0435 \u0443 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0445\u043e\u0442\u044f \u0432 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u043d\u0430 \u043d\u0430\u0431\u043e\u0440\u0435 \u0432 50 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u043d\u0430\u0448\u0451\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e 1 \u0438\u0437 25 (\u0443 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u043e\u0433\u043e 25\/25).<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\n<\/td>\n<td colspan=\"2\">\n<p align=\"left\">\u042d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">\n<\/td>\n<td colspan=\"2\">\n<p align=\"left\">\u041c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<td>\n<p align=\"left\">30<\/p>\n<\/td>\n<td>\n<p align=\"left\">323<\/p>\n<\/td>\n<td>\n<p align=\"left\">[42, 35, 45, 21, 38, 22, 27, 40, 3, 39]<\/p>\n<\/td>\n<td>\n<p align=\"left\">30<\/p>\n<\/td>\n<td>\n<p align=\"left\">323<\/p>\n<\/td>\n<td>\n<p align=\"left\">[35, 40, 22, 45, 3, 38, 21, 27, 39, 42]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">100<\/p>\n<\/td>\n<td>\n<p align=\"left\">30<\/p>\n<\/td>\n<td>\n<p align=\"left\">451<\/p>\n<\/td>\n<td>\n<p align=\"left\">[47, 20, 52, 65, 98, 37, 43, 60, 49, 38,   5, 89, 57, 63, 14]<\/p>\n<\/td>\n<td>\n<p align=\"left\">30<\/p>\n<\/td>\n<td>\n<p align=\"left\">454<\/p>\n<\/td>\n<td>\n<p align=\"left\">[60, 98, 57, 47, 52, 43, 80, 63, 37, 89,   14, 5, 49]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">500<\/p>\n<\/td>\n<td>\n<p align=\"left\">30<\/p>\n<\/td>\n<td>\n<p align=\"left\">837<\/p>\n<\/td>\n<td>\n<p align=\"left\">[291, 435, 63, 402, 2, 465, 389, 136,   214, 263, 292, 423, 350, 355, 35, 332, 304, 266, 177, 60, 158, 91, 315, 47,   431, 450]<\/p>\n<\/td>\n<td>\n<p align=\"left\">30<\/p>\n<\/td>\n<td>\n<p align=\"left\">658<\/p>\n<\/td>\n<td>\n<p align=\"left\">[150, 435, 263, 286, 350, 47, 469, 357,   266, 465, 304, 133, 423, 450, 136, 214, 355, 454, 60, 35]<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0421 \u0440\u043e\u0441\u0442\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0440\u044e\u043a\u0437\u0430\u043a\u0430, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432, \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e) \u0440\u0430\u0431\u043e\u0442\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442\u0441\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e. \u0422\u0430\u043a \u0434\u043b\u044f 50000 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430 \u043e\u0431\u043e\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0430 1,5 \u0447\u0430\u0441\u043e\u0432. \u0421\u0442\u0440\u0430\u0448\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u0440\u0435\u0430\u043b\u0438\u044f\u0445 \u0436\u0438\u0437\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442 \u0437\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d. \u0422\u0430\u043a\u0436\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u0431\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0442 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u044e\u0442\u0441\u044f \u043a \u043d\u0435\u043c\u0443.<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0435\u0440\u0435\u0432\u0435\u0441 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043c\u0435\u043d\u044f &#8212; \u0430\u0432\u0442\u043e\u0440\u0430 \u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 &#8212; \u043a\u0430\u043a\u043e\u0439 \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043b\u0443\u0447\u0448\u0435 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443, \u0442\u043e \u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u043d \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0439 \u0438 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u0451\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0441\u0432\u043e\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0418 \u0432\u0441\u0435 \u0436\u0435 \u043e\u0431\u0435 \u043e\u0441\u043d\u043e\u0432\u043e\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0438\u0435 \u0438\u0434\u0435\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0431\u0443\u0434\u043e\u0440\u0430\u0436\u0430\u0442 \u043c\u043e\u0435 \u0441\u043e\u0437\u043d\u0430\u043d\u0438\u0435 \u0435\u0449\u0451 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432 \u0438\u043d\u0441\u0442\u0438\u0442\u0443\u0442\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u0439\u0442\u0435\u0441\u044c: \u043d\u0430\u0448\u0430 \u043f\u0440\u0438\u0440\u043e\u0434\u0430 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u0435\u043b\u044c\u043d\u0430 \u0432 \u043c\u043d\u043e\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0438 \u0441\u0432\u043e\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0433\u0440\u0443\u0431\u044b\u0435 \u0438 \u0442\u043e\u0447\u043d\u044b\u0435 \u0432 \u0441\u0432\u043e\u0451\u043c \u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0443 \u0442\u0430\u043a\u043e\u0439, \u0445\u0430\u043e\u0442\u0438\u0447\u043d\u043e\u0439 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u0438\u0440\u043e\u0437\u0434\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043b\u043e\u0436\u0435\u043d \u043d\u0430 GitHub \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p><a href=\"https:\/\/github.com\/IlyaBlIcGoryanskiy\/EvolutionVsAnts\" rel=\"noopener noreferrer nofollow\"><u>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431<\/u><\/a>.<\/p>\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\/659741\/\"> https:\/\/habr.com\/ru\/post\/659741\/<\/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_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043e \u0440\u0430\u043d\u0446\u0435. \u041c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u043b\u0438 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043b\u0443\u0447\u0448\u0435? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<figure class=\"full-width\"><figcaption>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 ruDALL-E XL<\/figcaption><\/figure>\n<p>\u00a0\u041c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u043e\u0431\u0449\u0435\u043f\u0440\u0438\u0437\u043d\u0430\u043d\u043d\u044b\u0445 \u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u043b\u0438\u0434\u0435\u0440\u043e\u0432 \u043f\u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 (\u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438). \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435, \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u2014 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439. \u041a\u0430\u043a\u043e\u0439 \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c \u0438\u0445 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u043c\u0435\u043d\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u2014 \u0437\u0430\u0434\u0430\u0447\u0435 \u043e \u0440\u0430\u043d\u0446\u0435.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043e \u0440\u0430\u043d\u0446\u0435 \u0438\u043b\u0438 knapsack problem \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0442\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u0438 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445. \u0421\u043b\u043e\u0436\u043d\u043e? \u041f\u0440\u043e\u0449\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445.<\/p>\n<p>\u041f\u0440\u0438\u0445\u043e\u0434\u044f \u0432 \u0441\u0443\u043f\u0435\u0440\u043c\u0430\u0440\u043a\u0435\u0442 \u043c\u044b \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0435\u0448\u0430\u0435\u043c: \u00ab\u0427\u0435\u0433\u043e \u0431\u044b \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u0443\u043f\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0446\u0435\u043b\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u043d\u0435 \u043a\u0430\u0442\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0433\u043e\u0440\u043e\u0434\u0430 \u0440\u0430\u0434\u0438 \u0448\u043e\u043f\u0438\u043d\u0433\u0430, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043c \u0432\u0441\u0435\u0439 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u044b?\u00bb \u0418\u043b\u0438, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0443\u0434\u0430\u0447\u043d\u043e \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u043a\u0440\u043e\u0432\u043d\u043e \u043d\u0430\u0436\u0438\u0442\u044b\u0435. \u0417\u0430\u0445\u043e\u0434\u0438\u0442\u0435 \u0432 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0431\u0430\u043d\u043a\u0430, \u0438 \u0433\u043b\u0430\u0437\u0430 \u0440\u0430\u0437\u0431\u0435\u0433\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0435\u043d\u044c\u0433\u0438. \u0410 \u043d\u0430\u0448\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043a \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u043c\u0443 \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043d\u0435 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b. \u0412\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0445\u043e\u0434\u0438\u0442\u0435 \u0437\u0430 \u043f\u043e\u043a\u0443\u043f\u043a\u0430\u043c\u0438 \u0438\u043b\u0438 \u0440\u0435\u0448\u0430\u0435\u0442\u0435, \u043a\u0443\u0434\u0430 \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0435\u043d\u044c\u0433\u0438? \u041d\u0435\u0442, \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0422\u043e \u0435\u0441\u0442\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0442\u0430\u043a \u2013 \u043e\u0431\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442\u0435 \u0441\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440. \u041d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u0432\u044b \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 knapsack problem.<\/p>\n<p>\u041f\u043e\u0434\u044b\u0442\u043e\u0436\u0438\u043c: \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u0432\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u2014 \u0432\u0435\u0441 \u0438 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c. \u0420\u0430\u043d\u0435\u0446, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b, \u0438\u043c\u0435\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0435\u0441\u0443. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u044e\u043a\u0437\u0430\u043a\u0435.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u043d\u043e \u043e\u0442 \u0442\u043e\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u2014 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439 \u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u043e\u043d\u0438\u0438 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u043f\u0440\u0438 \u0434\u043e\u0431\u044b\u0447\u0435 \u0438\u043c\u0438 \u043f\u0438\u0449\u0438. \u0412 \u043f\u0430\u0440\u0435 \u0441\u043b\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0434\u0435\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0442\u0430\u043a: \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043f\u0438\u0449\u0438 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u0441\u043b\u0435\u0434 \u0438\u0437 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043f\u0443\u0442\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u043e\u0432, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u0438. \u0421\u0440\u0430\u0437\u0443 \u0436\u0435 \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043e\u043f\u0435\u0440\u0435\u0436\u0430\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u0430\u043a\u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u043f\u043e\u0434 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432, \u0445\u043e\u0442\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430\u043c \u043d\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u0432 \u0440\u0430\u043d\u0435\u0446 &#8212; \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u043c\u043a\u0430 \u0432\u044b\u0434\u0435\u0440\u0436\u0430\u043b\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u0443\u0440\u0430\u0432\u044c\u044f, \u043a\u0430\u043a \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0430\u043d\u043a\u0430, \u0442\u0430\u043a\u043e\u0433\u043e \u00ab\u0438\u043d\u0432\u0435\u0441\u0442\u043e\u0440\u0430\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442, \u0432\u043e \u0447\u0442\u043e \u0435\u043c\u0443 \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0435\u043d\u044c\u0433\u0438.<\/p>\n<p>\u042d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0438\u043b\u0438 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u0432\u044f\u0437\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0431\u043e\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u044b\u0435 \u043e\u0441\u043e\u0431\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0436\u0438\u0442\u044c \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u043e\u0442\u043e\u043c\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u044b\u043c, \u0447\u0435\u043c \u0438\u0445 \u043f\u0440\u0435\u0434\u043a\u0438.<\/p>\n<p>\u0425\u0432\u0430\u0442\u0438\u0442 \u0441 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c \u0432 \u0442\u0435\u043e\u0440\u0438\u044e \u2014 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043a\u043e\u0434\u0443!<\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u041e\u041e\u041f. \u0412 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u043b\u0430\u0441\u0441\u044b Investment, Ant \u0438 AntAlgorithm. Investment \u2014 \u044d\u0442\u043e \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430 \u0438\u0437 \u0440\u0430\u043d\u0446\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0438 (\u0438\u043b\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442 \u043c\u0443\u0440\u0430\u0432\u0435\u0439), \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u043d\u0430\u0448\u0435\u0439 \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0438 (\u0432\u0435\u0441 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430), \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430 \u0438 id.<\/p>\n<pre><code class=\"python\">class Investment:     def __init__(self, id, cost, profit):         self._id = id         self._cost = cost         self._profit = profit         self._pheromone = 1.0<\/code><\/pre>\n<p>Ant \u2014 \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043c\u0443\u0440\u0430\u0432\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043d\u0438\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u043b\u043e\u0436\u0438\u0442\u044c (\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u044e\u043a\u0437\u0430\u043a\u0430), \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043d\u0435\u0433 \u043e\u043d \u0443\u0436\u0435 \u0432\u043b\u043e\u0436\u0438\u043b, \u0441\u0432\u043e\u0439 \u0434\u043e\u0445\u043e\u0434 (\u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0445 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u043c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432) \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u043d\u0430\u0431\u043e\u0440 \u044d\u0442\u0438\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 (\u0438\u043b\u0438 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0439).<\/p>\n<pre><code class=\"python\">\u043cclass Ant:     def __init__(self, max_cost):         self._max_cost = max_cost         self._cost = 0         self._profit = 0         self._portfolio = []<\/code><\/pre>\n<p>\u0418 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 AntAlgorithm.<\/p>\n<pre><code class=\"python\">class AntAlgorithm:     def __init__(self, count_ants, count_iteration, max_ant_cost, items, evaporation_coefficient):         self._count_ants = count_ants         self._count_iteration = count_iteration         self._max_ant_cost = max_ant_cost         self._items = items         self._evaporation_coefficient = evaporation_coefficient<\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u044e\u043a\u0437\u0430\u043a\u0430 (\u043e\u043d\u0430 \u0436\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0439 \u043c\u0443\u0440\u0430\u0432\u044c\u044f), \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 (\u0432\u0435\u0441\u0430, \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 id \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445) \u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0438\u0441\u043f\u0430\u0440\u0435\u043d\u0438\u044f.<\/p>\n<p>\u00ab\u041f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u0447\u0442\u043e \u0437\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0438\u0441\u043f\u0430\u0440\u0435\u043d\u0438\u044f?\u00bb &#8212; \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b. \u0421\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c \u0434\u043e \u0435\u0434\u044b, \u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0441\u0432\u043e\u0439 \u0444\u0435\u0440\u043e\u043c\u043e\u043d \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438. \u041e\u0442 \u044d\u0442\u043e\u0433\u043e \u0435\u0433\u043e \u043d\u0430\u0441\u044b\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u0436\u0435, \u0447\u0435\u043c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c \u043f\u0443\u0442\u0438 \u0434\u043e \u00ab\u0431\u043b\u044e\u0434\u0430\u00bb, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0443\u0442\u044c. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0444\u0435\u0440\u043e\u043c\u043e\u043d \u043d\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0434\u043e\u0440\u043e\u0433\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u0430\u0440\u044f\u0435\u0442\u0441\u044f. \u0418 \u0438\u0441\u043f\u0430\u0440\u044f\u0435\u0442\u0441\u044f \u043e\u043d \u0442\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u043f\u0443\u0442\u044c. \u0422\u0430\u043a \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u0441\u043f\u0430\u0440\u0435\u043d\u0438\u044e, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0443\u0442\u044f\u0445. <\/p>\n<p>\u041d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c! \u041c\u044b \u0443\u0436\u0435 \u043d\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0438, \u0438\u0449\u0443\u0449\u0438\u0435 \u0434\u043e\u0440\u043e\u0433\u0443 \u0434\u043e \u043f\u0438\u0449\u0438, \u043c\u044b \u043c\u0443\u0440\u0430\u0432\u044c\u0438-\u0438\u043d\u0432\u0435\u0441\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435, \u0430 \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435! \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u043c\u0435\u0442, \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0438\u0436\u0435, \u043d\u043e \u0435\u0449\u0451 \u0438 \u0434\u043e\u0445\u043e\u0434 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0448\u0435, \u0442.\u0435. \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043a \u0432\u0435\u0441\u0443 \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u0438 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u00ab\u0432\u043a\u043b\u0430\u0434\u044b\u00bb, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0444\u0435\u0440\u043e\u043c\u043e\u043d \u043d\u0430 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0442\u0430\u043a \u0432\u043e\u0442 \u0438 \u0432\u0441\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u0441 \u0441\u0430\u043c\u044b\u043c \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043e\u0445\u043e\u0434\u0430 \u043a \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u044e\u043a\u0437\u0430\u043a\u0430. \u0411\u0438\u043d\u0433\u043e! \u041d\u043e \u043d\u0435 \u0432\u0441\u0451 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u0427\u0430\u0441\u0442\u043e \u0432 \u0445\u043e\u0434\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u044b \u2014 \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445, \u043d\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u0442\u0430\u043a\u0438\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u044b, \u043b\u0438\u0431\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043c\u0443\u0440\u0430\u0432\u044c\u0438\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0432\u043e\u0434\u044f\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u00ab\u044d\u043b\u0438\u0442\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432\u00bb \u2014 \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u043f\u0443\u0442\u0451\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u0441\u0432\u043e\u0439 \u0441\u0447\u0451\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u043e\u0432 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0443\u0442\u044f\u0445. \u0422\u0430\u043a\u0438\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c, \u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u044b.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u041d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0451 WolfWallStreet<\/p>\n<pre><code class=\"python\">def WolfWallStreet (self):<\/code><\/pre>\n<p>\u0412 \u043d\u0451\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0432\u043a\u043b\u0430\u0434\u043e\u0432.<\/p>\n<pre><code class=\"python\">inventory = [] i = 0 while (i &lt; len(self._items[0])):     inventory.append(Investment(self._items[2][i], self._items[0][i], self._items[1][i]))     i += 1<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u00ab\u044d\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u044f\u00bb \u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0446\u0438\u043a\u043b \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<pre><code class=\"python\">i = 0 best_ant = Ant(self._max_ant_cost) while (self._count_iteration > i):<\/code><\/pre>\n<p>\u0412\u0432\u0435\u0434\u0451\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e sum \u0434\u043b\u044f \u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0441\u0443\u043c\u043c\u044b <\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u00a0\u0438\u0437 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0451. \u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432.<\/p>\n<pre><code class=\"python\">sum = 0 j = 0 while (j &lt; len(inventory)):     sum += (inventory[j].pheromone ** P) * ((inventory[j].profit \/ inventory[j].cost) ** Q)     j += 1<\/code><\/pre>\n<p>\u0418 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"python\">j = 1 investment_probability = [] investment_probability.append((inventory[0].pheromone ** P) * ((inventory[0].profit \/ inventory[0].cost) ** Q) \/ sum) while (j &lt; len(inventory)):     investment_probability.append(         investment_probability[j - 1] + ((inventory[j].pheromone ** P) * (((inventory[j].profit \/ inventory[j].cost) ** Q) \/ sum)))     j += 1 <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0430\u0434 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0432\u044b\u0431\u0440\u0430\u043b \u0441\u0432\u043e\u0438 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Ant \u00ab\u0441\u043e\u0431\u0435\u0440\u0451\u043c \u0435\u0433\u043e \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c\u00bb.<\/p>\n<pre><code class=\"python\">def BuildPortfolio(self, investment_probability, inventory):     min_cost_investment = inventory[0].cost # \u0412\u043a\u043b\u0430\u0434 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043e\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e     min_cost_iter = 0 # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u043a\u043b\u0430\u0434\u0430 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043e\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e     investment_availability = [1] * len(inventory) # \u0421\u043f\u0438\u0441\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0432\u043a\u043b\u0430\u0434\u0430     while ((self._max_cost - self._cost) >= min_cost _investment):         rand = random.random()# \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e          k = 0         while (k &lt; (len(inventory))):             if ((investment_probability[k] >= rand) &amp; ((investment_availability[k] == 0) | ((self._max_cost - self._cost) &lt; inventory[k].cost))):                 break # \u0415\u0441\u043b\u0438 \u0432\u043a\u043b\u0430\u0434 \u043c\u044b \u0443\u0436\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u044f             if ((investment_probability[k] >= rand) &amp; (investment_availability[k] == 1) &amp; ((self._max_cost - self._cost) >= inventory[k].cost)): # \u041d\u0430\u0448\u043b\u0438 \u0431\u043b\u044e\u0434\u043e                 investment_availability[k] = 0 # \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u043a\u043b\u0430\u0434\u0430                 self._portfolio.append(inventory[k]) # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u00ab\u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c\u00bb                 self._cost += inventory[k].cost # \u041f\u043e\u0432\u044b\u0448\u0430\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438                 self._profit += inventory[k].profit # \u0418 \u0434\u043e\u0445\u043e\u0434\u0430                 if (k == min_cost _iter): # \u0415\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u043a\u043b\u0430\u0434 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0432\u043a\u043b\u0430\u0434\u043e\u043c \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u2014 \u0438\u0449\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432\u043a\u043b\u0430\u0434                     investment_availability[min_cost_iter] = 0                     min_cost_iter = next((j for j, x in enumerate(investment_availability) if x), None)                     if (min_cost_iter != None):                         min_cost_investment = inventory[min_cost_iter].cost                     else:                         break                 break             k += 1     return self<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0438 \u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0438\u043d\u0432\u0435\u0441\u0442\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u0438, \u043f\u043e\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u0438\u044e \u043d\u0430 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441 AntAlgorithm \u0438 \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044e \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432; \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0443\u0440\u0430\u0432\u044c\u0451\u0432 \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u044d\u043b\u0438\u0442\u043d\u043e\u0433\u043e.<\/p>\n<pre><code class=\"python\">j = 0 ant_population = [] while (self._count_ants > j):     ant_population.append(Ant(self._max_ant_cost).BuildPortfolio(investment_probability, inventory))   <\/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-331687","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331687","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=331687"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331687\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}