{"id":379773,"date":"2024-06-25T03:48:52","date_gmt":"2024-06-25T03:48:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=379773"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=379773","title":{"rendered":"<span>\u0423\u0447\u0438\u043c\u0441\u044f \u043b\u0435\u0442\u0430\u0442\u044c: \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438 \u043d\u0430 Rust. 3\/5<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ok\/13\/y9\/ok13y9vlz-qasq8lvjgusd0lpyk.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ok\/13\/y9\/ok13y9vlz-qasq8lvjgusd0lpyk.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>\u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438<\/strong> \u0438 <strong>\u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/strong>.<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/817585\/\">\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/818985\/\">\u0412\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u0443\u044e FFNN (feedforward neural network \u2014 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0438 \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0433 \u043d\u0430 \u043f\u0443\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0437\u0433\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435. \u041f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445, \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0430\u0441\u044c \u043b\u0443\u0447\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043c\u043e\u0437\u0433 \u043d\u0430\u0447\u0430\u043b \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u044f \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c <strong>\u043e\u0431\u0443\u0447\u0438\u0442\u044c<\/strong> \u0433\u0440\u0443\u043f\u043f\u0443 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u0437\u0430\u043f\u044f\u0442\u043e\u0439, \u0435\u0441\u043b\u0438 \u0443\u0433\u043e\u0434\u043d\u043e)?<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"proekt\">\u041f\u0440\u043e\u0435\u043a\u0442<\/h2>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0435\u0433\u043e \u043d\u0430 Rust. \u041c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Selection_(genetic_algorithm)\">\u0441\u0435\u043b\u0435\u043a\u0446\u0438\u044f<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Crossover_(genetic_algorithm)\">\u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435<\/a> \u0438 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mutation_(genetic_algorithm)\">\u043c\u0443\u0442\u0430\u0446\u0438\u044f<\/a> \u0432\u043c\u0435\u0441\u0442\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0438\u0437 \u0432\u043e\u0437\u0434\u0443\u0445\u0430.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u043d\u0435 \u0436\u0435\u0441\u0442\u043a\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u043b\u0438 \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u044f, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0430\u0436\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043d\u0430 crates.io!<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 Rust, \u0443\u0434\u0435\u043b\u044f\u044f \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a \u043a\u043e\u043d\u0446\u0443 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u044f \u043c\u043e\u0433\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e!<\/p>\n<p>  <\/p>\n<h2 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0438 \u0432 \u0447\u0435\u043c \u0441\u043c\u044b\u0441\u043b \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0442\u0435\u0438.<\/p>\n<p>  <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u2014 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0418\u0445 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0441\u0435\u0442\u0435\u0439 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0438\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0437\u0430 \u0432\u0441\u044e \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c.<\/p>\n<p>  <\/p>\n<blockquote><p>\u0412\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <strong>\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0430 (search space)<\/strong>; \u044d\u0440\u0443\u0434\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u043b \u0431\u044b, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043e\u0433\u0440\u043e\u043c\u043d\u043e, \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0431\u0435\u0436\u0430\u043b \u0431\u044b.<\/p><\/blockquote>\n<p>\u0427\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u0430\u0436\u0430\u0442\u044c \u043f\u0440\u0438\u0440\u043e\u0434\u0435: \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0438\u0445, \u0447\u0442\u043e\u0431\u044b \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u044d\u0442\u0443 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0443, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <strong>\u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/strong> \u2014 \u043e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432-\u0440\u0435\u0448\u0435\u043d\u0438\u0439 (<strong>\u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438<\/strong>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0442\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>\u043c\u0443\u0442\u0430\u0446\u0438\u0439<\/strong> \u0438 <strong>\u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0439<\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/strong> \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 (\u043e\u0441\u043e\u0431\u0435\u0439):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/p4\/h7\/-8\/p4h7-8brdivdg45dg0yh9teah0c.png\" data-src=\"https:\/\/habrastorage.org\/webt\/p4\/h7\/-8\/p4h7-8brdivdg45dg0yh9teah0c.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0437\u043e\u0440 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430; \u0441\u0432\u0435\u0440\u0445\u0443 \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0435\u043b\u043a\u0435: 1) \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438, 2) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u043c\u0443\u0442\u0430\u0446\u0438\u044e, 3) \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u043d\u043e\u0432\u043e\u0439 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0435\u0439.<\/em><\/p>\n<p>  <\/p>\n<blockquote><p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Randomized_algorithm\">\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430<\/a>.<\/p>\n<p>  \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0436\u0435\u0440\u0442\u0432\u0443\u044e\u0442 <strong>\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e<\/strong> \u0440\u0430\u0434\u0438 <strong>\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/strong> \u2014 \u043e\u043d\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043b\u0443\u0447\u0448\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u044b, \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u0430\u044e\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0435\u0448\u0435\u0432\u043e.<\/p><\/blockquote>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0438 \u043e\u0432\u043e\u0449\u0435\u0439 \u043d\u0435 \u0445\u043e\u0442\u044f\u0442, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0437\u043d\u0430\u043b\u0438 \u043e\u0431 \u044d\u0442\u043e\u043c, \u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c \u043c\u043e\u0440\u043a\u043e\u0432\u043d\u044b\u043c \u043c\u0430\u0433\u043d\u0430\u0442\u043e\u043c, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">10  \u0438\u0434\u0435\u043c \u0432 \u0441\u0430\u0434 20  \u0441\u0435\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0440\u043a\u043e\u0432\u043e\u043a 30  \u0436\u0434\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0432\u044b\u0440\u0430\u0441\u0442\u0443\u0442 40  \u0431\u0435\u0440\u0435\u043c \u0441\u0435\u043c\u0435\u043d\u0430 \u043b\u0443\u0447\u0448\u0438\u0445 \u043c\u043e\u0440\u043a\u043e\u0432\u043e\u043a \u0438 \u0441\u0435\u0435\u043c \u0438\u0445 50  \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a 30  \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435: - \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044f = \u043c\u043e\u0440\u043a\u043e\u0432\u043a\u0438 - \u043e\u0441\u043e\u0431\u044c = \u043c\u043e\u0440\u043a\u043e\u0432\u043a\u0430 - \u043c\u0443\u0442\u0430\u0446\u0438\u044f &amp; \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435 = \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 (\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0442\u0440\u0443\u0434!) - \u0444\u0438\u0442\u043d\u0435\u0441-\u0444\u0443\u043d\u043a\u0446\u0438\u044f = \u0432\u0430\u0448\u0438 \u0433\u043b\u0430\u0437\u0430 &amp; \u043c\u043e\u0437\u0433<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u044d\u0442\u0438\u0445 \u0441\u043b\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u2014 \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u044b \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041a \u043a\u043e\u043d\u0446\u0443 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0442\u0430\u043a\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043a\u0430\u043a:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041a\u0430\u043a \u043c\u044b <strong>\u043e\u0442\u0431\u0438\u0440\u0430\u0435\u043c<\/strong> \u043e\u0441\u043e\u0431\u0435\u0439? \u0414\u043e\u043b\u0436\u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u044b\u0441\u044f\u0447\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e! (\u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0434\u0430)<\/li>\n<li>\u041a\u0430\u043a \u043c\u044b <strong>\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c<\/strong> \u0438\u0445 \u0433\u0435\u043d\u043e\u043c\u044b? \u0414\u043e\u043b\u0436\u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u044b\u0441\u044f\u0447\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e! (\u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0434\u0430)<\/li>\n<li>\u041a\u0430\u043a <strong>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c<\/strong> \u044d\u0442\u043e \u043d\u0430 Rust? \u0422\u044b \u043e\u0431\u0435\u0449\u0430\u043b, \u0447\u0442\u043e \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435! (\u0431\u0443\u0434\u0435\u0442)<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"razrabotka-shema\">\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430: \u0441\u0445\u0435\u043c\u0430<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u0440\u0435\u0439\u0442\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">cd shorelark\/libs cargo new genetic-algorithm --name lib-genetic-algorithm --lib<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c <code>lib.rs<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct GeneticAlgorithm;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0448 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u2014 \u0438\u043d\u043e\u0433\u0434\u0430 \u0435\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <code>iterate<\/code>, \u0438\u043d\u043e\u0433\u0434\u0430 \u2014 <code>step<\/code> \u0438\u043b\u0438 <code>process<\/code>. \u042f \u0440\u0435\u0448\u0438\u043b \u0431\u044b\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl GeneticAlgorithm {     pub fn evolve(&amp;self) {         todo!()     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u043c\u044b \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u043c? \u041f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e!<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl GeneticAlgorithm {     pub fn evolve(&amp;self, population: &amp;[???]) -> Vec&lt;???> {         todo!()     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438, \u043d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u044b\u043b\u0430 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code>NeuralNetwork<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u2014 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c <strong>\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl GeneticAlgorithm {     pub fn evolve&lt;I>(&amp;self, population: &amp;[I]) -> Vec&lt;I> {         todo!()     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p><code>I<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u044c (individual):<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c  \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438   _ \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \/\/ |          _|     ____|  (\u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \"\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b\") \/\/ |         |      | \/\/ v-v       v-----vv----------v    pub fn foo&lt;'a, T>(bar: &amp;'a T) { \/* ... *\/ } \/\/            ^^  ^  ^--------^ \/\/            |   |  | \/\/            |   |  \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \/\/            |   |  (\u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \"\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\") \/\/            |   \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 \/\/            \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u042d\u0442\u043e \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>  &#171;\u041e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>foo<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <strong>\u043e\u0431\u0449\u0435\u0439<\/strong> \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 <code>a<\/code> \u0438 \u0442\u0438\u043f\u0443 <code>T<\/code>, \u0438 <strong>\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442<\/strong> \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>bar<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 <code>T<\/code>&#171;.<\/p>\n<p>  \u042d\u0442\u043e <strong>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412 <strong>\u043c\u0435\u0441\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u0430<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <strong>\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438<\/strong>:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ v-----------------------v \u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430    foo::&lt;'static, f32>(&amp;1.0); \/\/       ^-----^  ^-^  ^--^ \/\/       |        |    | \/\/       |        |    \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \/\/       |        |    (\u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \"\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\") \/\/       |        \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430 \/\/       \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl GeneticAlgorithm {     pub fn evolve&lt;I>(&amp;self, population: &amp;[I]) -> Vec&lt;I> {         assert!(!population.is_empty());          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl GeneticAlgorithm {     pub fn evolve&lt;I>(&amp;self, population: &amp;[I]) -> Vec&lt;I> {         \/* ... *\/          (0..population.len())             .map(|_| {                 \/\/ TODO \u043e\u0442\u0431\u043e\u0440                 \/\/ TODO \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435                 \/\/ TODO \u043c\u0443\u0442\u0430\u0446\u0438\u044f                 todo!()             })             .collect()     } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"razrabotka-otbor\">\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430: \u043e\u0442\u0431\u043e\u0440<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0446\u0438\u043a\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0432\u0443\u0445 \u043e\u0441\u043e\u0431\u0435\u0439 \u2014 \u043e\u043d\u0438 \u0441\u0442\u0430\u043d\u0443\u0442 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 &#171;\u0441\u043e\u0437\u0434\u0430\u0434\u0443\u0442&#187; \u0434\u043b\u044f \u043d\u0430\u0441 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0435 \u043f\u043e\u0442\u043e\u043c\u0441\u0442\u0432\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0431\u043e\u0440 \u043e\u0441\u043e\u0431\u0435\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Selection_(genetic_algorithm)\">\u044d\u0442\u0430\u043f\u043e\u043c \u043e\u0442\u0431\u043e\u0440\u0430<\/a> \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0434\u0432\u0443\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u0430\u0436\u0434\u0430\u044f \u043e\u0441\u043e\u0431\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043c\u0435\u0442\u044c <strong>\u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439<\/strong> \u0448\u0430\u043d\u0441 \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439<\/li>\n<li>\u043e\u0441\u043e\u0431\u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f <strong>\u0447\u0430\u0449\u0435<\/strong>, \u0447\u0435\u043c \u043e\u0441\u043e\u0431\u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c, \u043a\u0430\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0441\u0432\u043e\u044e \u0444\u0438\u0442\u043d\u0435\u0441-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u2014 \u043a\u0430\u043a \u0431\u044b \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043d\u0438 \u0437\u0432\u0443\u0447\u0430\u043b\u043e, \u0437\u0434\u0435\u0441\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u0432\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0424\u0438\u0442\u043d\u0435\u0441-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u0441\u043e\u0431\u0438:<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"rust\">impl GeneticAlgorithm {     pub fn evolve&lt;I>(         &amp;self,         population: &amp;[I],         evaluate_fitness: &amp;dyn Fn(&amp;I) -> f32,     ) -> Vec&lt;I> {         \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043e\u0441\u043e\u0431\u0438:<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait Individual {     fn fitness(&amp;self) -> f32; }  impl GeneticAlgorithm {     pub fn evolve&lt;I>(&amp;self, population: &amp;[I]) -> Vec&lt;I>     where         I: Individual,     {         \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u2705 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0438\u0442\u043d\u0435\u0441-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043e\u0441\u043e\u0431\u0435\u0439, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f (\u043d\u043e \u043d\u0435 \u043d\u0430\u043c)<\/li>\n<li>\u274c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0444\u0438\u0442\u043d\u0435\u0441-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>.evolve()<\/code>, \u0447\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u2705 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 <strong>\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/strong> \u0432\u0441\u0435 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0432 \u043e\u0434\u0438\u043d \u0442\u0438\u043f\u0430\u0436, \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c<\/li>\n<li>\u274c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0438\u0442\u043d\u0435\u0441-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041c\u043e\u044f \u0438\u043d\u0442\u0443\u0438\u0446\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u0443\u0435\u0442 213:7 \u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430\u0436\u0430 (\u043e\u043d \u043d\u0430\u043c \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u043a\u0430\u043a \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u043e\u0437\u0436\u0435).<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0442\u0431\u043e\u0440\u0430, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.tutorialspoint.com\/genetic_algorithms\/genetic_algorithms_parent_selection.htm\">\u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0442\u0431\u043e\u0440\u043e\u043c \u043f\u043e \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 (fitness proportionate selection)<\/a> (\u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043a\u0430\u043a <strong>\u0432\u044b\u0431\u043e\u0440 \u043a\u043e\u043b\u0435\u0441\u0430 \u0440\u0443\u043b\u0435\u0442\u043a\u0438 (roulette wheel selection)<\/strong>), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043e\u0431\u0438:<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u041e\u0441\u043e\u0431\u044c<\/th>\n<th>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/th>\n<th>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432 %<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A<\/td>\n<td>3<\/td>\n<td><code>3 \/ (1 + 2 + 3) = 3 \/ 6 = 50%<\/code><\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>2<\/td>\n<td><code>2 \/ (1 + 2 + 3) = 2 \/ 6 = 33%<\/code><\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>1<\/td>\n<td><code>1 \/ (1 + 2 + 3) = 1 \/ 6 = 16%<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0438\u0445 \u043d\u0430 \u043a\u043e\u043b\u0435\u0441\u043e \u0440\u0443\u043b\u0435\u0442\u043a\u0438 (\u0438\u043b\u0438, \u0435\u0441\u043b\u0438 \u0443\u0433\u043e\u0434\u043d\u043e, \u043d\u0430 \u043a\u0440\u0443\u0433\u043e\u0432\u0443\u044e \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443), \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u0430\u044f \u043e\u0441\u043e\u0431\u044c \u0437\u0430\u0439\u043c\u0435\u0442 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043b\u0435\u0441\u0430, \u0440\u0430\u0432\u043d\u0443\u044e \u0434\u043e\u043b\u0435 \u0435\u0433\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043a\u043e \u0432\u0441\u0435\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/4n\/ll\/91\/4nll91zbgcmibfkfj_qzyhcezui.png\" data-src=\"https:\/\/habrastorage.org\/webt\/4n\/ll\/91\/4nll91zbgcmibfkfj_qzyhcezui.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u2026 \u0442\u043e\u0433\u0434\u0430 \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0441\u043e\u0431\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a &#171;\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044e&#187; \u043a\u043e\u043b\u0435\u0441\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u043b\u043e\u0439 \u0438 \u043e\u0446\u0435\u043d\u043a\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/pc\/fc\/t7\/pcfct7evtiri2p02jzwxplcelhs.png\" data-src=\"https:\/\/habrastorage.org\/webt\/pc\/fc\/t7\/pcfct7evtiri2p02jzwxplcelhs.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<blockquote><p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043e\u0442\u0431\u043e\u0440, \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0441\u043a\u043e\u0440\u0435\u0435, \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0441\u043e\u0431\u044f\u043c <strong>\u0434\u043e\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/strong> \u0432 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043d\u0430\u0448 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445:<\/p><\/blockquote>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ib\/qv\/ff\/ibqvfft0emrgebszhuwq1ltsjgo.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ib\/qv\/ff\/ibqvfft0emrgebszhuwq1ltsjgo.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<blockquote><p>\u2026 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0431\u043e\u0440, \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0441 \u0440\u0430\u0434\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u0435\u043b\u0435\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 99% \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439 \u0432 \u0430\u0440\u043c\u0438\u044e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0437\u0435\u043b\u0435\u043d\u044b\u0445 \u043a\u043b\u043e\u043d\u043e\u0432.<\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c:<\/p>\n<p>  &#171;\u041d\u043e \u0440\u0430\u0437\u0432\u0435 \u043d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043d\u0435 \u0432 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f?&#187;<\/p>\n<p>  \u0414\u0430, \u043d\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0432\u0441\u0435\u0433\u0434\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u043c\u0438 <strong>\u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c<\/strong>: \u0435\u0441\u043b\u0438 \u043c\u044b \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043c, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0431\u0435\u0441\u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0440\u0430\u043d\u043e, \u0442\u043e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0443\u0437\u043d\u0430\u0435\u043c, \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0435\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u043b\u0443\u0447\u0448\u0435\u0433\u043e (\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0435 \u0437\u0430 \u0442\u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u044e) \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0434\u043e\u043b\u0433\u043e\u0441\u0440\u043e\u0447\u043d\u043e\u0439 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0435.<\/p>\n<p>  \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0443 \u043d\u0430\u0441 <strong>\u0440\u0430\u0437\u043d\u044b\u0445<\/strong> \u043e\u0441\u043e\u0431\u0435\u0439, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0448\u0430\u043d\u0441\u043e\u0432, \u0447\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0438\u0445 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0443\u043d\u0434\u0435\u0440\u043a\u0438\u043d\u0434\u043e\u043c \u043f\u043e \u0438\u0433\u0440\u0435 \u043d\u0430 \u0442\u0440\u043e\u043c\u0431\u043e\u043d\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440 \u043a\u043e\u043b\u0435\u0441\u0430 \u0440\u0443\u043b\u0435\u0442\u043a\u0438, \u043d\u043e \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e <strong>\u0432\u044b\u0431\u043e\u0440 \u0440\u0430\u043d\u0433\u0430 (rank selection)<\/strong> \u2014 \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u043c\u0438\u043d\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0448\u0438\u0445 \u043e\u0441\u043e\u0431\u0435\u0439 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u043f\u0442\u0438\u0447\u043a\u0430\u043c\u0438!<\/p><\/blockquote>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0436\u0435\u0441\u0442\u043a\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043a\u043e\u043b\u0435\u0441\u0430 \u0440\u0443\u043b\u0435\u0442\u043a\u0438, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0438\u043f\u0430\u0436. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait SelectionMethod {     fn select(&amp;self); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 \u043e\u0442\u0431\u043e\u0440\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait SelectionMethod {     fn select&lt;I>(&amp;self, population: &amp;[I]) -> &amp;I     where         I: Individual; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0438, \u0434\u043b\u044f \u044f\u0441\u043d\u043e\u0441\u0442\u0438, \u0443\u043a\u0430\u0436\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait SelectionMethod {     fn select&lt;'a, I>(&amp;self, population: &amp;'a [I]) -> &amp;'a I     where         I: Individual; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0442\u0430\u043a \u0447\u0442\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># ...  [dependencies] rand = \"0.8\"  [dev-dependencies] rand_chacha = \"0.3\"<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u0440\u0435\u0439\u0442 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u0435\u0442 <strong>\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439<\/strong> \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>rand<\/code>, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432 <code>libs\/neural-network\/Cargo.toml<\/code>, \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u0440\u0435\u0439\u0442\u0430\u043c \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430.<\/p><\/blockquote>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0413\u041f\u0421\u0427 (\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b) \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use rand::RngCore;  \/* ... *\/  pub trait SelectionMethod {     fn select&lt;'a, I>(&amp;self, rng: &amp;mut dyn RngCore, population: &amp;'a [I]) -> &amp;'a I     where         I: Individual; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a\u0430\u044f \u0447\u0443\u0434\u0435\u0441\u043d\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438?<\/p>\n<p>  <\/p>\n<blockquote><p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0439\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c <code>select()<\/code> \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0413\u041f\u0421\u0427?<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait SelectionMethod {     fn select&lt;'a, R, I>(        &amp;self,        rng: &amp;mut R,        population: &amp;'a [I],     ) -> &amp;'a I     where         R: RngCore,         I: Individual; }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438:  <\/p>\n<ol>\n<li><code>dyn Trait<\/code>, <code>&amp;dyn Trait<\/code> \u0438 <code>&amp;mut dyn Trait<\/code> \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e\u0442 <strong>\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e (dynamic dispatch)<\/strong>.<\/li>\n<li><code>T<\/code>, <code>&amp;T<\/code> \u0438 <code>&amp;mut T<\/code> \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e\u0442 <strong>\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e (static dispatch)<\/strong>.<\/li>\n<\/ol>\n<p>  \u0414\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 &#171;\u043a\u0443\u0434\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0439\u0442\u0438?&#187; \u0434\u043b\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">fn foo() {    bar();    \/\/ ^ \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 `bar` }  fn bar() {    println!(\"yas queen\"); }  fn method(obj: &amp;dyn SomeTrait) {     obj.method();     \/\/ ^ \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443     \/\/   \u043a\u0430\u0436\u0434\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f `SomeTrait` \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442     \/\/   \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e `fn method(&amp;self) { ... }` }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f\u0430\u0436 \u0441 \u0434\u0432\u0443\u043c\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">trait Animal {     fn kind(&amp;self) -> &amp;'static str; }  \/\/ --  struct Chinchilla;  impl Animal for Chinchilla {     fn kind(&amp;self) -> &amp;'static str {         \"chinchilla\"     } }  \/\/ --  struct Viscacha;  impl Animal for Viscacha {     fn kind(&amp;self) -> &amp;'static str {         \"viscacha\"     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0432\u0438\u0434 \u043b\u044e\u0431\u043e\u0433\u043e \u0436\u0438\u0432\u043e\u0442\u043d\u043e\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c): fn print_kind_static&lt;A>(animal: &amp;A) where     A: Animal, {     println!(\"{}\", animal.kind()); }  \/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c, \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f): fn print_kind_dynamic(animal: &amp;dyn Animal) {     println!(\"{}\", animal.kind()); }  fn main() {     print_kind_static(&amp;Chinchilla);     print_kind_static(&amp;Viscacha);      print_kind_dynamic(&amp;Chinchilla);     print_kind_dynamic(&amp;Viscacha); }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u043e\u0445\u043e\u0436\u0435 \u2014 \u0432 \u0447\u0435\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430?<\/p>\n<p>  <code>print_kind_static()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0435\u0445\u043d\u0438\u043a\u0443, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e <strong>\u043c\u043e\u043d\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u0430\u0446\u0438\u0435\u0439 (monomorphization)<\/strong>, \u2014 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0436\u0438\u0432\u043e\u0442\u043d\u043e\u0433\u043e, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e &#171;\u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e&#187; \u0432\u0435\u0440\u0441\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">fn print_kind_static__chinchilla(animal: &amp;Chinchilla) {     println!(\"{}\", Chinchilla::kind(animal)); }  fn print_kind_static__viscacha(animal: &amp;Viscacha) {     println!(\"{}\", Viscacha::kind(animal)); }  fn main() {     print_kind_static__chinchilla(&amp;Chinchilla);     print_kind_static__viscacha(&amp;Viscacha); }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u2014 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u0430\u0436\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438.<\/p>\n<p>  \u0423 \u043c\u043e\u043d\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u043e\u043d\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f (\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0434\u043d\u043e\u0439), \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u043d\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043e\u0431\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0441\u043a\u0430\u0436\u0435\u043c, \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<p>  <code>print_kind_dynamic()<\/code>, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0435\u0445\u043d\u0438\u043a\u0443 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <strong>vtable (virtual table \u2014 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430)<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ (\u044d\u0442\u043e \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438)  struct AnimalVtable {     \/\/ \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e `kind()`     kind: fn(*const ()) -> &amp;'static str, }  const CHINCHILLA_VTABLE: AnimalVtable = AnimalVtable {     kind: Chinchilla::kind, };  const VISCACHA_VTABLE: AnimalVtable = AnimalVtable {     kind: Viscacha::kind, };  fn print_kind_dynamic(     animal_obj: *const (),     animal_vtable: &amp;AnimalVtable, ) {     println!(\"{}\", animal_vtable.kind(animal_obj)); }  fn main() {     print_kind_dynamic(&amp;Chinchilla, &amp;CHINCHILLA_VTABLE);     print_kind_dynamic(&amp;Viscacha, &amp;VISCACHA_VTABLE); }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0447\u0435\u0440\u0435\u0437 <code>AnimalVtable<\/code>, <code>print_kind_dynamic()<\/code> \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043c\u043e\u043d\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u2014 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>print_kind_dynamic()<\/code> \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u0443 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e &#171;\u043f\u0440\u043e\u043a\u0441\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443&#187;, \u0447\u0442\u043e \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0435 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0439, \u0447\u0435\u043c <code>print_kind_static()<\/code>, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430.<\/p>\n<p>  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0443: \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c <code>where R: RngCore<\/code>?<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0438\u0433\u0440\u0430 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0441\u0432\u0435\u0447.<\/p><\/blockquote>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct RouletteWheelSelection;  impl SelectionMethod for RouletteWheelSelection {     fn select&lt;'a, I>(&amp;self, rng: &amp;mut dyn RngCore, population: &amp;'a [I]) -> &amp;'a I     where         I: Individual,     {         todo!()     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl SelectionMethod for RouletteWheelSelection {     fn select&lt;'a, I>(&amp;self, rng: &amp;mut dyn RngCore, population: &amp;'a [I]) -> &amp;'a I     where         I: Individual,     {         let total_fitness: f32 = population             .iter()             .map(|individual| individual.fitness())             .sum();          \/\/ \u042d\u0442\u043e \u043d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f \u0446\u0435\u043b\u0435\u0439 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 - \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f         \/\/ \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c `rng` \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437         loop {             let indiv = population                 .choose(rng)                 .expect(\"\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u043f\u0443\u0441\u0442\u0430\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044f\");              let indiv_share = indiv.fitness() \/ total_fitness;              if rng.gen_bool(indiv_share as f64) {                 return indiv;             }         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u043d\u043e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0431\u0443\u0434\u0435\u0442\u2026 \u0435\u0433\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435!<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0438\u0441\u0442\u0430\u0442\u044c <a href=\"https:\/\/docs.rs\/rand\/0.8.3\/rand\/\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e rand<\/a>, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0438\u043f\u0430\u0436 <a href=\"https:\/\/docs.rs\/rand\/0.8.3\/rand\/seq\/trait.SliceRandom.html\">SliceRandom<\/a>. \u0415\u0441\u043b\u0438 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 \u043d\u0435\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/docs.rs\/rand\/0.8.3\/rand\/seq\/trait.SliceRandom.html#tymethod.choose_weighted\">choose_weighted<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use rand::seq::SliceRandom; use rand::{Rng, RngCore};  \/* ... *\/  impl SelectionMethod for RouletteWheelSelection {     fn select&lt;'a, I>(&amp;self, rng: &amp;mut dyn RngCore, population: &amp;'a [I]) -> &amp;'a I     where         I: Individual,     {         population             .choose_weighted(rng, |individual| individual.fitness())             .expect(\"\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u043f\u0443\u0441\u0442\u0430\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044f\")     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0434\u043e\u0432\u0435\u0440\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c <code>rand<\/code>, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e <code>select_weighted()<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e? \u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u0435\u0433\u043e!<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     use super::*;      #[test]     fn roulette_wheel_selection() {         todo!();     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0443\u0442\u044c \u043a TDD-\u043d\u0438\u0440\u0432\u0430\u043d\u0435 (test driven development \u2014 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435) \u0443\u0441\u044b\u043f\u0430\u043d \u0440\u043e\u0437\u0430\u043c\u0438, \u0438 \u043c\u044b \u0432\u043e\u0442-\u0432\u043e\u0442 \u0432\u043a\u0443\u0441\u0438\u043c \u0438\u0445 \u0448\u0438\u043f\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     use super::*;     use rand::SeedableRng;     use rand_chacha::ChaCha8Rng;      #[test]     fn roulette_wheel_selection() {         let mut rng = ChaCha8Rng::from_seed(Default::default());          let population = vec![ \/* \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c? *\/ ];         let actual = RouletteWheelSelection::new().select(&amp;mut rng, &amp;population);          assert!(\/* \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c? *\/);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>Individual<\/code> \u2014 \u044d\u0442\u043e \u0442\u0438\u043f\u0430\u0436, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u0441\u044b\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0446\u0435\u043b\u0435\u0439 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f?<\/li>\n<li>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>select()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0441\u043e\u0431\u044c, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0435\u0435 <a href=\"https:\/\/xkcd.com\/221\/\">\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/a>?<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043d\u0430\u0447\u0430\u043b\u0430: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0446\u0435\u043b\u0435\u0439 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>\u043c\u0430\u043a\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c (mocking)<\/strong> \u2014 \u0438 \u0445\u043e\u0442\u044f \u0434\u043b\u044f Rust \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0435\u0442\u043e\u0432, \u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u044b\u043b \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u043e\u043c \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0435\u0435 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u0440\u0435\u0439\u0442\u043e\u0432, \u2014 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[derive(Clone, Debug)]     struct TestIndividual {         fitness: f32,     }      impl TestIndividual {         fn new(fitness: f32) -> Self {             Self { fitness }         }     }      impl Individual for TestIndividual {         fn fitness(&amp;self) -> f32 {             self.fitness         }     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0437\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn roulette_wheel_selection() {         \/* ... *\/          let population = vec![             TestIndividual::new(2.0),             TestIndividual::new(1.0),             TestIndividual::new(4.0),             TestIndividual::new(3.0),         ];          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f? \u0422\u0430\u043a\u043e\u0439 \u0442\u0435\u0441\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn roulette_wheel_selection() {         \/* ... *\/          let actual = RouletteWheelSelection::new()             .select(&amp;mut rng, &amp;population);          assert!(actual, &amp;population[2]);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u043d\u0435 \u0432\u043d\u0443\u0448\u0430\u0435\u0442 \u0434\u043e\u0432\u0435\u0440\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435 <strong>\u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442<\/strong>, \u0447\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u0421\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0442\u0430\u043a\u0430\u044f \u043a\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl SelectionMethod for RouletteWheelSelection {     fn select&lt;'a, I>(\/* ... *\/) -> &amp;'a I     where         I: Individual,     {         &amp;population[2]     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0442\u0430\u043a\u043e\u0439 \u0442\u0435\u0441\u0442!<\/p>\n<p>  <\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0432\u044b\u0445\u043e\u0434 \u0435\u0441\u0442\u044c \u2014 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0446\u0435\u043d\u0438\u0442\u044c <strong>\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c<\/strong>, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>select()<\/code> \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/4c\/bp\/wk\/4cbpwks5ivdj2mknqw1rt5436r0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/4c\/bp\/wk\/4cbpwks5ivdj2mknqw1rt5436r0.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><em>\u041e\u0441\u044c <code>X<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043e\u0441\u044c <code>Y<\/code> \u2014 \u0447\u0430\u0441\u0442\u043e\u0442\u0443.<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/     use std::collections::BTreeMap;     use std::iter::FromIterator;      #[test]     fn roulette_wheel_selection() {         let mut rng = ChaCha8Rng::from_seed(Default::default());          let population = vec![             \/* ... *\/         ];          let mut actual_histogram = BTreeMap::new();          \/\/          \/--| \u0426\u0438\u0444\u0440\u0430 1000 \u0432\u0437\u044f\u0442\u0430 \u0441 \u043f\u043e\u0442\u043e\u043b\u043a\u0430;         \/\/          v  | \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, 50 \u0442\u043e\u0436\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442         for _ in 0..1000 {             let fitness = RouletteWheelSelection                 .select(&amp;mut rng, &amp;population)                 .fitness() as i32;              *actual_histogram                 .entry(fitness)                 .or_insert(0) += 1;         }          let expected_histogram = BTreeMap::from_iter([             \/\/ (\u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u044d\u0442\u0430 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430)             (1, 0),             (2, 0),             (3, 0),             (4, 0),         ]);          assert_eq!(actual_histogram, expected_histogram);     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 <code>f32<\/code> \u0434\u043e <code>i32<\/code>:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">let fitness = RouletteWheelSelection     .select(&amp;mut rng, &amp;population)     .fitness() as i32;<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432 Rust \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0442\u0438\u043f\u0430\u0436 <a href=\"https:\/\/doc.rust-lang.org\/std\/cmp\/trait.Ord.html\">Ord<\/a>, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 <code>BTreeMap<\/code>:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::collections::BTreeMap;  fn main() {     let mut map = BTreeMap::new();     map.insert(1.0, \"one point zero\"); }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">error[E0277]: the trait bound `{float}: Ord` is not satisfied   |   |     map.insert(1.0, \"one point zero\");   |         ^^^^^^ the trait `Ord` is not implemented for `{float}`<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u043a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c <a href=\"https:\/\/floating-point-gui.de\/\">IEEE 754<\/a>, \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Total_order\">\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c<\/a>, \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/NaN#Comparison_with_NaN\">NaN<\/a> \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">NaN != NaN<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c <code>NaN<\/code> \u0432 \u043a\u0430\u0440\u0442\u0443, \u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u043d\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 <code>BTreeMap<\/code>, \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0432 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. _\u041a\u0441\u0442\u0430\u0442\u0438, \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u0435\u0440\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 <code>Ord<\/code> \u0438 <code>PartialOrd<\/code> \u2014 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Asymmetry#In_mathematics\">\u0430\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0438<\/a> \u0438 <a href=\"https:\/\/simple.wikipedia.org\/wiki\/Transitivity_(mathematics)\">\u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438<\/a>, \u0432\u044b \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0436\u0430\u043b\u0435\u0435\u0442\u0435._<\/p><\/blockquote>\n<p><code>cargo test<\/code> (\u0438\u043b\u0438 <code>cargo test --workspace<\/code>, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0435\u0441\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430) \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">thread '...' panicked at 'assertion failed: `(left == right)`   left: `{1: 98, 2: 202, 3: 278, 4: 422}`,  right: `{1: 0, 2: 0, 3: 0, 4: 0}`'<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f, \u0447\u0442\u043e <code>choose_weighted()<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f (\u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0447\u0430\u0449\u0435), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u0441\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn roulette_wheel_selection() {         \/* ... *\/          let expected_histogram = BTreeMap::from_iter(vec![             \/\/ (\u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u044d\u0442\u0430 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430)             (1, 98),             (2, 202),             (3, 278),             (4, 422),         ]);          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0443\u0430\u043b\u044f \u2014 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u043d\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u043e\u0435! \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0432 \u043e\u0442\u0431\u043e\u0440, \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u043d\u0430 \u0447\u0435\u043c \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl GeneticAlgorithm {     pub fn evolve&lt;I>(&amp;self, population: &amp;[I]) -> Vec&lt;I>     where         I: Individual,     {         \/* ... *\/          (0..population.len())             .map(|_| {                 \/\/ TODO \u043e\u0442\u0431\u043e\u0440                 \/\/ TODO \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435                 \/\/ TODO \u043c\u0443\u0442\u0430\u0446\u0438\u044f                 todo!()             })             .collect()     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u0443\u0434\u0430 <code>SelectionMethod<\/code> \u2014 \u044f \u0432\u0438\u0436\u0443 \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"rust\">impl GeneticAlgorithm {     pub fn evolve&lt;I, S>(         &amp;self,         population: &amp;[I],         selection_method: &amp;S,     ) -> Vec&lt;I>     where         I: Individual,         S: SelectionMethod,     {         \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430:<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct GeneticAlgorithm&lt;S> {     selection_method: S, }  impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     pub fn new(selection_method: S) -> Self {         Self { selection_method }     }      pub fn evolve&lt;I, S>(&amp;self, population: &amp;[I]) -> Vec&lt;I>     where         I: Individual,     {         \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044f\u0441\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0434\u0438\u043b\u0435\u043c\u043c\u0430\u043c\u0438, \u044f \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044e\u0441\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 <code>evolve()<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0442\u0431\u043e\u0440\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0439 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u0447\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u0431\u043e\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     \/* ... *\/      pub fn evolve&lt;I>(&amp;self, population: &amp;[I]) -> Vec&lt;I>     where         I: Individual,     {         \/* ... *\/          (0..population.len())             .map(|_| {                 let parent_a = self.selection_method.select(rng, population);                 let parent_b = self.selection_method.select(rng, population);                  \/\/ TODO \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435                 \/\/ TODO \u043c\u0443\u0442\u0430\u0446\u0438\u044f                 todo!()             })             .collect()     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u044d\u0442\u043e \u0413\u041f\u0421\u0427:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     \/* ... *\/      pub fn evolve&lt;I>(&amp;self, rng: &amp;mut dyn RngCore, population: &amp;[I]) -> Vec&lt;I>     where         I: Individual,     {         \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0412\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c <code>rng<\/code> \u0447\u0435\u0440\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0432\u0435\u0434\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438!<\/p>\n<p>  \u041d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430:  <\/p>\n<ol>\n<li>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c <strong>\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439<\/strong> \u0413\u041f\u0421\u0427 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/li>\n<\/ol>\n<p>  <\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct GeneticAlgorithm&lt;R> {     rng: R, }  impl&lt;R> GeneticAlgorithm&lt;R> where     R: RngCore, {     pub fn new(rng: R) -> Self {         Self { rng }     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote>\n<ol>\n<li>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c <strong>\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0439<\/strong> \u0413\u041f\u0421\u0427 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/li>\n<\/ol>\n<p>  <\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct GeneticAlgorithm&lt;'r> {     rng: &amp;'r mut dyn RngCore, }  impl&lt;'r> GeneticAlgorithm&lt;'r> {     pub fn new(rng: &amp;'r mut dyn RngCore) -> Self {         Self { rng }     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f \u0431\u044b \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u0432 C# \u0438\u043b\u0438 Java, \u043d\u043e \u043d\u0435 \u0432 Rust, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c <code>rng<\/code> \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0442\u043e \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let rng = \/* ... *\/;     let ga = GeneticAlgorithm::new(rng);      \/\/ \u041e \u043d\u0435\u0442, \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 `rng`!     if rng.gen_bool() {         \/* ... *\/     } else {         \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 <code>SelectionMethod<\/code>:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let sp = RouletteWheelSelection::new();     let ga = GeneticAlgorithm::new(sp);      \/\/ \u041e \u043d\u0435\u0442, \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 `sp`!     if sp.something() {         \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u2026 \u043d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>Rng<\/code> \u2014 \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f\u0430\u0436, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0435 <code>GeneticAlgorithm<\/code>, \u0447\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e <code>SelectionMethod<\/code>.<\/p>\n<p>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 <code>&amp;mut dyn RngCore<\/code>, \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0435\u0433\u043e \u0445\u0443\u0434\u0448\u0438\u043c \u2014 \u043e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f (<code>&amp;mut<\/code>) <code>rng<\/code>, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e &#171;\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442&#187; \u0413\u041f\u0421\u0427 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let rng = \/* ... *\/;     let ga = GeneticAlgorithm::new(&amp;mut rng);      \/\/ \u041e \u043d\u0435\u0442, \u043c\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 `rng`!     let population = if rng.gen_bool() {         \/* ... *\/     } else {         \/* ... *\/     };      ga.evolve(population); }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u2026 \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043b\u043e\u043c\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Simulation {     rng: ChaCha8Rng,     ga: GeneticAlgoritm&lt;'whats_this_lifetime??>, }  impl Simulation {     pub fn new_chacha() -> Self {         let rng = ChaCha8Rng::from_seed(Default::default());         let ga = GeneticAlgorithm::new(&amp;mut rng);          Self { rng, ga } \/\/ \u0443\u043f\u0441     } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"razrabotka-skreschivanie\">\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430: \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0434\u0432\u0443\u0445 \u043e\u0441\u043e\u0431\u0435\u0439-\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439, \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f <strong>\u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u044f<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435 (\u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u043a\u0430\u043a <strong>\u0440\u0435\u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f<\/strong>) \u0431\u0435\u0440\u0435\u0442 \u0434\u0432\u0443\u0445 \u043e\u0441\u043e\u0431\u0435\u0439 \u0438 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0435\u0442 \u0438\u0445, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043d\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/y9\/iw\/8p\/y9iw8p7klu9gapijpbdh83kdufm.png\" data-src=\"https:\/\/habrastorage.org\/webt\/y9\/iw\/8p\/y9iw8p7klu9gapijpbdh83kdufm.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439, \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f <strong>\u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u044f<\/strong>. \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u043e\u0441\u043e\u0431\u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043e\u0441\u043e\u0431\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u043e\u0439 \u0438, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u0435\u0439, \u043a\u0430\u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u0441\u043e\u0431\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u0435\u0437 \u0440\u0438\u0441\u043a\u0430 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435, \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435 \u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439, \u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432 \u0438\u0445 <strong>\u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0430\u0445<\/strong> \u2014 \u043c\u043e\u0434\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 &#171;\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f&#187;:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/hp\/re\/g_\/hpreg_rizu9cjn3opglo0c7_xnu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/hp\/re\/g_\/hpreg_rizu9cjn3opglo0c7_xnu.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0425\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0430 (\u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f <strong>\u0433\u0435\u043d\u043e\u0442\u0438\u043f\u043e\u043c<\/strong>, \u0445\u043e\u0442\u044f \u044f \u0443\u0431\u0435\u0436\u0434\u0435\u043d, \u0447\u0442\u043e \u0431\u0438\u043e\u043b\u043e\u0433\u0430\u043c \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u044e\u0442\u0441\u044f) \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 <strong>\u0433\u0435\u043d\u043e\u0432<\/strong>, \u0438 \u0435\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0435\u0448\u0430\u0435\u043c\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0443 \u0443\u0434\u043e\u0431\u043d\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/l2\/nk\/wo\/l2nkwotft_yh_zulvaz1bdm9rfi.png\" data-src=\"https:\/\/habrastorage.org\/webt\/l2\/nk\/wo\/l2nkwotft_yh_zulvaz1bdm9rfi.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u2026 \u0438\u043d\u043e\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/l9\/k2\/lt\/l9k2ltr0nr07kbii_sw9dy3jj2c.png\" data-src=\"https:\/\/habrastorage.org\/webt\/l9\/k2\/lt\/l9k2ltr0nr07kbii_sw9dy3jj2c.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u2026 \u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u2014 \u043d\u0430\u0431\u043e\u0440\u043e\u043c <code>f32<\/code>, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u043c \u0432\u0435\u0441\u0430 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/z9\/wa\/_c\/z9wa_c2kabqo6tlkpvyoiyyhn_w.png\" data-src=\"https:\/\/habrastorage.org\/webt\/z9\/wa\/_c\/z9wa_c2kabqo6tlkpvyoiyyhn_w.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Clone, Debug)] pub struct Chromosome {     genes: Vec&lt;f32>, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0433\u0435\u043d\u044b \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 (\u0447\u0435\u0440\u0435\u0437 <code>pub genes<\/code>\u200b), \u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u044b \u2014 \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0435\u0439<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl Chromosome {     pub fn len(&amp;self) -> usize {         self.genes.len()     }      pub fn iter(&amp;self) -> impl Iterator&lt;Item = &amp;f32> {         self.genes.iter()     }      pub fn iter_mut(&amp;mut self) -> impl Iterator&lt;Item = &amp;mut f32> {         self.genes.iter_mut()     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u0441\u043b\u0443\u0447\u0430\u0435\u043c, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0442\u0438\u043f\u0430\u0436\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0422\u0438\u043f\u0430\u0436 <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/ops\/trait.Index.html\">Index<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 <code>[]<\/code> \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0442\u0438\u043f\u043e\u0432:<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::ops::Index;  \/* ... *\/  \/\/ --- \/\/ | \u042d\u0442\u043e \u0442\u0438\u043f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a, \/\/ | \/\/ | \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c `Index&lt;&amp;str>`, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c: \/\/ |   chromosome[\"yass\"] \/\/ ------- v---v impl Index&lt;usize> for Chromosome {     type Output = f32;      fn index(&amp;self, index: usize) -> &amp;Self::Output {         &amp;self.genes[index]     } }<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u0422\u0438\u043f\u0430\u0436 <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/iter\/trait.FromIterator.html\">FromIterator<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>.collect()<\/code> \u0432 \u043d\u0430\u0448\u0438\u0445 \u0442\u0438\u043f\u0430\u0445:<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ --- \/\/ | \u042d\u0442\u043e \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \/\/ | \u0441 \u043d\u0430\u0448\u0435\u0439 \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u043e\u0439 \/\/ | \/\/ | (\u0438\u043d\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 *\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442* (yields)) \/\/ | \/\/ | \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u0448\u0430 \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0437\u0434\u0435\u0441\u044c \/\/ | \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \/\/ -------------- v-v impl FromIterator&lt;f32> for Chromosome {     fn from_iter&lt;T: IntoIterator&lt;Item = f32>>(iter: T) -> Self {         Self {             genes: iter.into_iter().collect(),         }     } }<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0442\u0438\u043f\u0430\u0436 <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/iter\/trait.IntoIterator.html\">IntoIterator<\/a> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u2014 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0438\u043f \u0432 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440:<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"rust\">impl IntoIterator for Chromosome {     type Item = f32;     type IntoIter = std::vec::IntoIter&lt;f32>;      fn into_iter(self) -> Self::IntoIter {         self.genes.into_iter()     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u0435\u043d <code>std::vec::IntoIter&lt;f32><\/code>?<\/p>\n<p>  \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0438\u043f, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0442\u0438\u043f\u0430\u0436 <code>Iterator<\/code>:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Fibonacci {     prev: u32,     curr: u32, }  impl Default for Fibonacci {     fn default() -> Self {         Self { prev: 0, curr: 1 }     } }  impl Iterator for Fibonacci {     type Item = u32;      fn next(&amp;mut self) -> Option&lt;u32> {         let next = self.prev + self.curr;          self.prev = self.curr;         self.curr = next;          Some(self.prev)     } }  fn main() {     for number in Fibonacci::default().take(10) {         println!(\"{}\", number);     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0432 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0442\u0438\u043f. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>Chromosome<\/code> \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0430 \u0434\u043b\u044f <code>Vec<\/code>, \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0442\u0438\u043f \u2014 <code>std::vec::IntoIter<\/code>, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Chromosome {     genes: Vec&lt;f32>, }  impl IntoIterator for Chromosome {     type Item = f32;     type IntoIter = (); \/\/ \u043c\u044b \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f      fn into_iter(self) -> Self::IntoIter {         self.genes.into_iter()     } }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">error[E0308]: mismatched types    |    | \/* ... *\/    |    = note: expected unit type `()`                  found struct `std::vec::IntoIter&lt;f32>`<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u044d\u0442\u043e\u0442 \u0442\u0438\u043f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u043d\u0435\u043c \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>.filter()<\/code> \u0438\u043b\u0438 <code>.map()<\/code>:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Somethinger {     values: Vec&lt;f32>, }  impl IntoIterator for Somethinger {     type Item = f32;     type IntoIter = ();      fn into_iter(self) -> Self::IntoIter {         self.values             .into_iter()             .filter(|value| *value > 0.0)             .map(|value| value * 10.0)     } }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">error[E0308]: mismatched types    |    | \/* ... *\/    |    = note: expected unit type `()`                  found struct `Map&lt;Filter&lt;std::vec::IntoIter&lt;f32>, {closure}>, {closure}>`<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041d\u043e\u0447\u043d\u043e\u0439 Rust \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u2014 <code>impl_trait_in_assoc_type<\/code>:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">#![feature(impl_trait_in_assoc_type)]  struct Somethinger {     values: Vec&lt;f32>, }  impl IntoIterator for Somethinger {     type Item = f32;     type IntoIter = impl Iterator&lt;Item = f32>;      fn into_iter(self) -> Self::IntoIter {         self.values             .into_iter()             .filter(|value| *value > 0.0)             .map(|value| value * 10.0)     } }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u2026 \u0447\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442: &#171;\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0432\u044b\u0432\u0435\u0434\u0438 \u0442\u0438\u043f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430&#187;.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u043e, \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0430\u043c \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p><\/blockquote>\n<p>\u041a\u0430\u043a \u044f \u0441\u043a\u0430\u0437\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442 \u043d\u0430\u0437\u0430\u0434, \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435 \u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u0439, \u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432 \u0438\u0445 \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0430\u0445, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0441 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     \/* ... *\/      pub fn evolve&lt;I>(\/* ... *\/) -> Vec&lt;I>     where         I: Individual,     {         (0..population.len())             .map(|_| {                 let parent_a = self.selection_method.select(rng, population).chromosome();                 let parent_b = self.selection_method.select(rng, population).chromosome();                  \/* ... *\/             })             .collect()     } }  \/* ... *\/  pub trait Individual {     fn fitness(&amp;self) -> f32;     fn chromosome(&amp;self) -> &amp;Chromosome; }  \/* ... *\/  #[cfg(test)] mod tests {     \/* ... *\/      impl Individual for TestIndividual {         fn fitness(&amp;self) -> f32 {             self.fitness         }          fn chromosome(&amp;self) -> &amp;Chromosome {             panic!(\"\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f TestIndividual\")         }     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u044f, \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Crossover_(genetic_algorithm)#Examples\">\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e<\/a> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u041e\u0431\u044b\u0447\u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <strong>\u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435\u043c (uniform crossover)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0438\u0441\u0443\u043d\u043a\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/hg\/ov\/n4\/hgovn4tpxzhs_-qot6odjwytgea.png\" data-src=\"https:\/\/habrastorage.org\/webt\/hg\/ov\/n4\/hgovn4tpxzhs_-qot6odjwytgea.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u043f\u0440\u0435\u0436\u0434\u0435, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u0438\u043f\u0430\u0436\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait CrossoverMethod {     fn crossover(         &amp;self,         rng: &amp;mut dyn RngCore,         parent_a: &amp;Chromosome,         parent_b: &amp;Chromosome,     ) -> Chromosome; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct UniformCrossover;  impl CrossoverMethod for UniformCrossover {     fn crossover(         &amp;self,         rng: &amp;mut dyn RngCore,         parent_a: &amp;Chromosome,         parent_b: &amp;Chromosome,     ) -> Chromosome {         let mut child = Vec::new();         let gene_count = parent_a.len();          for gene_idx in 0..gene_count {             let gene = if rng.gen_bool(0.5) {                 parent_a[gene_idx]             } else {                 parent_b[gene_idx]             };              child.push(gene);         }          child.into_iter().collect()     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0430\u0448 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043a\u0440\u0438\u0442\u0438\u043a, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u2013 \u0438 \u043e\u043d\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u044e\u0442\u0441\u044f!<\/p>\n<p>  <\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl CrossoverMethod for UniformCrossover {     fn crossover(\/* ... *\/) -> Chromosome {         assert_eq!(parent_a.len(), parent_b.len());          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u043c <code>.zip()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl CrossoverMethod for UniformCrossover {     fn crossover(\/* ... *\/) -> Chromosome {         assert_eq!(parent_a.len(), parent_b.len());          parent_a             .iter()             .zip(parent_b.iter())             .map(|(&amp;a, &amp;b)| if rng.gen_bool(0.5) { a } else { b })             .collect()     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e!<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 <code>.iter()<\/code> \u0438 <code>FromIterator<\/code> \u043c\u0438\u043d\u0443\u0442\u0443 \u043d\u0430\u0437\u0430\u0434, \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u0434\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0441\u0443\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0412\u0430\u0448 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043a\u0440\u0438\u0442\u0438\u043a \u0432\u0441\u0435 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442\u2026 \u0445\u043c\u2026 \u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0442\u0435\u0441\u0442\u044b!<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn uniform_crossover() {         let mut rng = ChaCha8Rng::from_seed(Default::default());         let parent_a = todo!();         let parent_b = todo!();         let child = UniformCrossover.crossover(&amp;mut rng, &amp;parent_a, &amp;parent_b);          assert!(\/* ... *\/);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e <code>child<\/code> \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 50% <code>parent_\u0430<\/code> + 50% <code>parent_b<\/code>.<\/p>\n<p>  <\/p>\n<p>\u042f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u044b (\u043e\u043d\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0435\u043d\u043e\u0432):<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn uniform_crossover() {         \/* ... *\/          let parent_a: Chromosome = (1..=100).map(|n| n as f32).collect();         let parent_b: Chromosome = (1..=100).map(|n| -n as f32).collect();          \/\/ \u041f\u0435\u0440\u0432\u044b\u043c \u043f\u0440\u0435\u0434\u043a\u043e\u043c \u0431\u0443\u0434\u0435\u0442:         \/\/   [1, 2, \/* ... *\/, 100]         \/\/         \/\/ \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e, \u043d\u043e \u0441 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u043a\u0430\u043c\u0438:         \/\/   [-1, -2, \/* ... *\/, -100]         \/\/         \/\/ \u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439, \u0442\u043e\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0433\u0435\u043d\u043e\u0432 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f -         \/\/ 100 \u043f\u0440\u043e\u0441\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 100%, \u0432\u043e\u0442 \u0438 \u0432\u0441\u0435          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0438 \u0437\u0430\u0442\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e <code>child<\/code> \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn uniform_crossover() {         \/* ... *\/          let child = UniformCrossover.crossover(&amp;mut rng, &amp;parent_a, &amp;parent_b);          \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0435\u043d\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 `child` \u0438 `parent_a`         let diff_a = child.iter().zip(parent_a).filter(|(c, p)| *c != p).count();          \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0435\u043d\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 `child` \u0438 `parent_b`         let diff_b = child.iter().zip(parent_b).filter(|(c, p)| *c != p).count();          assert_eq!(diff_a, 0);         assert_eq!(diff_b, 0);     } }<\/code><\/pre>\n<p>  <\/p>\n<p><code>cargo test<\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">thread '...' panicked at 'assertion failed: `(left == right)`   left: `49`,  right: `0`'<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u043f\u0440\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">assert_eq!(diff_a, 49);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 <code>cargo test<\/code> &#171;\u043f\u0430\u0434\u0430\u0435\u0442&#187; \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">thread '...' panicked at 'assertion failed: `(left == right)`   left: `51`,  right: `0`'<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u043f\u043e\u044d\u0442\u043e\u043c\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">assert_eq!(diff_b, 51);<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn uniform_crossover() {         \/* ... *\/          assert_eq!(diff_a, 49);         assert_eq!(diff_b, 51);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448 <code>child<\/code> \u043f\u043e\u043b\u0443\u0447\u0438\u043b 49% \u0441\u0432\u043e\u0435\u0433\u043e \u0433\u0435\u043d\u043e\u043c\u0430 \u043e\u0442 <code>parent_a<\/code> \u0438 51% \u2014 \u043e\u0442 <code>parent_b<\/code>. \u042d\u0442\u043e \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0433\u0435\u043d\u044b \u043e\u0442 \u043e\u0431\u043e\u0438\u0445 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u0441 \u0440\u0430\u0432\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e (\u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 50% \u043d\u0430 50%, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c).<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>CrossoverMethod<\/code> \u0441\u043b\u0435\u0434\u043e\u043c \u0437\u0430 <code>SelectionMethod<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct GeneticAlgorithm&lt;S> {     selection_method: S,     crossover_method: Box&lt;dyn CrossoverMethod>, }  impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     pub fn new(         selection_method: S,         crossover_method: impl CrossoverMethod + 'static,     ) -> Self {         Self {             selection_method,             crossover_method: Box::new(crossover_method),         }     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>SelectionMethod::select()<\/code>, <code>CrossoverMethod::crossover()<\/code> \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0431\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, <a href=\"https:\/\/doc.rust-lang.org\/book\/ch17-02-trait-objects.html#object-safety-is-required-for-trait-objects\">\u043f\u043e\u044d\u0442\u043e\u043c\u0443<\/a> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c (\u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0432 <code>Box<\/code>). \u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct GeneticAlgorithm&lt;S, C> {     selection_method: S,     crossover_method: C, }  impl&lt;S, C> GeneticAlgorithm&lt;S, C> where     S: SelectionMethod,     C: CrossoverMethod, {     pub fn new(         selection_method: S,         crossover_method: C,     ) -> Self {         Self {             selection_method,             crossover_method,         }     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u2026 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u0437\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>T: Trait<\/code> \u043f\u0440\u043e\u0442\u0438\u0432 <code>dyn Trait<\/code> (\u0433\u0434\u0435 <code>Box&lt;dyn Trait><\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438).<\/p>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e\u0442, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>Box<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 Rust \u043c\u0435\u043d\u0435\u0435 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u043c.<\/p>\n<p>  \u041c\u043e\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>Box<\/code> \u2014 \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0435\u0433\u0430\u0442\u0438\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u0435\u0433\u0447\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c.<\/p><\/blockquote>\n<p>\u2026 \u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0435\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     \/* ... *\/      pub fn evolve&lt;I>(&amp;self, rng: &amp;mut dyn RngCore, population: &amp;[I]) -> Vec&lt;I>     where         I: Individual,     {         \/* ... *\/          (0..population.len())             .map(|_| {                 \/* ... *\/                  let mut child = self.crossover_method.crossover(rng, parent_a, parent_b);                  \/* ... *\/             })             .collect()     } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"razrabotka-mutaciya\">\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430: \u043c\u0443\u0442\u0430\u0446\u0438\u044f<\/h2>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u043d\u043e\u0432\u0430\u044f \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0430, \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f!<\/p>\n<p>  <\/p>\n<p>\u041c\u0443\u0442\u0430\u0446\u0438\u044f, \u043d\u0430\u0440\u044f\u0434\u0443 \u0441\u043e \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u043e\u0442\u0431\u043e\u0440\u043e\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0435\u0442\u044c\u0438\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Genetic_operator\">\u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c<\/a> \u2014 \u043e\u043d\u0430 \u0431\u0435\u0440\u0435\u0442 \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0443 \u0438 \u0432\u043d\u043e\u0441\u0438\u0442 \u0432 \u043d\u0435\u0435 \u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/u1\/n0\/1a\/u1n01ag38tnbax7bf00ypnnkgx4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/u1\/n0\/1a\/u1n01ag38tnbax7bf00ypnnkgx4.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438, \u0440\u043e\u043b\u044c \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u0430\u0441\u0442\u0440\u0435\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u043f\u0442\u0438\u043c\u0443\u043c\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044e \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u044f \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 <code>Chromosome<\/code>, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0443\u0442\u0430\u0446\u0438\u044e \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait MutationMethod {     fn mutate(&amp;self, rng: &amp;mut dyn RngCore, child: &amp;mut Chromosome); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>\u043c\u0443\u0442\u0430\u0446\u0438\u044e \u0413\u0430\u0443\u0441\u0441\u0430 (Gaussian mutation)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u0438\u0447\u0443\u0434\u043b\u0438\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043a\u0430\u0437\u0430\u0442\u044c: &#171;\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043b\u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u0433\u0435\u043d\u043e\u043c\u0430&#187;. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0442\u0431\u043e\u0440\u0430 \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043c\u0443\u0442\u0430\u0446\u0438\u044f \u0413\u0430\u0443\u0441\u0441\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Clone, Debug)] pub struct GaussianMutation {     \/\/\/ \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0433\u0435\u043d\u0430:     \/\/\/ - 0.0 = \u043d\u0438 \u043e\u0434\u0438\u043d \u0433\u0435\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442     \/\/\/ - 1.0 = \u0432\u0441\u0435 \u0433\u0435\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b     chance: f32,      \/\/\/ \u041c\u0430\u0433\u043d\u0438\u0442\u0443\u0434\u0430 \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:     \/\/\/ - 0.0 =  \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0435 \u0433\u0435\u043d\u044b \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u044b     \/\/\/ - 3.0 = \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0435 \u0433\u0435\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u044b (+=) \u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u044b (-=), \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043d\u0430 3.0     coeff: f32, }  impl GaussianMutation {     pub fn new(chance: f32, coeff: f32) -> Self {         assert!(chance >= 0.0 &amp;&amp; chance &lt;= 1.0);          Self { chance, coeff }     } }  impl MutationMethod for GaussianMutation {     fn mutate(&amp;self, rng: &amp;mut dyn RngCore, child: &amp;mut Chromosome) {         for gene in child.iter_mut() {             let sign = if rng.gen_bool(0.5) { -1.0 } else { 1.0 };              if rng.gen_bool(self.chance as f64) {                 *gene += sign * self.coeff * rng.gen::&lt;f32>();             }         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>fn test()<\/code>, \u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435, \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e <strong>\u043a\u0440\u0430\u0439\u043d\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      mod gaussian_mutation {         mod given_zero_chance {             mod and_zero_coefficient {                 #[test]                 fn does_not_change_the_original_chromosome() {                     todo!();                 }             }              mod and_nonzero_coefficient {                 #[test]                 fn does_not_change_the_original_chromosome() {                     todo!();                 }             }         }          mod given_fifty_fifty_chance {             mod and_zero_coefficient {                 #[test]                 fn does_not_change_the_original_chromosome() {                     todo!();                 }             }              mod and_nonzero_coefficient {                 #[test]                 fn slightly_changes_the_original_chromosome() {                     todo!();                 }             }         }          mod given_max_chance {             mod and_zero_coefficient {                 #[test]                 fn does_not_change_the_original_chromosome() {                     todo!();                 }             }              mod and_nonzero_coefficient {                 #[test]                 fn entirely_changes_the_original_chromosome() {                     todo!();                 }             }         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043d\u0443\u0442\u044c \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u044f \u043d\u0430\u0448\u0435\u043b \u044d\u0442\u043e \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c, \u0447\u0442\u043e \u043d\u0435 \u043c\u043e\u0433\u0443 \u043d\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043e \u043d\u0435\u043c. \u0422\u0435\u0441\u0442\u044b \u0441 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0441\u0442\u043e\u044f\u0442 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u044b, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043d\u0435 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0430\u044e\u0442.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      mod gaussian_mutation {         use super::*;          fn actual(chance: f32, coeff: f32) -> Vec&lt;f32> {             let mut rng = ChaCha8Rng::from_seed(Default::default());             let mut child = vec![1.0, 2.0, 3.0, 4.0, 5.0].into_iter().collect();              GaussianMutation::new(chance, coeff).mutate(&amp;mut rng, &amp;mut child);              child.into_iter().collect()         }          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># ...  [dev-dependencies] approx = \"0.4\" rand_chacha = \"0.3\"<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      mod gaussian_mutation {         \/* ... *\/          mod given_zero_chance {             use approx::assert_relative_eq;              fn actual(coeff: f32) -> Vec&lt;f32> {                 super::actual(0.0, coeff)             }              mod and_zero_coefficient {                 use super::*;                  #[test]                 fn does_not_change_the_original_chromosome() {                     let actual = actual(0.0);                     let expected = vec![1.0, 2.0, 3.0, 4.0, 5.0];                      assert_relative_eq!(actual.as_slice(), expected.as_slice());                 }             }              mod and_nonzero_coefficient {                 use super::*;                  #[test]                 fn does_not_change_the_original_chromosome() {                     let actual = actual(0.5);                     let expected = vec![1.0, 2.0, 3.0, 4.0, 5.0];                      assert_relative_eq!(actual.as_slice(), expected.as_slice());                 }             }         }          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>MutationMethod<\/code> \u0441\u043b\u0435\u0434\u043e\u043c \u0437\u0430 <code>SelectionMethod<\/code>. \u0412\u043d\u0443\u0442\u0440\u0438 <code>MutationMethod::mutate()<\/code> \u043d\u0435\u0442 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043a\u043e\u043b\u0435\u0431\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 <code>Box<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct GeneticAlgorithm&lt;S> {     selection_method: S,     crossover_method: Box&lt;dyn CrossoverMethod>,     mutation_method: Box&lt;dyn MutationMethod>, }  impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     pub fn new(         selection_method: S,         crossover_method: impl CrossoverMethod + 'static,         mutation_method: impl MutationMethod + 'static,     ) -> Self {         Self {             selection_method,             crossover_method: Box::new(crossover_method),             mutation_method: Box::new(mutation_method),         }     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0438 \u0437\u0430\u0442\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     \/* ... *\/      pub fn evolve&lt;I>(\/* ... *\/) -> Vec&lt;I>     where         I: Individual,     {         \/* ... *\/          (0..population.len())             .map(|_| {                 \/* ... *\/                  self.mutation_method.mutate(rng, &amp;mut child);                  \/* ... *\/             })             .collect()     } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"razrabotka-sozdanie-osobey\">\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0441\u043e\u0431\u0435\u0439<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u0448 <code>child<\/code> \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>Chromosome<\/code>, \u0430 \u0432\u0435\u043a\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c, \u2014 <code>Vec&lt;I><\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u2014 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043d\u043e\u0442\u0438\u043f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043e\u0441\u043e\u0431\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait Individual {     fn create(chromosome: Chromosome) -> Self;      \/* ... *\/ }  \/* ... *\/  #[cfg(test)] mod tests {     \/* ... *\/      impl Individual for TestIndividual {         fn create(chromosome: Chromosome) -> Self {            todo!()         }          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u0443\u0430\u043b\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl&lt;S> GeneticAlgorithm&lt;S> where     S: SelectionMethod, {     \/* ... *\/      pub fn evolve&lt;I>(&amp;self, rng: &amp;mut dyn RngCore, population: &amp;[I]) -> Vec&lt;I>     where         I: Individual,     {         assert!(!population.is_empty());          (0..population.len())             .map(|_| {                 let parent_a = self.selection_method.select(rng, population).chromosome();                 let parent_b = self.selection_method.select(rng, population).chromosome();                 let mut child = self.crossover_method.crossover(rng, parent_a, parent_b);                  self.mutation_method.mutate(rng, &amp;mut child);                  I::create(child)             })             .collect()     } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"testirovanie\">\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0439 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438: \u0442\u0435\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0441\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 <code>.evolve()<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0430\u0448\u0435\u0433\u043e <code>TestIndividual<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u043c\u0435\u0441\u0442\u043e <code>panic!()<\/code> \u043e\u043d \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b <code>::create()<\/code> \u0438 <code>.chromosome()<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0435\u0441\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f <code>RouletteWheelSelection<\/code>, \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u044f\u0442\u0441\u044f \u043e \u0433\u0435\u043d\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0430\u043b\u043b\u044b \u0437\u0430 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u042f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>TestIndividual<\/code> \u0441\u043e <code>struct<\/code> \u043d\u0430 <code>enum<\/code> \u0441 \u0434\u0432\u0443\u043c\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[derive(Clone, Debug)]     enum TestIndividual {         \/\/\/ \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0435         WithChromosome { chromosome: Chromosome },          \/\/\/ \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0445\u0440\u043e\u043c\u043e\u0441\u043e\u043c\u0435         WithFitness { fitness: f32 },     }      impl TestIndividual {         fn new(fitness: f32) -> Self {             Self::WithFitness { fitness }         }     }      impl Individual for TestIndividual {         fn create(chromosome: Chromosome) -> Self {             Self::WithChromosome { chromosome }         }          fn chromosome(&amp;self) -> &amp;Chromosome {             match self {                 Self::WithChromosome { chromosome } => chromosome,                  Self::WithFitness { .. } => {                     panic!(\"\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f TestIndividual::WithFitness\")                 }             }         }          fn fitness(&amp;self) -> f32 {             match self {                 Self::WithChromosome { chromosome } => {                     chromosome.iter().sum()                     \/\/ ^ \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043d\u0430 \u0441\u0432\u0435\u0442\u0435 \u0444\u0438\u0442\u043d\u0435\u0441-\u0444\u0443\u043d\u043a\u0446\u0438\u044f:                     \/\/ \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0433\u0435\u043d\u044b \u0432\u043c\u0435\u0441\u0442\u0435                 }                  Self::WithFitness { fitness } => *fitness,             }         }     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043a\u0430 \u043c\u044b \u0437\u0434\u0435\u0441\u044c, \u0432\u044b\u0432\u0435\u0434\u0435\u043c (derive) <code>PartialEq<\/code> \u2014 \u043d\u0430\u043c \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[derive(Clone, Debug, PartialEq)]     pub enum TestIndividual {         \/* ... *\/     }      \/* ... *\/      impl PartialEq for Chromosome {         fn eq(&amp;self, other: &amp;Self) -> bool {             approx::relative_eq!(self.genes.as_slice(), other.genes.as_slice())         }     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u0441\u0442\u0430, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043e\u0441\u043e\u0431\u0435\u0439, \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u044b \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043e\u043d\u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn genetic_algorithm() {         let mut rng = ChaCha8Rng::from_seed(Default::default());          let ga = GeneticAlgorithm::new(             RouletteWheelSelection,             UniformCrossover,             GaussianMutation::new(0.5, 0.5),         );          let mut population = vec![             \/* TODO *\/         ];          \/\/ \u041c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c `.evolve()` \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0447\u0442\u043e\u0431\u044b \u043b\u0435\u0433\u0447\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443         \/\/ \u043c\u0435\u0436\u0434\u0443 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044f\u043c\u0438.         \/\/         \/\/ 10 \u0432\u0437\u044f\u0442\u043e \u0441 \u043f\u043e\u0442\u043e\u043b\u043a\u0430, \u0441 \u0442\u0435\u043c \u0436\u0435 \u0443\u0441\u043f\u0435\u0445\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c 5, 20 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435         \/\/ 1000 \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u0439: \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f - \u043c\u0430\u0433\u043d\u0438\u0442\u0443\u0434\u0430         \/\/ \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044f\u043c\u0438.         for _ in 0..10 {             population = ga.evolve(&amp;mut rng, &amp;population);         }          let expected_population = vec![             \/* TODO *\/         ];          assert_eq!(population, expected_population);     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043e\u0431\u0435\u0439 \u0437\u0430 \u0440\u0430\u0437, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn genetic_algorithm() {         fn individual(genes: &amp;[f32]) -> TestIndividual {             TestIndividual::create(genes.iter().cloned().collect())         }          \/* ... *\/     }      \/* ... *\/ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn genetic_algorithm() {         \/* ... *\/          let mut population = vec![             individual(&amp;[0.0, 0.0, 0.0]),             individual(&amp;[1.0, 1.0, 1.0]),             individual(&amp;[1.0, 2.0, 1.0]),             individual(&amp;[1.0, 2.0, 4.0]),         ];          \/* ... *\/          let expected_population = vec![             individual(&amp;[0.0, 0.0, 0.0, 0.0]),             individual(&amp;[0.0, 0.0, 0.0, 0.0]),             individual(&amp;[0.0, 0.0, 0.0, 0.0]),             individual(&amp;[0.0, 0.0, 0.0, 0.0]),         ];          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>4 \u043e\u0441\u043e\u0431\u0438 \u0440\u043e\u0432\u043d\u043e \u043f\u043e 3 \u0433\u0435\u043d\u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u2014 \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043c\u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c.<\/em><\/p>\n<p>  <\/p>\n<p><code>cargo test<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">thread '...' panicked at 'assertion failed: `(left == right)`   left: `[WithChromosome { ... }, WithChromosome { ... }, ... ]`,  right: `[WithChromosome { ... }, WithChromosome { ... }, ... ]`,<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0433\u0435\u043d\u044b \u0438\u0437 <code>left<\/code> \u0432 <code>expected_population<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     \/* ... *\/      #[test]     fn genetic_algorithm() {         \/* ... *\/          let expected_population = vec![             individual(&amp;[0.44769490, 2.0648358, 4.3058133]),             individual(&amp;[1.21268670, 1.5538777, 2.8869110]),             individual(&amp;[1.06176780, 2.2657390, 4.4287640]),             individual(&amp;[0.95909685, 2.4618788, 4.0247330]),         ];          \/* ... *\/     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u2026 \u0445\u0430-\u0445\u0430-\u0445\u0430\u2026 \u0434\u0430\u2026 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c\u2026 \u0447\u0438\u0441\u043b\u0430?<\/p>\n<p>  <\/p>\n<p>\u041d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u0439 \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u043e \u043e\u0442\u043a\u0443\u0434\u0430 \u043d\u0430\u043c \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0441\u043e\u0431\u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0442\u0435, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043d\u0430\u0447\u0430\u043b\u0438?<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0436, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0438\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438!<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 `\u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438` \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 `\u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u043e\u0432` \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \/\/ \u0432\u043d\u0443\u0442\u0440\u0438 `TestIndividual::fitness()`  let population = vec![     individual(&amp;[\/* ... *\/]), \/\/ \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c = 0.0     individual(&amp;[\/* ... *\/]), \/\/ \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c = 1.0     individual(&amp;[\/* ... *\/]), \/\/ \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c ~= 1.33     individual(&amp;[\/* ... *\/]), \/\/ \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c ~= 2.33 ];  let expected_population = vec![     individual(&amp;[\/* ... *\/]), \/\/ \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c ~= 6.8     individual(&amp;[\/* ... *\/]), \/\/ \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c ~= 5.7     individual(&amp;[\/* ... *\/]), \/\/ \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c ~= 7.8     individual(&amp;[\/* ... *\/]), \/\/ \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c ~= 7.4 ];<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442! \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442! \u041d\u0430\u0448 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u0432\u044b\u0441\u0448\u0438\u0439 \u0445\u0438\u0449\u043d\u0438\u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0438!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/vo\/4a\/mt\/vo4amthjw0l7iz3ls5_oik8owim.png\" data-src=\"https:\/\/habrastorage.org\/webt\/vo\/4a\/mt\/vo4amthjw0l7iz3ls5_oik8owim.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u043e\u0441\u043e\u0431\u0438 \u0441\u0442\u0430\u043b\u0438 \u043b\u0443\u0447\u0448\u0435 \u0438 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u044b\u0431\u043e\u0440\u0443 \u043a\u043e\u043b\u0435\u0441\u0430 \u0440\u0443\u043b\u0435\u0442\u043a\u0438 \u0445\u0443\u0434\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, <code>[0,0, 0,0, 0,0]<\/code>, \u0431\u044b\u043b\u043e \u043e\u0442\u0431\u0440\u043e\u0448\u0435\u043d\u043e.<\/li>\n<li>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u043a\u0440\u0435\u0449\u0438\u0432\u0430\u043d\u0438\u044e \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0440\u043e\u0441 \u043e\u0442 3.5 \u0434\u043e 7 (!).<\/li>\n<li>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u0413\u0430\u0443\u0441\u0441\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0433\u0435\u043d\u044b (\u0447\u0438\u0441\u043b\u0430), \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u043c\u043e\u0436\u0435\u0442\u0435 \u043c\u043d\u0435 \u043d\u0435 \u0432\u0435\u0440\u0438\u0442\u044c, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ self.mutation_method.mutate(rng, &amp;mut child);<\/code><\/pre>\n<p>  <\/p>\n<p>\u2026 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u043d\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<h2 id=\"zaklyuchitelnye-mysli\">\u0417\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u044b\u0441\u043b\u0438<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0443\u0437\u043d\u0430\u0432 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u043f\u043e \u043f\u0443\u0442\u0438, \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0432\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430: \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c \u0438 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0441\u0435\u0440\u0438\u0438 \u043c\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u044d\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0432\u0438\u0434\u0435\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0431\u043e\u0440\u044b \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u2014 \u0437\u0434\u0435\u0441\u044c \u0432 \u0438\u0433\u0440\u0443 \u0432\u0441\u0442\u0443\u043f\u044f\u0442 JavaScript \u0438 WebAssembly.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<blockquote><p><a href=\"https:\/\/t.me\/timewebru\"><b>\u041d\u043e\u0432\u043e\u0441\u0442\u0438, \u043e\u0431\u0437\u043e\u0440\u044b \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0438 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u044b \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b Timeweb.Cloud \u2014 \u0432 \u043d\u0430\u0448\u0435\u043c Telegram-\u043a\u0430\u043d\u0430\u043b\u0435<\/b><\/a> <b>\u21a9<\/b><\/p><\/blockquote>\n<p><a href=\"https:\/\/timeweb.cloud\/?i=106909\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/r8\/ms\/jc\/r8msjcfet9mgza3ybpor_sdgrt0.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/r8\/ms\/jc\/r8msjcfet9mgza3ybpor_sdgrt0.jpeg\" data-blurred=\"true\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/820699\/\"> https:\/\/habr.com\/ru\/articles\/820699\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ok\/13\/y9\/ok13y9vlz-qasq8lvjgusd0lpyk.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ok\/13\/y9\/ok13y9vlz-qasq8lvjgusd0lpyk.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>\u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438<\/strong> \u0438 <strong>\u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/strong>.<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/817585\/\">\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/818985\/\">\u0412\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u0443\u044e FFNN (feedforward neural network \u2014 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0438 \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0433 \u043d\u0430 \u043f\u0443\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0437\u0433\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435. \u041f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445, \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0430\u0441\u044c \u043b\u0443\u0447\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043c\u043e\u0437\u0433 \u043d\u0430\u0447\u0430\u043b \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u044f \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c <strong>\u043e\u0431\u0443\u0447\u0438\u0442\u044c<\/strong> \u0433\u0440\u0443\u043f\u043f\u0443 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u0437\u0430\u043f\u044f\u0442\u043e\u0439, \u0435\u0441\u043b\u0438 \u0443\u0433\u043e\u0434\u043d\u043e)?<\/p>\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-379773","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379773","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=379773"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379773\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}