{"id":349659,"date":"2023-07-02T09:00:53","date_gmt":"2023-07-02T09:00:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=349659"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=349659","title":{"rendered":"<span>\u041f\u0440\u043e\u0433\u0443\u043b\u043a\u0430 \u043f\u043e \u043c\u043e\u0441\u0442\u0430\u043c \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430 \u0441 ORtools<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043e\u0434\u043d\u0438 \u0438\u0437 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u043d\u0435\u0439 \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u0433\u0440\u0430\u0434. \u042f \u0443\u0434\u0435\u043b\u0438\u043b \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e \u0443\u0440\u043e\u0432\u043d\u044f \u0436\u0438\u0437\u043d\u0438 \u0438 \u0431\u043b\u0430\u0433\u043e\u043f\u043e\u043b\u0443\u0447\u0438\u044f \u043a\u0440\u0430\u044f, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u044f\u0441\u044c \u043d\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u043a\u0443\u043f\u043a\u0438\/\u0430\u0440\u0435\u043d\u0434\u044b \u0436\u0438\u043b\u044c\u044f, \u0446\u0435\u043d\u044b \u0432 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430\u0445 \u0438 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0442\u0430\u043a\u0441\u0438\u0441\u0442\u043e\u0432. \u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0435\u043b \u0432 \u0433\u043e\u0440\u043e\u0434\u0435\/\u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u0443\u043b\u044c\u0442\u0443\u0440\u043d\u044b\u0439\/\u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u0441\u043f\u0435\u043a\u0442 \u0436\u0438\u0437\u043d\u0438 \u0433\u043e\u0440\u043e\u0434\u0430. \u0417\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043d\u0438\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0435 \u044f \u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u043b <em>\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438!<\/em> \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0441\u043f\u043e\u043a\u043e\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0433\u043e\u0440\u043e\u0434\u0430 \u0431\u043e\u0433\u0430\u0442\u0430\u044f, \u0438 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0448\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u044f \u043d\u0430\u0448\u0435\u043b \u043a\u043e\u0435-\u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f. \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u0437\u0430\u0434\u0430\u0447\u0435 \u0441\u0435\u043c\u0438 \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043d\u044b\u0445 \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430. \u0412 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u042d\u0439\u043b\u0435\u0440 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439 \u043d\u0430\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u043d\u0430\u0447\u0430\u043b\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0440\u0435\u0445\u0441\u043e\u0442\u043b\u0435\u0442\u043d\u0435\u0439 \u0434\u0430\u0432\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python \u0438 OR-Tools.<\/p>\n<h2>\u0421\u0435\u043c\u044c \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430<\/h2>\n<p>\u041f\u043e \u043b\u0435\u0433\u0435\u043d\u0434\u0435 \u0435\u0449\u0435 \u0441 \u043f\u0440\u0443\u0441\u0441\u043a\u0438\u0445 \u0432\u0440\u0435\u043c\u0435\u043d \u0436\u0438\u0442\u0435\u043b\u0438 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430 \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c: \u043a\u0430\u043a \u043f\u0440\u043e\u0439\u0442\u0438 \u0432\u0441\u0435 \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043d\u044b\u0435 \u043c\u043e\u0441\u0442\u044b \u0433\u043e\u0440\u043e\u0434\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043c\u043e\u0441\u0442\u043e\u0432 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u042d\u0439\u043b\u0435\u0440 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0432\u043e\u0435\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u00ab\u041a\u0430\u043a \u044f \u0441\u043b\u044b\u0448\u0430\u043b, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u044e\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u044e\u0442\u0441\u044f, \u043d\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438\u00bb.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 1542 \u0433\u043e\u0434\u0430 \u0431\u044b\u043b\u043e \u0441\u0435\u043c\u044c \u043c\u043e\u0441\u0442\u043e\u0432 \u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u0435\u0440\u0435\u0433\u0430 (\u0410\u043b\u044c\u0442\u0448\u0442\u0430\u0434\u0442, \u041a\u043d\u0430\u0439\u043f\u0445\u043e\u0444, \u041b\u043e\u043c\u0437\u0435 \u0438 \u0424\u043e\u0440\u0448\u0442\u0430\u0434\u0442). \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043b-\u0432\u043e \u043c\u043e\u0441\u0442\u043e\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0443\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c, \u043d\u043e \u0431\u0435\u0440\u0435\u0433\u0430 \u043e\u0441\u0442\u0430\u043b\u0438c\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c\u0438. \u0414\u0430\u043b\u0435\u0435, \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0435\u0440\u0438\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u0435\u043c\u044c \u043c\u043e\u0441\u0442\u043e\u0432 \u0431\u044b\u043b\u0438 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u0430\u043a\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u042d\u0439\u043b\u0435\u0440. <\/p>\n<p>\u0412 \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432 \u0435\u0441\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%AD%D0%B9%D0%BB%D0%B5%D1%80%D0%BE%D0%B2_%D1%86%D0%B8%D0%BA%D0%BB\" rel=\"noopener noreferrer nofollow\">\u042d\u0439\u043b\u0435\u0440\u043e\u0432\u0430 \u0446\u0435\u043f\u044c<\/a> &#8212; \u044d\u0442\u043e \u043f\u0443\u0442\u044c, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u043e \u0432\u0441\u0435\u043c \u0440\u0451\u0431\u0440\u0430\u043c \u0433\u0440\u0430\u0444\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0443. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043f\u0440\u043e\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u044c \u0442\u0435\u0440\u043c\u0438\u043d\u0430 \u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0441\u043a\u0438\u0445 \u043c\u043e\u0441\u0442\u0430\u0445. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u0432\u0435\u044f\u0442\u044c \u0442\u0430\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043c\u0430\u0442. \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aaa\/360\/de5\/aaa360de518696e3ee50a266e8730b25.png\" alt=\"\u041a\u0430\u0440\u0442\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430\" title=\"\u041a\u0430\u0440\u0442\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430\" width=\"1365\" height=\"768\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aaa\/360\/de5\/aaa360de518696e3ee50a266e8730b25.png\"\/><\/p>\n<div><figcaption>\u041a\u0430\u0440\u0442\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430<\/figcaption><\/div>\n<\/figure>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439<\/h2>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043e\u0440\u0438\u0435\u0439 \u0433\u0440\u0430\u0444\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430. \u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"V\" alt=\"V\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cf8\/764\/661\/cf87646618aba6b6fbf6b058ef481e01.svg\" width=\"15\" height=\"17\"\/>\u00a0&#8212; \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0433\u0440\u0430\u0444\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0447\u0435\u0442\u044b\u0440\u0435\u043c \u0431\u0435\u0440\u0435\u0433\u0430\u043c, \u00a0\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"V\" alt=\"V\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f80\/a11\/895\/f80a11895a3a1468983dbfb0a786c579.svg\" width=\"15\" height=\"17\"\/>&#8212; \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0431\u0435\u0440 \u0433\u0440\u0430\u0444\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u043e\u0441\u0442\u0430\u043c, \u0441\u0430\u043c \u0433\u0440\u0430\u0444 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"G=(V, E).\" alt=\"G=(V, E).\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b9c\/4a3\/be1\/b9c4a3be1896d8493bfc511484023017.svg\" width=\"99\" height=\"22\"\/> \u0414\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u0433\u0440\u0430\u0444 \u0443 \u043d\u0430\u0441 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a2d\/761\/5ac\/a2d7615ac18deaec18ec6f0376d24932.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430\" title=\"\u0421\u0445\u0435\u043c\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430\" width=\"404\" height=\"492\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a2d\/761\/5ac\/a2d7615ac18deaec18ec6f0376d24932.png\"\/><\/p>\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (ILP). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0432\u0435\u0434\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. \u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c:<\/p>\n<p><strong>\u0418\u043d\u0434\u0435\u043a\u0441\u044b<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"i, j \\in V\" alt=\"i, j \\in V\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f80\/873\/29e\/f8087329e69c33e7b994fe7bc2982097.svg\" width=\"62\" height=\"20\"\/>&#8212; \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432 \u0441\u0435\u0442\u0438 (\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u0435\u0440\u0435\u0433\u0430\u043c);<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"m \\in M\" alt=\"m \\in M\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a88\/60e\/dd3\/a8860edd3fe63dabf8958c69715b1351.svg\" width=\"61\" height=\"17\"\/>&#8212; \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0441\u0442\u043e\u0432;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(i, j, m) \\in E\" alt=\"(i, j, m) \\in E\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/278\/2f9\/5cf\/2782f95cfd368d913dd5a8e4e8d9307c.svg\" width=\"102\" height=\"22\"\/> &#8212; \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u043c\u043e\u0441\u0442\u0430\u043c (\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0441\u0442\u0430 \u0434\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0431\u0440\u0430);<\/p>\n<p><strong>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"s_i\" alt=\"s_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eb5\/faa\/675\/eb5faa6755bc4bfac035e7f9c548fe9d.svg\" width=\"16\" height=\"15\"\/>&#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0443\u0437\u0435\u043b \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0443\u0442\u0438 (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0442\u043e\u0447\u043a\u0443 \u0441\u0442\u0430\u0440\u0442\u0430 \u043d\u0435\u0442);<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"t_j\" alt=\"t_j\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ea\/af1\/cd1\/7eaaf1cd145ed2b30ca49499e69be57b.svg\" width=\"15\" height=\"21\"\/>&#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0443\u0437\u0435\u043b \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043d\u0435\u0442);<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"b_{ijm}\" alt=\"b_{ijm}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c4e\/af0\/46b\/c4eaf046b5c8ead1e1ab36e2ef0563a4.svg\" width=\"32\" height=\"22\"\/>&#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"m\" alt=\"m\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/48e\/1c4\/729\/48e1c472974041cabd17737c19e4838b.svg\" width=\"17\" height=\"12\"\/>\u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"i-j.\" alt=\"i-j.\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bed\/38b\/0c0\/bed38b0c0e7ed8a13fa6f18d9e9f14fb.svg\" width=\"44\" height=\"19\"\/><\/p>\n<p><strong>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>\u0412 \u0437\u0430\u0434\u0430\u0447\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u0432\u0441\u0435\u043c \u043c\u043e\u0441\u0442\u0430\u043c \u0438 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439: \u043d\u0430 \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u043f\u0443\u0442\u0438 &#8212; \u0440\u0435\u0431\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438; \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<ul>\n<li>\n<p>\u041e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0443\u0442\u0438 (\u043e\u0434\u0438\u043d \u0438\u0441\u0442\u043e\u043a):<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\sum_{i \\in I} s_i = 1;\" alt=\"\\sum_{i \\in I} s_i = 1;\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7d4\/f91\/cf3\/7d4f91cf3e1e412a3beae6b69b180dce.svg\" width=\"87\" height=\"45\"\/><\/p>\n<ul>\n<li>\n<p>\u041e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 (\u043e\u0434\u0438\u043d \u0441\u0442\u043e\u043a):<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\sum_{i \\in I} t_i = 1;\" alt=\"\\sum_{i \\in I} t_i = 1;\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/53c\/e81\/64e\/53ce8164e1c1fe0b5986db52e19a6e49.svg\" width=\"85\" height=\"45\"\/><\/p>\n<ul>\n<li>\n<p>\u0411\u0430\u043b\u0430\u043d\u0441 \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u0432 \u0443\u0437\u0435\u043b \u0441\u0435\u0442\u0438:<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"s_i + \\sum_{j \\in I}\\sum_{m \\in M} b_{jim} = t_i + \\sum_{j \\in I}\\sum_{m \\in M} b_{ijm}, \\quad \\forall i \\in I;\" alt=\"s_i + \\sum_{j \\in I}\\sum_{m \\in M} b_{jim} = t_i + \\sum_{j \\in I}\\sum_{m \\in M} b_{ijm}, \\quad \\forall i \\in I;\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/63f\/c02\/592\/63fc025925670dab7bf1a3d37729a823.svg\" width=\"390\" height=\"47\"\/><\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043c\u043e\u0441\u0442\u0443 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 (\u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438):<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"b_{ijm} + b_{jim} = 1, \\quad \\forall m \\in M.\" alt=\"b_{ijm} + b_{jim} = 1, \\quad \\forall m \\in M.\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6a4\/798\/4c5\/6a47984c5cfaf41e26dddba10b809381.svg\" width=\"229\" height=\"22\"\/><\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043f\u043e\u0441\u043e\u0431\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0432\u0438\u0434\u0435 ILP.<\/p>\n<h2>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u042d\u0439\u043b\u0435\u0440\u043e\u0432\u0430 \u043f\u0443\u0442\u0438 \u0441 OR-Tools<\/h2>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 OR-Tools \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 ILP \u0438 \u043d\u0430\u0439\u0442\u0438 \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c cp-sat solver, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 OR-Tools. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">pip install ortools<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0441\u0442 \u0441\u0432\u044f\u0436\u0435\u043c \u0441 \u0431\u0435\u0440\u0435\u0433\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0431\u0435\u0440\u0435\u0433\u043e\u043c \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f. \u0414\u043b\u044f \u0443\u0447\u0435\u0442\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 \u0432\u0432\u0435\u0434\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441 \u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0441\u0442\u0430 <code>_r<\/code> &#8212; reverse. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0441\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">from ortools.sat.python import cp_model  model = cp_model.CpModel()  # \u0423\u0447\u0430\u0441\u0442\u043a\u0438 \u0433\u043e\u0440\u043e\u0434\u0430, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u043a\u043e\u0439 \u041f\u0440\u0435\u0433\u043e\u043b\u044f areas = [\"Altstadt\", \"Kneiphof\", \"Vorstadt\", \"Lomse\"]  # \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0441\u0442\u043e\u0432 bridges = {     \"lavochniy\": (\"Altstadt\", \"Kneiphof\"),  # \u041b\u0430\u0432\u043e\u0447\u043d\u044b\u0439 \u043c\u043e\u0441\u0442     \"zeleniy\": (\"Kneiphof\", \"Vorstadt\"),  # \u0417\u0435\u043b\u0451\u043d\u044b\u0439 \u043c\u043e\u0441\u0442     \"rabochiy\": (\"Kneiphof\", \"Vorstadt\"),  # \u0420\u0430\u0431\u043e\u0447\u0438\u0439 \u043c\u043e\u0441\u0442     \"kuznechniy\": (\"Altstadt\", \"Kneiphof\"),  # \u041a\u0443\u0437\u043d\u0435\u0447\u043d\u044b\u0439 \u043c\u043e\u0441\u0442     \"derevyanniy\": (\"Altstadt\",  \"Lomse\"),    # \u0414\u0435\u0440\u0435\u0432\u044f\u043d\u043d\u044b\u0439 \u043c\u043e\u0441\u0442     \"visokiy\": (\"Vorstadt\", \"Lomse\"),     # \u0412\u044b\u0441\u043e\u043a\u0438\u0439 \u043c\u043e\u0441\u0442     \"medoviy\": (\"Kneiphof\", \"Lomse\")      # \u041c\u0435\u0434\u043e\u0432\u044b\u0439 \u043c\u043e\u0441\u0442 }  # \u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0431\u0440\u0430 arcs = {} for bridge, (_from, _to) in bridges.items():   arcs[bridge] = (_from, _to)   arcs[bridge + \"_r\"] = (_to, _from)<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412\u044b\u0448\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0438.<\/p>\n<pre><code class=\"python\"># \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f S = {}  # \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 start T = {}  # \u0421\u043b\u0430\u0432\u0440\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 terminate  for area in areas:   var_name = f\"s_{area}\"  # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439   S[area] = model.NewBoolVar(name=var_name)    var_name = f\"t_{area}\"  # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439   T[area] = model.NewBoolVar(name=var_name)  # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 E = {}  # \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 (\u0440\u0435\u0431\u0440\u0430)  for arc in arcs:   var_name = f\"b_{arc}\"  # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439   E[arc] = model.NewBoolVar(name=var_name)<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\"># \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f model.AddExactlyOne(S.values())  # \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f model.AddExactlyOne(T.values())  # \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f: \u0431\u0430\u043b\u0430\u043d\u0441 \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u0432 area for area in areas:   # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0432 area   start_var = S[area]   # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0432 area   t_var = T[area]   # \u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 area   lst_in_vars = [var for key, var in E.items() if arcs[key][1] == area]   # \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0438\u0437 area   lst_out_vars = [var for key, var in E.items() if arcs[key][0] == area]    # \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u043e\u0434\u0435\u043b\u044c   model.Add(start_var + sum(lst_in_vars) == sum(lst_out_vars) + t_var)  # \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043c\u043e\u0441\u0442\u0443 \u0440\u043e\u0432\u043d\u043e 1 \u0440\u0430\u0437 for bridge in bridges:   model.AddExactlyOne([E[bridge], E[bridge + \"_r\"]])<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 OR-Tools \u043d\u0430\u0431\u043e\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 &#8212; \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044c\/solver. \u0420\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438: 13 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0438 22 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f, \u043d\u043e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u0435\u0435 \u043d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"python\"># \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f solver solver = cp_model.CpSolver()  # # \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e \u043c\u043e\u0434\u0435\u043b\u0438 # print(model.ModelStats())  # \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 status = solver.Solve(model)  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 if status == cp_model.OPTIMAL:   print('\u041d\u0430\u0439\u0434\u0435\u043d \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c!') elif status == cp_model.INFEASIBLE:   print('\u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442!')<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u043e\u0442 \u042d\u0439\u043b\u0435\u0440\u0430. <\/p>\n<p><strong>\u041f\u0435\u0440\u0432\u0430\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u0430 \u042d\u0439\u043b\u0435\u0440\u0430, 1736.<\/strong> \u0413\u0440\u0430\u0444 \u0441 \u0434\u0432\u0443\u043c\u044f \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0438\u043c\u0435\u0435\u0442 \u044d\u0439\u043b\u0435\u0440\u043e\u0432 \u0446\u0438\u043a\u043b \u0442\u043e\u0433\u0434\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432\u0445\u043e\u0434\u0438\u0442 \u0447\u0451\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0451\u0431\u0435\u0440.<\/p>\n<p><strong>\u0412\u0442\u043e\u0440\u0430\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u0430 \u042d\u0439\u043b\u0435\u0440\u0430, 1736.<\/strong> \u0413\u0440\u0430\u0444 \u0441 \u0434\u0432\u0443\u043c\u044f \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0438\u043c\u0435\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u0442\u043e\u0433\u0434\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0440\u043e\u0432\u043d\u043e \u0432 \u0434\u0432\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0451\u0431\u0435\u0440.<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435.<\/strong> \u0413\u0440\u0430\u0444 \u0441 \u0434\u0432\u0443\u043c\u044f \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0438\u043c\u0435\u0435\u0442 \u044d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u0442\u043e\u0433\u0434\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043b\u0438\u0431\u043e \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432\u0445\u043e\u0434\u0438\u0442 \u0447\u0451\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0451\u0431\u0435\u0440, \u043b\u0438\u0431\u043e \u0440\u043e\u0432\u043d\u043e \u0432 \u0434\u0432\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0451\u0431\u0435\u0440.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430 \u0438\u043c\u0435\u0435\u043c \u0447\u0435\u0442\u044b\u0440\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0440\u0435\u0431\u0435\u0440, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 &#8212; <code>\u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442!<\/code> \u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. <\/p>\n<h2>\u041a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u043a\u043e\u0433\u0434\u0430 \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c? \u041e\u0442\u0432\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u0442\u0435\u043e\u0440\u0435\u043c \u042d\u0439\u043b\u0435\u0440\u0430, \u0438\u043b\u0438, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430: \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u043c\u043e\u0441\u0442\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c.<\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u043d\u043e \u0432\u043d\u0435\u0441\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043c\u043e\u0441\u0442\u043e\u0432. \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u043a: \u043f\u043e \u043c\u043e\u0441\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043e\u0434\u0438\u043d \u0440\u0430\u0437<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"b_{ijm} + b_{jim} \\le 1, \\quad \\forall m \\in M.\" alt=\"b_{ijm} + b_{jim} \\le 1, \\quad \\forall m \\in M.\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6d7\/43a\/edb\/6d743aedbed685a643f56e733d6ae0d4.svg\" width=\"229\" height=\"22\"\/><\/p>\n<p>\u0425\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u043c\u043e\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c. \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0432 \u0432\u0438\u0434\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\max \\sum_{i,j,m \\in E} b_{ijm}.\" alt=\"\\max \\sum_{i,j,m \\in E} b_{ijm}.\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3bf\/38a\/31f\/3bf38a31ff2b15a41180c68c314f3c91.svg\" width=\"130\" height=\"47\"\/><\/p>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439\/\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\"># \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430 # \u0412\u041d\u0418\u041c\u0410\u041d\u0418\u0415! \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043c\u043e\u0441\u0442\u0443 \u0440\u043e\u0432\u043d\u043e 1 \u0440\u0430\u0437 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 for bridge in bridges:   model.AddAtMostOne([E[bridge], E[bridge + \"_r\"]])  # \u0426\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043b-\u0432\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u0432 \u043f\u0443\u0442\u0438 model.Maximize(sum(E.values()))<\/code><\/pre>\n<p>\u041d\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0443\u0442\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0431\u0440\u0430. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0443\u043b\u043a\u0443 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u042d\u0439\u043b\u0435\u0440\u043e\u0432\u044b\u043c \u043f\u0443\u0442\u0435\u043c, \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c &#8212; `\u041d\u0430\u0439\u0434\u0435\u043d \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c!`.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u043e\u0439 \u043c\u043e\u0441\u0442\/\u043c\u043e\u0441\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043c\u043d\u0435\u043c \u043f\u0440\u0435\u0442\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f &#8230; \u0423\u0436\u0435 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u042d\u0439\u043b\u0435\u0440\u0430, \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u0441\u0442 (\u043e\u0434\u0438\u043d), \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043b\u0438 \u0443\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439, \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0440\u0435\u0448\u0430\u0435\u043c\u043e\u0439. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u043c\u043e\u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: <\/p>\n<pre><code>\u041c\u043e\u0441\u0442\u044b: medoviy_r -> kuznechniy_r -> derevyanniy -> visokiy_r -> rabochiy_r -> zeleniy \u0411\u0435\u0440\u0435\u0433\u0430: Lomse -> Kneiphof -> Altstadt -> Lomse -> Vorstadt -> Kneiphof -> Vorstadt<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9f6\/2fe\/4c4\/9f62fe4c415de1b665c167b8b2c01b90.png\" alt=\"\u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u0438 \u0438\u0437 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 \u043c\u043e\u0441\u0442\u043e\u0432\" title=\"\u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u0438 \u0438\u0437 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 \u043c\u043e\u0441\u0442\u043e\u0432\" width=\"476\" height=\"492\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f6\/2fe\/4c4\/9f62fe4c415de1b665c167b8b2c01b90.png\"\/><\/p>\n<div><figcaption>\u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u0438 \u0438\u0437 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 \u043c\u043e\u0441\u0442\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u043c, \u0442.\u0435. \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0434\u0430\u043d \u043d\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c. \u0423\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0441\u043e\u0432 \u0432 \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0437\u0430 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u043c\u043e\u0441\u0442\u0430. \u0412\u0435\u0441 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432, \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043f\u043e \u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u0435\u0434\u044b \u0438\u043b\u0438 \u0436\u0438\u0432\u043e\u043f\u0438\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0441\u0442\u043e\u0432.<\/p>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u043f\u044f\u0442\u044c \u043c\u043e\u0441\u0442\u043e\u0432 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0435 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043d\u043e\u0432\u044b\u0435 3 \u043c\u043e\u0441\u0442\u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0443\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0440\u043e\u0433\u0443\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0443, \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0437\u044f\u0442\u044c \u043d\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0443 \u0438 \u043f\u0440\u043e\u0433\u0443\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u043e \u042d\u0439\u043b\u0435\u0440\u043e\u0432\u0443 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0443 \u0432 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0430 \u0438 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%B4%D0%B0%D1%87%D0%B0_%D0%BE_%D1%81%D0%B5%D0%BC%D0%B8_%D0%BA%D1%91%D0%BD%D0%B8%D0%B3%D1%81%D0%B1%D0%B5%D1%80%D0%B3%D1%81%D0%BA%D0%B8%D1%85_%D0%BC%D0%BE%D1%81%D1%82%D0%B0%D1%85\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/a>;<\/p>\n<\/li>\n<li>\n<p>\u0412\u0435\u0440\u0441\u0438\u044f <a href=\"https:\/\/github.com\/Lozkins\/mos\/blob\/master\/Special_Seven_Bridges_of_K%C3%B6nigsberg.ipynb\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u0432 Jupyter notebook.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0445\u043e\u0436\u0438\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b:<\/p>\n<p>&#8212; <a href=\"https:\/\/habr.com\/ru\/articles\/731006\/\" rel=\"noopener noreferrer nofollow\">\u041c\u043e\u0434\u0435\u043b\u044c<\/a> \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u0448\u0438\u043d \u0442\u0430\u043a\u0441\u0438 \u043d\u0430 \u0437\u0430\u044f\u0432\u043a\u0438;<\/p>\n<p>&#8212; <a href=\"https:\/\/habr.com\/ru\/articles\/735572\/\" rel=\"noopener noreferrer nofollow\">\u041c\u043e\u0434\u0435\u043b\u044c<\/a> \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432;<\/p>\n<p>&#8212; \u0412\u0432\u043e\u0434\u043d\u0430\u044f <a href=\"https:\/\/habr.com\/ru\/articles\/733804\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u043f\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<\/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\/745300\/\"> https:\/\/habr.com\/ru\/articles\/745300\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043e\u0434\u043d\u0438 \u0438\u0437 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u043d\u0435\u0439 \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u0433\u0440\u0430\u0434. \u042f \u0443\u0434\u0435\u043b\u0438\u043b \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e \u0443\u0440\u043e\u0432\u043d\u044f \u0436\u0438\u0437\u043d\u0438 \u0438 \u0431\u043b\u0430\u0433\u043e\u043f\u043e\u043b\u0443\u0447\u0438\u044f \u043a\u0440\u0430\u044f, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u044f\u0441\u044c \u043d\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u043a\u0443\u043f\u043a\u0438\/\u0430\u0440\u0435\u043d\u0434\u044b \u0436\u0438\u043b\u044c\u044f, \u0446\u0435\u043d\u044b \u0432 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430\u0445 \u0438 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0442\u0430\u043a\u0441\u0438\u0441\u0442\u043e\u0432. \u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0435\u043b \u0432 \u0433\u043e\u0440\u043e\u0434\u0435\/\u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u0443\u043b\u044c\u0442\u0443\u0440\u043d\u044b\u0439\/\u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u0441\u043f\u0435\u043a\u0442 \u0436\u0438\u0437\u043d\u0438 \u0433\u043e\u0440\u043e\u0434\u0430. \u0417\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043d\u0438\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0435 \u044f \u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u043b <em>\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438!<\/em> \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0441\u043f\u043e\u043a\u043e\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0433\u043e\u0440\u043e\u0434\u0430 \u0431\u043e\u0433\u0430\u0442\u0430\u044f, \u0438 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0448\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u044f \u043d\u0430\u0448\u0435\u043b \u043a\u043e\u0435-\u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f. \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u0437\u0430\u0434\u0430\u0447\u0435 \u0441\u0435\u043c\u0438 \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043d\u044b\u0445 \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430. \u0412 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u042d\u0439\u043b\u0435\u0440 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439 \u043d\u0430\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u043d\u0430\u0447\u0430\u043b\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0440\u0435\u0445\u0441\u043e\u0442\u043b\u0435\u0442\u043d\u0435\u0439 \u0434\u0430\u0432\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python \u0438 OR-Tools.<\/p>\n<h2>\u0421\u0435\u043c\u044c \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430<\/h2>\n<p>\u041f\u043e \u043b\u0435\u0433\u0435\u043d\u0434\u0435 \u0435\u0449\u0435 \u0441 \u043f\u0440\u0443\u0441\u0441\u043a\u0438\u0445 \u0432\u0440\u0435\u043c\u0435\u043d \u0436\u0438\u0442\u0435\u043b\u0438 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430 \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c: \u043a\u0430\u043a \u043f\u0440\u043e\u0439\u0442\u0438 \u0432\u0441\u0435 \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043d\u044b\u0435 \u043c\u043e\u0441\u0442\u044b \u0433\u043e\u0440\u043e\u0434\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043c\u043e\u0441\u0442\u043e\u0432 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u042d\u0439\u043b\u0435\u0440 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0432\u043e\u0435\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u00ab\u041a\u0430\u043a \u044f \u0441\u043b\u044b\u0448\u0430\u043b, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u044e\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u044e\u0442\u0441\u044f, \u043d\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438\u00bb.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 1542 \u0433\u043e\u0434\u0430 \u0431\u044b\u043b\u043e \u0441\u0435\u043c\u044c \u043c\u043e\u0441\u0442\u043e\u0432 \u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u0435\u0440\u0435\u0433\u0430 (\u0410\u043b\u044c\u0442\u0448\u0442\u0430\u0434\u0442, \u041a\u043d\u0430\u0439\u043f\u0445\u043e\u0444, \u041b\u043e\u043c\u0437\u0435 \u0438 \u0424\u043e\u0440\u0448\u0442\u0430\u0434\u0442). \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043b-\u0432\u043e \u043c\u043e\u0441\u0442\u043e\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0443\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c, \u043d\u043e \u0431\u0435\u0440\u0435\u0433\u0430 \u043e\u0441\u0442\u0430\u043b\u0438c\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c\u0438. \u0414\u0430\u043b\u0435\u0435, \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0435\u0440\u0438\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u0435\u043c\u044c \u043c\u043e\u0441\u0442\u043e\u0432 \u0431\u044b\u043b\u0438 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u0430\u043a\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u042d\u0439\u043b\u0435\u0440. <\/p>\n<p>\u0412 \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432 \u0435\u0441\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%AD%D0%B9%D0%BB%D0%B5%D1%80%D0%BE%D0%B2_%D1%86%D0%B8%D0%BA%D0%BB\" rel=\"noopener noreferrer nofollow\">\u042d\u0439\u043b\u0435\u0440\u043e\u0432\u0430 \u0446\u0435\u043f\u044c<\/a> &#8212; \u044d\u0442\u043e \u043f\u0443\u0442\u044c, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u043e \u0432\u0441\u0435\u043c \u0440\u0451\u0431\u0440\u0430\u043c \u0433\u0440\u0430\u0444\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0443. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043f\u0440\u043e\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u044c \u0442\u0435\u0440\u043c\u0438\u043d\u0430 \u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0441\u043a\u0438\u0445 \u043c\u043e\u0441\u0442\u0430\u0445. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u0432\u0435\u044f\u0442\u044c \u0442\u0430\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043c\u0430\u0442. \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u0430\u0440\u0442\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430<\/figcaption><\/div>\n<\/figure>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439<\/h2>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043e\u0440\u0438\u0435\u0439 \u0433\u0440\u0430\u0444\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430. \u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u00a0&#8212; \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0433\u0440\u0430\u0444\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0447\u0435\u0442\u044b\u0440\u0435\u043c \u0431\u0435\u0440\u0435\u0433\u0430\u043c, \u00a0\u0438 &#8212; \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0431\u0435\u0440 \u0433\u0440\u0430\u0444\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u043e\u0441\u0442\u0430\u043c, \u0441\u0430\u043c \u0433\u0440\u0430\u0444 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c  \u0414\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u0433\u0440\u0430\u0444 \u0443 \u043d\u0430\u0441 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439.<\/p>\n<figure class=\"\">\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (ILP). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0432\u0435\u0434\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. \u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c:<\/p>\n<p><strong>\u0418\u043d\u0434\u0435\u043a\u0441\u044b<\/strong><\/p>\n<p>&#8212; \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432 \u0441\u0435\u0442\u0438 (\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u0435\u0440\u0435\u0433\u0430\u043c);<\/p>\n<p>&#8212; \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0441\u0442\u043e\u0432;<\/p>\n<p> &#8212; \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u043c\u043e\u0441\u0442\u0430\u043c (\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0441\u0442\u0430 \u0434\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0431\u0440\u0430);<\/p>\n<p><strong>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/strong><\/p>\n<p>&#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0443\u0437\u0435\u043b \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0443\u0442\u0438 (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0442\u043e\u0447\u043a\u0443 \u0441\u0442\u0430\u0440\u0442\u0430 \u043d\u0435\u0442);<\/p>\n<p>&#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0443\u0437\u0435\u043b \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043d\u0435\u0442);<\/p>\n<p>&#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 <\/p>\n<p><strong>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>\u0412 \u0437\u0430\u0434\u0430\u0447\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u0432\u0441\u0435\u043c \u043c\u043e\u0441\u0442\u0430\u043c \u0438 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439: \u043d\u0430 \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u043f\u0443\u0442\u0438 &#8212; \u0440\u0435\u0431\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438; \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<ul>\n<li>\n<p>\u041e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0443\u0442\u0438 (\u043e\u0434\u0438\u043d \u0438\u0441\u0442\u043e\u043a):<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u041e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 (\u043e\u0434\u0438\u043d \u0441\u0442\u043e\u043a):<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0411\u0430\u043b\u0430\u043d\u0441 \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u0432 \u0443\u0437\u0435\u043b \u0441\u0435\u0442\u0438:<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043c\u043e\u0441\u0442\u0443 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 (\u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438):<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043f\u043e\u0441\u043e\u0431\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0432\u0438\u0434\u0435 ILP.<\/p>\n<h2>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u042d\u0439\u043b\u0435\u0440\u043e\u0432\u0430 \u043f\u0443\u0442\u0438 \u0441 OR-Tools<\/h2>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 OR-Tools \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 ILP \u0438 \u043d\u0430\u0439\u0442\u0438 \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c cp-sat solver, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 OR-Tools. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">pip install ortools<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u0441\u0442 \u0441\u0432\u044f\u0436\u0435\u043c \u0441 \u0431\u0435\u0440\u0435\u0433\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0431\u0435\u0440\u0435\u0433\u043e\u043c \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f. \u0414\u043b\u044f \u0443\u0447\u0435\u0442\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 \u0432\u0432\u0435\u0434\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441 \u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0441\u0442\u0430 <code>_r<\/code> &#8212; reverse. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0441\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">from ortools.sat.python import cp_model  model = cp_model.CpModel()  # \u0423\u0447\u0430\u0441\u0442\u043a\u0438 \u0433\u043e\u0440\u043e\u0434\u0430, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u043a\u043e\u0439 \u041f\u0440\u0435\u0433\u043e\u043b\u044f areas = [\"Altstadt\", \"Kneiphof\", \"Vorstadt\", \"Lomse\"]  # \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0441\u0442\u043e\u0432 bridges = {     \"lavochniy\": (\"Altstadt\", \"Kneiphof\"),  # \u041b\u0430\u0432\u043e\u0447\u043d\u044b\u0439 \u043c\u043e\u0441\u0442     \"zeleniy\": (\"Kneiphof\", \"Vorstadt\"),  # \u0417\u0435\u043b\u0451\u043d\u044b\u0439 \u043c\u043e\u0441\u0442     \"rabochiy\": (\"Kneiphof\", \"Vorstadt\"),  # \u0420\u0430\u0431\u043e\u0447\u0438\u0439 \u043c\u043e\u0441\u0442     \"kuznechniy\": (\"Altstadt\", \"Kneiphof\"),  # \u041a\u0443\u0437\u043d\u0435\u0447\u043d\u044b\u0439 \u043c\u043e\u0441\u0442     \"derevyanniy\": (\"Altstadt\",  \"Lomse\"),    # \u0414\u0435\u0440\u0435\u0432\u044f\u043d\u043d\u044b\u0439 \u043c\u043e\u0441\u0442     \"visokiy\": (\"Vorstadt\", \"Lomse\"),     # \u0412\u044b\u0441\u043e\u043a\u0438\u0439 \u043c\u043e\u0441\u0442     \"medoviy\": (\"Kneiphof\", \"Lomse\")      # \u041c\u0435\u0434\u043e\u0432\u044b\u0439 \u043c\u043e\u0441\u0442 }  # \u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0431\u0440\u0430 arcs = {} for bridge, (_from, _to) in bridges.items():   arcs[bridge] = (_from, _to)   arcs[bridge + \"_r\"] = (_to, _from)<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412\u044b\u0448\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0438.<\/p>\n<pre><code class=\"python\"># \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f S = {}  # \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 start T = {}  # \u0421\u043b\u0430\u0432\u0440\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 terminate  for area in areas:   var_name = f\"s_{area}\"  # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439   S[area] = model.NewBoolVar(name=var_name)    var_name = f\"t_{area}\"  # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439   T[area] = model.NewBoolVar(name=var_name)  # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 E = {}  # \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 (\u0440\u0435\u0431\u0440\u0430)  for arc in arcs:   var_name = f\"b_{arc}\"  # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439   E[arc] = model.NewBoolVar(name=var_name)<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\"># \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f model.AddExactlyOne(S.values())  # \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f model.AddExactlyOne(T.values())  # \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f: \u0431\u0430\u043b\u0430\u043d\u0441 \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u0432 area for area in areas:   # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0432 area   start_var = S[area]   # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0432 area   t_var = T[area]   # \u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 area   lst_in_vars = [var for key, var in E.items() if arcs[key][1] == area]   # \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0438\u0437 area   lst_out_vars = [var for key, var in E.items() if arcs[key][0] == area]    # \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u043e\u0434\u0435\u043b\u044c   model.Add(start_var + sum(lst_in_vars) == sum(lst_out_vars) + t_var)  # \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043c\u043e\u0441\u0442\u0443 \u0440\u043e\u0432\u043d\u043e 1 \u0440\u0430\u0437 for bridge in bridges:   model.AddExactlyOne([E[bridge], E[bridge + \"_r\"]])<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 OR-Tools \u043d\u0430\u0431\u043e\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 &#8212; \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044c\/solver. \u0420\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438: 13 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0438 22 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f, \u043d\u043e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u0435\u0435 \u043d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"python\"># \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f solver solver = cp_model.CpSolver()  # # \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e \u043c\u043e\u0434\u0435\u043b\u0438 # print(model.ModelStats())  # \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 status = solver.Solve(model)  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 if status == cp_model.OPTIMAL:   print('\u041d\u0430\u0439\u0434\u0435\u043d \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c!') elif status == cp_model.INFEASIBLE:   print('\u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442!')<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u043e\u0442 \u042d\u0439\u043b\u0435\u0440\u0430. <\/p>\n<p><strong>\u041f\u0435\u0440\u0432\u0430\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u0430 \u042d\u0439\u043b\u0435\u0440\u0430, 1736.<\/strong> \u0413\u0440\u0430\u0444 \u0441 \u0434\u0432\u0443\u043c\u044f \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0438\u043c\u0435\u0435\u0442 \u044d\u0439\u043b\u0435\u0440\u043e\u0432 \u0446\u0438\u043a\u043b \u0442\u043e\u0433\u0434\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432\u0445\u043e\u0434\u0438\u0442 \u0447\u0451\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0451\u0431\u0435\u0440.<\/p>\n<p><strong>\u0412\u0442\u043e\u0440\u0430\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u0430 \u042d\u0439\u043b\u0435\u0440\u0430, 1736.<\/strong> \u0413\u0440\u0430\u0444 \u0441 \u0434\u0432\u0443\u043c\u044f \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0438\u043c\u0435\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u0442\u043e\u0433\u0434\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0440\u043e\u0432\u043d\u043e \u0432 \u0434\u0432\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0451\u0431\u0435\u0440.<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435.<\/strong> \u0413\u0440\u0430\u0444 \u0441 \u0434\u0432\u0443\u043c\u044f \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0438\u043c\u0435\u0435\u0442 \u044d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u0442\u043e\u0433\u0434\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043b\u0438\u0431\u043e \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432\u0445\u043e\u0434\u0438\u0442 \u0447\u0451\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0451\u0431\u0435\u0440, \u043b\u0438\u0431\u043e \u0440\u043e\u0432\u043d\u043e \u0432 \u0434\u0432\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0451\u0431\u0435\u0440.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0441\u0442\u043e\u0432 \u041a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0430 \u0438\u043c\u0435\u0435\u043c \u0447\u0435\u0442\u044b\u0440\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0440\u0435\u0431\u0435\u0440, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 &#8212; <code>\u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442!<\/code> \u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. <\/p>\n<h2>\u041a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u043a\u043e\u0433\u0434\u0430 \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c? \u041e\u0442\u0432\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u0442\u0435\u043e\u0440\u0435\u043c \u042d\u0439\u043b\u0435\u0440\u0430, \u0438\u043b\u0438, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430: \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u043c\u043e\u0441\u0442\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c.<\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u043d\u043e \u0432\u043d\u0435\u0441\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043c\u043e\u0441\u0442\u043e\u0432. \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u043a: \u043f\u043e \u043c\u043e\u0441\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043e\u0434\u0438\u043d \u0440\u0430\u0437<\/p>\n<p>\u0425\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u043c\u043e\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c. \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0432 \u0432\u0438\u0434\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439\/\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\"># \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043c\u043e\u0441\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430 # \u0412\u041d\u0418\u041c\u0410\u041d\u0418\u0415! \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043c\u043e\u0441\u0442\u0443 \u0440\u043e\u0432\u043d\u043e 1 \u0440\u0430\u0437 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 for bridge in bridges:   model.AddAtMostOne([E[bridge], E[bridge + \"_r\"]])  # \u0426\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043b-\u0432\u0430 \u043c\u043e\u0441\u0442\u043e\u0432 \u0432 \u043f\u0443\u0442\u0438 model.Maximize(sum(E.values()))<\/code><\/pre>\n<p>\u041d\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0443\u0442\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0431\u0440\u0430. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0443\u043b\u043a\u0443 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u042d\u0439\u043b\u0435\u0440\u043e\u0432\u044b\u043c \u043f\u0443\u0442\u0435\u043c, \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c &#8212; `\u041d\u0430\u0439\u0434\u0435\u043d \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c!`.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u043e\u0439 \u043c\u043e\u0441\u0442\/\u043c\u043e\u0441\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043c\u043d\u0435\u043c \u043f\u0440\u0435\u0442\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f &#8230; \u0423\u0436\u0435 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u042d\u0439\u043b\u0435\u0440\u0430, \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u0441\u0442 (\u043e\u0434\u0438\u043d), \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043b\u0438 \u0443\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439, \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0440\u0435\u0448\u0430\u0435\u043c\u043e\u0439. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u043c\u043e\u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: <\/p>\n<pre><code>\u041c\u043e\u0441\u0442\u044b: medoviy_r -> kuznechniy_r -> derevyanniy -> visokiy_r -> rabochiy_r -> zeleniy \u0411\u0435\u0440\u0435\u0433\u0430: Lomse -> Kneiphof -> Altstadt -> Lomse -> Vorstadt -> Kneiphof -> Vorstadt<\/code><\/pre>\n<figure class=\"\">\n<div><figcaption>\u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u0438 \u0438\u0437 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 \u043c\u043e\u0441\u0442\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u043c, \u0442.\u0435. \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0434\u0430\u043d \u043d\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c. \u0423\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0441\u043e\u0432 \u0432 \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0437\u0430 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u043c\u043e\u0441\u0442\u0430. \u0412\u0435\u0441 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432, \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043f\u043e \u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u0435\u0434\u044b \u0438\u043b\u0438 \u0436\u0438\u0432\u043e\u043f\u0438\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0441\u0442\u043e\u0432.<\/p>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u043f\u044f\u0442\u044c \u043c\u043e\u0441\u0442\u043e\u0432 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0435 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u042d\u0439\u043b\u0435\u0440\u043e\u0432 \u043f\u0443\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e,<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-349659","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/349659","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=349659"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/349659\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=349659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=349659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=349659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}