{"id":329004,"date":"2022-02-03T09:01:19","date_gmt":"2022-02-03T09:01:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=329004"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=329004","title":{"rendered":"<span>\u041a\u0430\u043a \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0448\u043a\u043e\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e IBM CPLEX Solver<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u043e\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u044b\u043c. \u0414\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443 \u0440\u0435\u0448\u0430\u043b\u0438\u0441\u044c \u043d\u0435 \u0432\u0441\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 NP-\u043f\u043e\u043b\u043d\u0430\u044f \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u00ab\u0432 \u043b\u043e\u0431\u00bb \u0437\u0430 \u043e\u0431\u043e\u0437\u0440\u0438\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442. (<a href=\"https:\/\/stackoverflow.com\/questions\/2177836\/algorithm-for-creating-a-school-timetable\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/a>)<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/118\/b4b\/2f7\/118b4b2f7681d3d47003498583fba3c6.PNG\" alt=\"\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043f\u0440\u043e 4\u0445 \u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u0443\u0431. \u041d\u043e \u043a\u0430\u043a \u043e\u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u2013 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0430\u0442\u044c\u0438\" title=\"\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043f\u0440\u043e 4\u0445 \u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u0443\u0431. \u041d\u043e \u043a\u0430\u043a \u043e\u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u2013 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0430\u0442\u044c\u0438\" width=\"625\" height=\"675\"\/><figcaption>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043f\u0440\u043e 4\u0445 \u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u0443\u0431. \u041d\u043e \u043a\u0430\u043a \u043e\u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u2013 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0430\u0442\u044c\u0438<\/figcaption><\/figure>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043a\u043e \u043c\u043d\u0435 \u0432 \u0440\u0443\u043a\u0438 \u043f\u043e\u043f\u0430\u043b \u043f\u0430\u043a\u0435\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f IBM CPLEX Solver \u0438 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u043a\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f.   <\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0440\u0435\u0448\u0438\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u0443\u044e, \u0435\u0449\u0435 \u0435\u0451 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <a href=\"https:\/\/www.ibm.com\/docs\/en\/icos\/20.1.0?topic=optimization-solving-mixed-integer-programming-problems-mip\" rel=\"noopener noreferrer nofollow\">MIP<\/a>.<\/p>\n<h2>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043b\u0438\u0446 \u0443 \u043d\u0430\u0441 \u0447\u0435\u0442\u044b\u0440\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0441\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442. \u0422.\u0435. \u043d\u0430\u0448\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0431\u0443\u0434\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u043c. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0438\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p align=\"center\"><strong>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0441\u0438<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p align=\"center\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 dat \u0444\u0430\u0439\u043b\u0435<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p>\u043a\u043b\u0430\u0441\u0441\u044b \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432<\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p>5\u0430 \u0438\u043b\u0438 9\u0431<\/p>\n<\/td>\n<td>\n<p>classes = {&#171;5a&#187;, &#171;5b&#187;, &#171;6a&#187;, &#171;6b&#187;, &#171;7a&#187;, &#171;7b&#187;, &#171;8a&#187;, &#171;8b&#187;, &#171;9a&#187;, &#171;9b&#187;,&#187;10a&#187;, &#171;10b&#187;, &#171;11a&#187;, &#171;11b&#187;};<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p>\u0443\u0447\u0438\u0442\u0435\u043b\u044f<\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p>\u0418\u0432\u0430\u043d\u043e\u0432\u0430 \u041c\u0430\u0440\u0438\u044f \u0418\u0432\u0430\u043d\u043e\u0432\u043d\u0430, \u041f\u0435\u0442\u0440\u043e\u0432\u0430 \u0422\u0430\u0442\u044c\u044f\u043d\u0430 \u0421\u0435\u0440\u0433\u0435\u0435\u0432\u043d\u0430 \u0438 \u0442.\u0434.<\/p>\n<\/td>\n<td>\n<p>teachers = {&#171;ivanova&#187;, &#171;petrova_en&#187;, &#171;sidorova_ge&#187;, &#171;shumova&#187;, &#171;trudovik_m&#187;, &#171;trudovik_w&#187;, &#171;stoprtteacher&#187;};   <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p>\u043a\u0430\u0431\u0438\u043d\u0435\u0442\u044b   <\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p>\u044d\u0442\u043e \u043f\u0440\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043d\u0430\u0442\u044b: 101 \u043a\u0430\u0431\u0438\u043d\u0435\u0442, \u0441\u043f\u043e\u0440\u0442. \u0437\u0430\u043b, \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u0442\u0440\u0443\u0434\u0430 \u2116 105, \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u0444\u0438\u0437\u0438\u043a\u0438 \u2116 205 \u0438 \u0442.\u0434.<\/p>\n<\/td>\n<td>\n<p>rooms = {&#171;18&#187;, &#171;sport1&#187;, &#171;trudy_m&#187;, &#171;trudy_w&#187; , &#171;21&#187;,&#187;22&#8243;,&#187;23&#8243;,&#187;24&#8243;, &#171;25&#187;, &#171;26&#187;, &#171;27&#187;, &#171;31&#187;,&#187;32&#8243;,&#187;33&#8243;,&#187;34&#8243;};<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p>\u0443\u0440\u043e\u043a\u0438<\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p>\u044d\u0442\u043e \u0432\u0430\u043a\u0430\u043d\u0442\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0432 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043a\u0430\u043a 3\u0445-\u0437\u043d\u0430\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c<\/p>\n<p>\u043f\u0435\u0440\u0432\u0430\u044f \u0446\u0438\u0444\u0440\u0430 \u2013 \u044d\u0442\u043e \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f \u043e\u0442 1 \u0434\u043e 6, \u0435\u0441\u043b\u0438 \u0443\u0447\u0430\u0442\u0441\u044f \u043f\u043e \u0448\u0435\u0441\u0442\u0438\u0434\u043d\u0435\u0432\u043a\u0435 \u0438 \u0434\u043e 5, \u0435\u0441\u043b\u0438 \u043f\u043e \u043f\u044f\u0442\u0438\u0434\u043d\u0435\u0432\u043a\u0435   <\/p>\n<p>\u0432\u0442\u043e\u0440\u044f \u0446\u0438\u0444\u0440\u0430 \u2013 \u043d\u043e\u043c\u0435\u0440 \u0441\u043c\u0435\u043d\u044b 1 \u0438\u043b\u0438 2   <\/p>\n<p>\u0442\u0440\u0435\u0442\u044c\u044f \u0446\u0438\u0444\u0440\u0430 \u2013 \u043d\u043e\u043c\u0435\u0440 \u0443\u0440\u043e\u043a\u0430 \u0432 \u0441\u043c\u0435\u043d\u0435. \u041e\u0431\u044b\u0447\u043d\u043e \u043e\u0442 1 \u0434\u043e 6 \u0438\u043b\u0438 \u0434\u043e 7   <\/p>\n<\/td>\n<td>\n<p>\/\/ day,  shift, lesson number<br \/> lessons = {<br \/> 111, 112, 113, 114, 115, 116, 117, 121, 122, 123, 124, 125, 126, 127\/\/,<br \/> 211, 212, 213, 214, 215, 216, 217, 221, 222, 223, 224, 225, 226, 227,<br \/> 311, 312, 313, 314, 315, 316, 317, 321, 322, 323, 324, 325, 326, 327,<br \/> 411, 412, 413, 414, 415, 416, 417, 421, 422, 423, 424, 425, 426, 427,<br \/> 511, 512, 513, 514, 515, 516, 517, 521, 522, 523, 524, 525, 526, 527,<br \/> 611, 612, 613, 614, 615, 616, 617, 621, 622, 623, 624, 625, 626, 627<br \/> };<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041c\u0435\u0436\u0434\u0443 \u043e\u0441\u044f\u043c\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u0418 \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u044d\u0442\u0438 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u041e\u043d\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0412 \u044d\u0442\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435:   <\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p align=\"center\"><strong>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p align=\"center\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 dat \u0444\u0430\u0439\u043b\u0435<\/strong> <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u043c\u0438 \u0438 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438<\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e >= 0. \u0415\u0441\u043b\u0438 \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u041d\u0415 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u2013 \u0442\u043e 0. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0444\u0438\u0437\u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0443 \u0432 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438. \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0432 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u0444\u0438\u0437\u0438\u043a\u0438. \u0422\u0443\u0442 \u0431\u0443\u0434\u0435\u043c \u0438\u0433\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430\u043c\u0438. 1 \u2013 \u0441\u0430\u043c\u044b\u0439 \u043b\u0443\u0447\u0448\u0438\u0439 \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0447\u0438\u0442\u0435\u043b\u044f. 2 \u2013 \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0445\u043e\u0440\u043e\u0448\u0438\u0439, 3 \u2013 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0439, \u043d\u043e \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0435\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e \u0432 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.   <\/p>\n<\/td>\n<td>\n<p>roomTeachersRelation = [<br \/> [2,1,1,1,0,0,0],<br \/> [0,0,0,0,0,0,1],<br \/> [0,0,0,0,1,0,0],<br \/> [0,0,0,0,0,1,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0]<br \/> ];<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432<\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p>\u0422\u0443\u0442 \u043f\u0438\u0448\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u043a\u043e\u0432 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0418\u0432\u0430\u043d\u043e\u0432\u0430 \u041c.\u0418. \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 4 \u0440\u0443\u0441\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u0430 \u0438 2 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u0443 6 \u0411 \u043a\u043b\u0430\u0441\u0441\u0430. \u0417\u043d\u0430\u0447\u0438\u0442 \u0432 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u043f\u0438\u0448\u0435\u043c \u0446\u0438\u0444\u0440\u0443 4 + 2\u00a0 = 6<\/p>\n<\/td>\n<td>\n<p>teacherClassRelation = [<br \/> [2,1,0,0,1,1,0,0,0,0,0,0,0,0],<br \/> [0,0,1,1,0,1,0,0,0,0,0,0,0,0],<br \/> [0,0,1,0,1,0,0,1,1,0,0,0,1,0],<br \/> [0,0,0,0,0,0,1,0,0,0,0,2,0,0],<br \/> [0,0,0,1,0,0,1,0,0,1,1,0,1,1],<br \/> [0,0,0,1,0,0,1,0,0,1,1,0,1,1],<br \/> [1,0,1,0,1,0,0,1,1,0,0,1,0,0]<br \/> ];<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432 \u0438 \u0443\u0440\u043e\u043a\u0430\u043c\u0438 <\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b 0 \u0438\u043b\u0438 1. \u0410 \u0442\u043e\u0447\u043d\u0435\u0435 \u0442\u0443\u0442 \u043c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u043c\u0435\u043d\u0435 \u0443\u0447\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441. \u0415\u0441\u043b\u0438 0 \u2013 \u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0443\u0440\u043e\u043a\u0438 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f.   <\/p>\n<\/td>\n<td>\n<p>classLessonRelation = [<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1]<br \/> ];<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0443\u0440\u043e\u043a\u0430<\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b 0 \u0438\u043b\u0438 1. \u0415\u0441\u043b\u0438 \u0441\u0442\u043e\u0438\u0442 0 \u2013 \u0437\u043d\u0430\u0447\u0438\u0442 \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0443\u0440\u043e\u043a\u0438 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f. \u042d\u0442\u043e \u043d\u0430 \u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0434\u043d\u0438 \u043d\u0435\u0434\u0435\u043b\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c\u0438 \u0434\u0435\u0442\u044c\u043c\u0438 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e \u0441\u0443\u0431\u0431\u043e\u0442\u0430\u043c.<\/p>\n<\/td>\n<td>\n<p>teacherLessonRelation = [<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,0,0,0]<br \/> ];<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 (4 \u043e\u0441\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0438 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438) \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043a\u0430\u043a \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u0443\u0431. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 4 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438 4 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u041c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u043e\u0432, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0443\u0440\u043e\u043a\u0438 \u0432 \u044d\u0442\u0438\u0445 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u0445. \u0418\u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0443\u0440\u043e\u043a\u0430 \u0438 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u0440\u0435\u0434\u0443. \u041d\u043e \u043f\u043e\u043a\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u043c\u0430\u043b\u044b\u043c.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"951\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/276\/6a3\/b15\/2766a3b1512e99d121d8dfa0c15aa4ad.png\" data-width=\"974\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/h2>\n<p>\u0412 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f 4\u0445 \u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c 0 \u0438\u043b\u0438 1.<\/p>\n<p>1 &#8212; \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0443\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. <\/p>\n<p>0 &#8212; \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f.<\/p>\n<pre><code class=\"java\">dvar int schedule [rooms][teachers][classes][lessons] in 0..1;<\/code><\/pre>\n<h2>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u0418\u043c\u0435\u044f \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0437\u0430\u0434\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f.<\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0441\u0442\u0440\u043e\u0433\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u043d\u0430\u0448\u0438\u0445 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u043b\u044c, \u0442\u043e \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u043e\u043b\u044c<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"java\">forall(  r in rooms,   t in teachers,   c in classes,   l in lessons   )  if(roomTeachersRelation[r][t] == 0 || teacherClassRelation[t][c] == 0 || classLessonRelation[c][l] == 0 || teacherLessonRelation[t][l] == 0)  {    schedule[r][t][c][l] == 0;    }   <\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432   <\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0437\u043d\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0440\u043e\u043a\u043e\u0432 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u0443 \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0443\u043c\u043c\u0430 \u0443\u0440\u043e\u043a\u043e\u0432 \u0432 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u0445 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u0430 \u0446\u0438\u0444\u0440\u0435 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f.   <\/p>\n<pre><code class=\"java\">\/\/ teacher - class relations forall( t in teachers, c in classes)  sum(r in rooms, l in lessons) schedule[r][t][c][l] == teacherClassRelation[t][c]; <\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u043c\u0438 \u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0443\u0440\u043e\u043a\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043e\u0434\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0443\u0440\u043e\u043a, \u0447\u0442\u043e \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e<\/p>\n<pre><code class=\"java\">\/\/ room - lesson relations  forall(r in rooms, l in lessons) sum(t in teachers, c in classes) schedule[r][t][c][l] &lt;= 1;<\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0443\u0440\u043e\u043a\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/p>\n<pre><code class=\"java\">\/\/ teacher - lesson relations   forall( t in teachers, l in lessons)      sum(r in rooms, c in classes)    schedule[r][t][c][l] &lt;= 1;<\/code><\/pre>\n<ul>\n<li>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432 \u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0443\u0440\u043e\u043a\u043e\u0432. \u042d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043a\u0430\u043a \u0438\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u0444\u0438\u0437\u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0430, \u0442\u0440\u0443\u0434\u044b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043a\u0430\u043a \u0440\u0435\u0448\u0435\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u043a\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0447\u0430\u0441\u0442\u043e \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b: \u0444\u0438\u0437\u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0430 \u0443 \u044e\u043d\u043e\u0448\u0435\u0439 \u0438 \u0434\u0435\u0432\u0443\u0448\u0435\u043a, \u0442\u0440\u0443\u0434\u044b \u0443 \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u043e\u0432 \u0438 \u0434\u0435\u0432\u043e\u0447\u0435\u043a, \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e \u044f\u0437\u044b\u043a\u0443 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0435.<\/p>\n<p>\u0423 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0442\u043e\u0436\u0435 \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0432\u0432\u0435\u0434\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u00ab\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0445\u00bb \u0443\u0447\u0438\u0442\u0435\u043b\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0438\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0433\u043e:<\/p>\n<pre><code class=\"java\">{string} foreignLangTeachers = ...;<\/code><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0432 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443 \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0443\u0447\u0438\u0442\u0435\u043b\u0435\u0439 \u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u0445.<\/p>\n<pre><code class=\"java\">  \/\/ class - lesson relations forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in foreignLangTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in foreignLangTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in trudyTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in trudyTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in informaticsTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in informaticsTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in sportTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in sportTeachers)    schedule[r][t][c][l] &lt;= 2;<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0426\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/h2>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043c\u0430\u0442. \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0422.\u0435. \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043a \u0447\u0435\u043c\u0443 \u043c\u044b \u0441\u0442\u0440\u0435\u043c\u0438\u043c\u0441\u044f. \u0422\u0443\u0442 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0438\u0445 \u0432\u0430\u0436\u043d\u043e. \u041f\u0435\u0440\u0432\u043e\u0435, \u044d\u0442\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0440\u043e\u043a\u0438 \u0434\u043b\u044f \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0432 \u0441\u0443\u0442\u043a\u0430\u0445. \u0422.\u0435. \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438 \u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0440\u043e\u043a\u0430 \u0441\u0432\u043e\u0435\u0439 \u0441\u043c\u0435\u043d\u044b. \u0412\u0442\u043e\u0440\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435, \u044d\u0442\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0440\u0430\u043d\u044c\u0448\u0435. \u0422\u0440\u0435\u0442\u044c\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0432\u0435\u043b\u0438 \u0443\u0440\u043e\u043a\u0438 \u0432 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0445 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u0445. \u041d\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>minimize  staticLex(  sum(c in classes, l in lessons) (  ClassLessonResult [c][l] * l  )    , sum(t in teachers, l in lessons) (  TeacherLessonResult [t][l] * l  ) , sum(r in rooms, t in teachers, c in classes, l in lessons) schedule[r][t][c][l] * roomTeachersRelation[r][t]    ) ;<\/code><\/pre>\n<h2>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432 OPL Studio \u044f \u0432\u0432\u0435\u043b\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/p>\n<pre><code>dvar int TeacherLessonResult[teachers][lessons] ; dvar int ClassLessonResult[classes][lessons] ; dvar int RoomLessonResult[rooms][lessons]; dvar int TeacherClassResult [teachers][classes]; dvar int RoomClassResult [rooms][classes]; dvar int RoomTeacherResult [rooms][teachers];<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 schedule.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"356\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c61\/977\/c3b\/c61977c3b1418fc8ec2404f092d225fb.png\" data-width=\"974\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u041c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<details class=\"spoiler\">\n<summary>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u043b\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">{string} rooms = ...; {string} teachers = ...; {string} foreignLangTeachers = ...; {string} trudyTeachers = ...; {string} informaticsTeachers = ...; {string} sportTeachers = ...; {string} classes = ...; {int} lessons = ...;  int roomTeachersRelation [rooms][teachers]= ...; int teacherClassRelation [teachers][classes] = ...; int classLessonRelation [classes][lessons] = ...; int teacherLessonRelation [teachers][lessons] = ...;  dvar int TeacherLessonResult[teachers][lessons] ; dvar int ClassLessonResult[classes][lessons] ; dvar int RoomLessonResult[rooms][lessons]; dvar int TeacherClassResult [teachers][classes]; dvar int RoomClassResult [rooms][classes]; dvar int RoomTeacherResult [rooms][teachers];  dvar int schedule [rooms][teachers][classes][lessons] in 0..1;   minimize  staticLex(  sum(c in classes, l in lessons) (  ClassLessonResult [c][l] * l  )    , sum(t in teachers, l in lessons) (  TeacherLessonResult [t][l] * l  ) , sum(r in rooms, t in teachers, c in classes, l in lessons) schedule[r][t][c][l] * roomTeachersRelation[r][t]    ) ;  subject to {  forall(  r in rooms,   t in teachers,   c in classes,   l in lessons   )  if(roomTeachersRelation[r][t] == 0 || teacherClassRelation[t][c] == 0 || classLessonRelation[c][l] == 0 || teacherLessonRelation[t][l] == 0)  {    schedule[r][t][c][l] == 0;    }        \/\/ teacher - class relations forall( t in teachers, c in classes)  sum(r in rooms, l in lessons) schedule[r][t][c][l] == teacherClassRelation[t][c];     forall( t in teachers, c in classes)  TeacherClassResult[t][c] == sum(r in rooms, l in lessons) schedule[r][t][c][l];        \/\/ room - lesson relations  forall(r in rooms, l in lessons) sum(t in teachers, c in classes) schedule[r][t][c][l] &lt;= 1;          forall(r in rooms, l in lessons) RoomLessonResult[r][l] == sum(t in teachers, c in classes) schedule[r][t][c][l]  ;              \/\/ teacher - lesson relations   forall( t in teachers, l in lessons)      sum(r in rooms, c in classes)    schedule[r][t][c][l] &lt;= 1;    forall( t in teachers, l in lessons)    TeacherLessonResult[t][l] == ( sum(r in rooms, c in classes)  schedule[r][t][c][l] ) ;      \/\/ class - lesson relations forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in foreignLangTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in foreignLangTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in trudyTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in trudyTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in informaticsTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in informaticsTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in sportTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in sportTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )   { ClassLessonResult [c][l] == ( sum(r in rooms, t in teachers)  schedule[r][t][c][l] ) ; }   \/\/ forall( r in rooms, c in classes)  RoomClassResult[r][c]  == ( sum(l in lessons, t in teachers)  schedule[r][t][c][l] ) ;  \/\/ forall( r in rooms, t in teachers)  RoomTeacherResult[r][t] == ( sum(l in lessons, c in classes)  schedule[r][t][c][l] ) ; }   <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>rooms = {&#171;18&#187;, &#171;sport1&#187;, &#171;trudy_m&#187;, &#171;trudy_w&#187; , &#171;21&#187;,&#187;22&#8243;,&#187;23&#8243;,&#187;24&#8243;, &#171;25&#187;, &#171;26&#187;, &#171;27&#187;, &#171;31&#187;,&#187;32&#8243;,&#187;33&#8243;,&#187;34&#8243;};<\/p>\n<p>teachers = {&#171;ivanova&#187;, &#171;petrova_en&#187;, &#171;sidorova_ge&#187;, &#171;shumova&#187;, &#171;trudovik_m&#187;, &#171;trudovik_w&#187;, &#171;stoprtteacher&#187;};<\/p>\n<p>foreignLangTeachers = {&#171;petrova_en&#187;, &#171;sidorova_ge&#187;};<\/p>\n<p>trudyTeachers = {&#171;trudovik_m&#187;, &#171;trudovik_w&#187;};<\/p>\n<p>informaticsTeachers = {&#171;trudovik_m&#187;, &#171;trudovik_w&#187;};<\/p>\n<p>sportTeachers = {&#171;trudovik_m&#187;, &#171;trudovik_w&#187;};<\/p>\n<p>classes = {&#171;5a&#187;, &#171;5b&#187;, &#171;6a&#187;, &#171;6b&#187;, &#171;7a&#187;, &#171;7b&#187;, &#171;8a&#187;, &#171;8b&#187;, &#171;9a&#187;, &#171;9b&#187;,&#187;10a&#187;, &#171;10b&#187;, &#171;11a&#187;, &#171;11b&#187;};<\/p>\n<p>\/\/ day,  shift, lesson number<br \/> lessons = {<br \/> 111, 112, 113, 114, 115, 116, 117, 121, 122, 123, 124, 125, 126, 127\/\/,<br \/> \/* 211, 212, 213, 214, 215, 216, 217, 221, 222, 223, 224, 225, 226, 227,<br \/> 311, 312, 313, 314, 315, 316, 317, 321, 322, 323, 324, 325, 326, 327,<br \/> 411, 412, 413, 414, 415, 416, 417, 421, 422, 423, 424, 425, 426, 427,<br \/> 511, 512, 513, 514, 515, 516, 517, 521, 522, 523, 524, 525, 526, 527,<br \/> 611, 612, 613, 614, 615, 616, 617, 621, 622, 623, 624, 625, 626, 627*\/<br \/> };<\/p>\n<p>roomTeachersRelation = [<br \/> [2,1,1,1,0,0,0],<br \/> [0,0,0,0,0,0,1],<br \/> [0,0,0,0,1,0,0],<br \/> [0,0,0,0,0,1,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0]<br \/> ];<\/p>\n<p>teacherClassRelation = [<br \/> [2, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],<br \/> [0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],<br \/> [0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0],<br \/> [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0],<br \/> [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1],<br \/> [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1],<br \/> [1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0]<br \/> ];<\/p>\n<p>classLessonRelation = [<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1]<br \/> ];<\/p>\n<p>teacherLessonRelation = [<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,0,0,0]<br \/> ];<\/p>\n<\/div>\n<\/details>\n<p>\u042d\u0442\u043e \u0431\u044b\u043b\u0430 \u0442\u043e\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0448\u043a\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0439 \u00ab\u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0438\u00bb \u0434\u043b\u044f \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/649445\/\"> https:\/\/habr.com\/ru\/post\/649445\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u043e\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u044b\u043c. \u0414\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443 \u0440\u0435\u0448\u0430\u043b\u0438\u0441\u044c \u043d\u0435 \u0432\u0441\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 NP-\u043f\u043e\u043b\u043d\u0430\u044f \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u00ab\u0432 \u043b\u043e\u0431\u00bb \u0437\u0430 \u043e\u0431\u043e\u0437\u0440\u0438\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442. (<a href=\"https:\/\/stackoverflow.com\/questions\/2177836\/algorithm-for-creating-a-school-timetable\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/a>)<\/p>\n<figure class=\"bordered full-width\"><figcaption>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043f\u0440\u043e 4\u0445 \u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u0443\u0431. \u041d\u043e \u043a\u0430\u043a \u043e\u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u2013 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0430\u0442\u044c\u0438<\/figcaption><\/figure>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043a\u043e \u043c\u043d\u0435 \u0432 \u0440\u0443\u043a\u0438 \u043f\u043e\u043f\u0430\u043b \u043f\u0430\u043a\u0435\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044f IBM CPLEX Solver \u0438 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u043a\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f.   <\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0440\u0435\u0448\u0438\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u0443\u044e, \u0435\u0449\u0435 \u0435\u0451 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <a href=\"https:\/\/www.ibm.com\/docs\/en\/icos\/20.1.0?topic=optimization-solving-mixed-integer-programming-problems-mip\" rel=\"noopener noreferrer nofollow\">MIP<\/a>.<\/p>\n<h2>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043b\u0438\u0446 \u0443 \u043d\u0430\u0441 \u0447\u0435\u0442\u044b\u0440\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0441\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442. \u0422.\u0435. \u043d\u0430\u0448\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0431\u0443\u0434\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u043c. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0438\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p align=\"center\"><strong>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0441\u0438<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p align=\"center\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 dat \u0444\u0430\u0439\u043b\u0435<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p>\u043a\u043b\u0430\u0441\u0441\u044b \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432<\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p>5\u0430 \u0438\u043b\u0438 9\u0431<\/p>\n<\/td>\n<td>\n<p>classes = {&#171;5a&#187;, &#171;5b&#187;, &#171;6a&#187;, &#171;6b&#187;, &#171;7a&#187;, &#171;7b&#187;, &#171;8a&#187;, &#171;8b&#187;, &#171;9a&#187;, &#171;9b&#187;,&#187;10a&#187;, &#171;10b&#187;, &#171;11a&#187;, &#171;11b&#187;};<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p>\u0443\u0447\u0438\u0442\u0435\u043b\u044f<\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p>\u0418\u0432\u0430\u043d\u043e\u0432\u0430 \u041c\u0430\u0440\u0438\u044f \u0418\u0432\u0430\u043d\u043e\u0432\u043d\u0430, \u041f\u0435\u0442\u0440\u043e\u0432\u0430 \u0422\u0430\u0442\u044c\u044f\u043d\u0430 \u0421\u0435\u0440\u0433\u0435\u0435\u0432\u043d\u0430 \u0438 \u0442.\u0434.<\/p>\n<\/td>\n<td>\n<p>teachers = {&#171;ivanova&#187;, &#171;petrova_en&#187;, &#171;sidorova_ge&#187;, &#171;shumova&#187;, &#171;trudovik_m&#187;, &#171;trudovik_w&#187;, &#171;stoprtteacher&#187;};   <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p>\u043a\u0430\u0431\u0438\u043d\u0435\u0442\u044b   <\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p>\u044d\u0442\u043e \u043f\u0440\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043d\u0430\u0442\u044b: 101 \u043a\u0430\u0431\u0438\u043d\u0435\u0442, \u0441\u043f\u043e\u0440\u0442. \u0437\u0430\u043b, \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u0442\u0440\u0443\u0434\u0430 \u2116 105, \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u0444\u0438\u0437\u0438\u043a\u0438 \u2116 205 \u0438 \u0442.\u0434.<\/p>\n<\/td>\n<td>\n<p>rooms = {&#171;18&#187;, &#171;sport1&#187;, &#171;trudy_m&#187;, &#171;trudy_w&#187; , &#171;21&#187;,&#187;22&#8243;,&#187;23&#8243;,&#187;24&#8243;, &#171;25&#187;, &#171;26&#187;, &#171;27&#187;, &#171;31&#187;,&#187;32&#8243;,&#187;33&#8243;,&#187;34&#8243;};<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"128\" width=\"128\">\n<p>\u0443\u0440\u043e\u043a\u0438<\/p>\n<\/td>\n<td data-colwidth=\"223\" width=\"223\">\n<p>\u044d\u0442\u043e \u0432\u0430\u043a\u0430\u043d\u0442\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0432 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043a\u0430\u043a 3\u0445-\u0437\u043d\u0430\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c<\/p>\n<p>\u043f\u0435\u0440\u0432\u0430\u044f \u0446\u0438\u0444\u0440\u0430 \u2013 \u044d\u0442\u043e \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f \u043e\u0442 1 \u0434\u043e 6, \u0435\u0441\u043b\u0438 \u0443\u0447\u0430\u0442\u0441\u044f \u043f\u043e \u0448\u0435\u0441\u0442\u0438\u0434\u043d\u0435\u0432\u043a\u0435 \u0438 \u0434\u043e 5, \u0435\u0441\u043b\u0438 \u043f\u043e \u043f\u044f\u0442\u0438\u0434\u043d\u0435\u0432\u043a\u0435   <\/p>\n<p>\u0432\u0442\u043e\u0440\u044f \u0446\u0438\u0444\u0440\u0430 \u2013 \u043d\u043e\u043c\u0435\u0440 \u0441\u043c\u0435\u043d\u044b 1 \u0438\u043b\u0438 2   <\/p>\n<p>\u0442\u0440\u0435\u0442\u044c\u044f \u0446\u0438\u0444\u0440\u0430 \u2013 \u043d\u043e\u043c\u0435\u0440 \u0443\u0440\u043e\u043a\u0430 \u0432 \u0441\u043c\u0435\u043d\u0435. \u041e\u0431\u044b\u0447\u043d\u043e \u043e\u0442 1 \u0434\u043e 6 \u0438\u043b\u0438 \u0434\u043e 7   <\/p>\n<\/td>\n<td>\n<p>\/\/ day,  shift, lesson number<br \/> lessons = {<br \/> 111, 112, 113, 114, 115, 116, 117, 121, 122, 123, 124, 125, 126, 127\/\/,<br \/> 211, 212, 213, 214, 215, 216, 217, 221, 222, 223, 224, 225, 226, 227,<br \/> 311, 312, 313, 314, 315, 316, 317, 321, 322, 323, 324, 325, 326, 327,<br \/> 411, 412, 413, 414, 415, 416, 417, 421, 422, 423, 424, 425, 426, 427,<br \/> 511, 512, 513, 514, 515, 516, 517, 521, 522, 523, 524, 525, 526, 527,<br \/> 611, 612, 613, 614, 615, 616, 617, 621, 622, 623, 624, 625, 626, 627<br \/> };<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041c\u0435\u0436\u0434\u0443 \u043e\u0441\u044f\u043c\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u0418 \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u044d\u0442\u0438 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u041e\u043d\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0412 \u044d\u0442\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435:   <\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p align=\"center\"><strong>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p align=\"center\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 dat \u0444\u0430\u0439\u043b\u0435<\/strong> <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u043c\u0438 \u0438 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438<\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e >= 0. \u0415\u0441\u043b\u0438 \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u041d\u0415 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u2013 \u0442\u043e 0. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0444\u0438\u0437\u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0443 \u0432 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438. \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0432 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u0444\u0438\u0437\u0438\u043a\u0438. \u0422\u0443\u0442 \u0431\u0443\u0434\u0435\u043c \u0438\u0433\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430\u043c\u0438. 1 \u2013 \u0441\u0430\u043c\u044b\u0439 \u043b\u0443\u0447\u0448\u0438\u0439 \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0447\u0438\u0442\u0435\u043b\u044f. 2 \u2013 \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0445\u043e\u0440\u043e\u0448\u0438\u0439, 3 \u2013 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0439, \u043d\u043e \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0435\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e \u0432 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.   <\/p>\n<\/td>\n<td>\n<p>roomTeachersRelation = [<br \/> [2,1,1,1,0,0,0],<br \/> [0,0,0,0,0,0,1],<br \/> [0,0,0,0,1,0,0],<br \/> [0,0,0,0,0,1,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [1,2,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0],<br \/> [2,1,1,1,0,0,0]<br \/> ];<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432<\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p>\u0422\u0443\u0442 \u043f\u0438\u0448\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u043a\u043e\u0432 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0418\u0432\u0430\u043d\u043e\u0432\u0430 \u041c.\u0418. \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 4 \u0440\u0443\u0441\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u0430 \u0438 2 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u0443 6 \u0411 \u043a\u043b\u0430\u0441\u0441\u0430. \u0417\u043d\u0430\u0447\u0438\u0442 \u0432 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u043f\u0438\u0448\u0435\u043c \u0446\u0438\u0444\u0440\u0443 4 + 2\u00a0 = 6<\/p>\n<\/td>\n<td>\n<p>teacherClassRelation = [<br \/> [2,1,0,0,1,1,0,0,0,0,0,0,0,0],<br \/> [0,0,1,1,0,1,0,0,0,0,0,0,0,0],<br \/> [0,0,1,0,1,0,0,1,1,0,0,0,1,0],<br \/> [0,0,0,0,0,0,1,0,0,0,0,2,0,0],<br \/> [0,0,0,1,0,0,1,0,0,1,1,0,1,1],<br \/> [0,0,0,1,0,0,1,0,0,1,1,0,1,1],<br \/> [1,0,1,0,1,0,0,1,1,0,0,1,0,0]<br \/> ];<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432 \u0438 \u0443\u0440\u043e\u043a\u0430\u043c\u0438 <\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b 0 \u0438\u043b\u0438 1. \u0410 \u0442\u043e\u0447\u043d\u0435\u0435 \u0442\u0443\u0442 \u043c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u043c\u0435\u043d\u0435 \u0443\u0447\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441. \u0415\u0441\u043b\u0438 0 \u2013 \u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0443\u0440\u043e\u043a\u0438 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f.   <\/p>\n<\/td>\n<td>\n<p>classLessonRelation = [<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [1,1,1,1,1,1,1,0,0,0,0,0,0,0],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1],<br \/> [0,0,0,0,0,0,0,1,1,1,1,1,1,1]<br \/> ];<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"135\" width=\"135\">\n<p>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0443\u0440\u043e\u043a\u0430<\/p>\n<\/td>\n<td data-colwidth=\"319\" width=\"319\">\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b 0 \u0438\u043b\u0438 1. \u0415\u0441\u043b\u0438 \u0441\u0442\u043e\u0438\u0442 0 \u2013 \u0437\u043d\u0430\u0447\u0438\u0442 \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0443\u0440\u043e\u043a\u0438 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f. \u042d\u0442\u043e \u043d\u0430 \u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0434\u043d\u0438 \u043d\u0435\u0434\u0435\u043b\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c\u0438 \u0434\u0435\u0442\u044c\u043c\u0438 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e \u0441\u0443\u0431\u0431\u043e\u0442\u0430\u043c.<\/p>\n<\/td>\n<td>\n<p>teacherLessonRelation = [<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,1,1,1],<br \/> [1,1,1,1,1,1,1,1,1,1,1,0,0,0]<br \/> ];<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 (4 \u043e\u0441\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0438 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438) \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043a\u0430\u043a \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u0443\u0431. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 4 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438 4 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u041c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u043e\u0432, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0443\u0440\u043e\u043a\u0438 \u0432 \u044d\u0442\u0438\u0445 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u0445. \u0418\u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0443\u0440\u043e\u043a\u0430 \u0438 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u0440\u0435\u0434\u0443. \u041d\u043e \u043f\u043e\u043a\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u043c\u0430\u043b\u044b\u043c.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/h2>\n<p>\u0412 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f 4\u0445 \u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c 0 \u0438\u043b\u0438 1.<\/p>\n<p>1 &#8212; \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0443\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. <\/p>\n<p>0 &#8212; \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f.<\/p>\n<pre><code class=\"java\">dvar int schedule [rooms][teachers][classes][lessons] in 0..1;<\/code><\/pre>\n<h2>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u0418\u043c\u0435\u044f \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0437\u0430\u0434\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f.<\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0441\u0442\u0440\u043e\u0433\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u043d\u0430\u0448\u0438\u0445 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u043b\u044c, \u0442\u043e \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u043e\u043b\u044c<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"java\">forall(  r in rooms,   t in teachers,   c in classes,   l in lessons   )  if(roomTeachersRelation[r][t] == 0 || teacherClassRelation[t][c] == 0 || classLessonRelation[c][l] == 0 || teacherLessonRelation[t][l] == 0)  {    schedule[r][t][c][l] == 0;    }   <\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432   <\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0437\u043d\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0440\u043e\u043a\u043e\u0432 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u0443 \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0443\u043c\u043c\u0430 \u0443\u0440\u043e\u043a\u043e\u0432 \u0432 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u0445 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u0430 \u0446\u0438\u0444\u0440\u0435 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f.   <\/p>\n<pre><code class=\"java\">\/\/ teacher - class relations forall( t in teachers, c in classes)  sum(r in rooms, l in lessons) schedule[r][t][c][l] == teacherClassRelation[t][c]; <\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u043c\u0438 \u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0443\u0440\u043e\u043a\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043e\u0434\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0443\u0440\u043e\u043a, \u0447\u0442\u043e \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e<\/p>\n<pre><code class=\"java\">\/\/ room - lesson relations  forall(r in rooms, l in lessons) sum(t in teachers, c in classes) schedule[r][t][c][l] &lt;= 1;<\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0443\u0440\u043e\u043a\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/p>\n<pre><code class=\"java\">\/\/ teacher - lesson relations   forall( t in teachers, l in lessons)      sum(r in rooms, c in classes)    schedule[r][t][c][l] &lt;= 1;<\/code><\/pre>\n<ul>\n<li>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432 \u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0443\u0440\u043e\u043a\u043e\u0432. \u042d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043a\u0430\u043a \u0438\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u0444\u0438\u0437\u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0430, \u0442\u0440\u0443\u0434\u044b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043a\u0430\u043a \u0440\u0435\u0448\u0435\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u043a\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0447\u0430\u0441\u0442\u043e \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b: \u0444\u0438\u0437\u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0430 \u0443 \u044e\u043d\u043e\u0448\u0435\u0439 \u0438 \u0434\u0435\u0432\u0443\u0448\u0435\u043a, \u0442\u0440\u0443\u0434\u044b \u0443 \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u043e\u0432 \u0438 \u0434\u0435\u0432\u043e\u0447\u0435\u043a, \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e \u044f\u0437\u044b\u043a\u0443 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0435.<\/p>\n<p>\u0423 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0442\u043e\u0436\u0435 \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0432\u0432\u0435\u0434\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u00ab\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0445\u00bb \u0443\u0447\u0438\u0442\u0435\u043b\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0438\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0433\u043e:<\/p>\n<pre><code class=\"java\">{string} foreignLangTeachers = ...;<\/code><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0432 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443 \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0443\u0447\u0438\u0442\u0435\u043b\u0435\u0439 \u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u0445.<\/p>\n<pre><code class=\"java\">  \/\/ class - lesson relations forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in foreignLangTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in foreignLangTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in trudyTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in trudyTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in informaticsTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in informaticsTeachers)    schedule[r][t][c][l] &lt;= 2;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t not in sportTeachers)    schedule[r][t][c][l] &lt;= 1;    forall( c in classes, l in lessons )      sum(r in rooms, t in teachers : t in sportTeachers)    schedule[r][t][c][l] &lt;= 2;<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0426\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/h2>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043c\u0430\u0442. \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0422.\u0435. \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043a \u0447\u0435\u043c\u0443 \u043c\u044b \u0441\u0442\u0440\u0435\u043c\u0438\u043c\u0441\u044f. \u0422\u0443\u0442 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0438\u0445 \u0432\u0430\u0436\u043d\u043e. \u041f\u0435\u0440\u0432\u043e\u0435, \u044d\u0442\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0440\u043e\u043a\u0438 \u0434\u043b\u044f \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0432 \u0441\u0443\u0442\u043a\u0430\u0445. \u0422.\u0435. \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438 \u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0440\u043e\u043a\u0430 \u0441\u0432\u043e\u0435\u0439 \u0441\u043c\u0435\u043d\u044b. \u0412\u0442\u043e\u0440\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435, \u044d\u0442\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0440\u0430\u043d\u044c\u0448\u0435. \u0422\u0440\u0435\u0442\u044c\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0438\u0442\u0435\u043b\u044f \u0432\u0435\u043b\u0438 \u0443\u0440\u043e\u043a\u0438 \u0432 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0445 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430\u0445. \u041d\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>minimize  staticLex(  sum(c in classes, l in lessons) (  ClassLessonResult [c][l] * l  )    , sum(t in teachers, l in lessons) (  TeacherLessonResult [t][l] * l  ) , sum(r in rooms, t in teachers, c in classes, l in lessons) schedule[r][t][c][l] * roomTeachersRelation[r][t]    ) ;<\/code><\/pre>\n<h2>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432 OPL Studio \u044f \u0432\u0432\u0435\u043b\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/p>\n<pre><code>dvar int TeacherLessonResult[teachers][lessons] ; dvar int ClassLessonResult[classes][lessons] ; dvar int RoomLessonResult[rooms][lessons]; dvar int TeacherClassResult [teachers][classes]; dvar int RoomClassResult [rooms][classes]; dvar int RoomTeacherResult [rooms][teachers];<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/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-329004","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329004","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=329004"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329004\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}