{"id":382568,"date":"2024-06-29T04:21:47","date_gmt":"2024-06-29T04:21:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=382568"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T04:21:47","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=382568","title":{"rendered":"<span>PULP \u0411\u0416\u0423<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/3ee\/2e7\/00a\/3ee2e700a3e1bceb700ad38d5fb069f0.jpg\" width=\"780\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3ee\/2e7\/00a\/3ee2e700a3e1bceb700ad38d5fb069f0.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u0430\u0440\u0442\u043e\u0444\u0435\u043b\u044c \u0444\u0440\u0438, \u043a\u043e\u0442\u043b\u0435\u0442\u0430, \u0445\u043b\u0435\u0431, \u043f\u043e\u043c\u0438\u0434\u043e\u0440, \u043e\u0433\u0443\u0440\u0435\u0446 \u0438 \u043c\u043e\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c. \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u044a\u0435\u0441\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 30 \u0433\u0440. \u0431\u0435\u043b\u043a\u0430, 25 \u0433\u0440. \u0436\u0438\u0440\u043e\u0432 \u0438 60 \u0433\u0440. \u0443\u0433\u043b\u0435\u0432\u043e\u0434\u043e\u0432? \u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u044f \u0431\u0430\u043b\u043e\u0432\u0430\u043b\u0441\u044f \u0438 \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/post\/576348\/\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u0442\u0440\u0438\u0446<\/a>, \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 &#8212; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0438 python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/coin-or\/pulp\" rel=\"noopener noreferrer nofollow\">PuLP<\/a>.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e PuLP (Python Linear programming)<\/h2>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e. <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e 0 &lt;= x &lt;= 3, \u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439: <\/p>\n<pre><code>x = LpVariable(\"x\", 0, 3)<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439  0 &lt;= y &lt;= 1:<\/p>\n<pre><code>y = LpVariable(\"y\", 0, 1)<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f LpProblem()  \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<pre><code>prob = LpProblem(\"\u041c\u043e\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043a\u0430\", LpMinimize)<\/code><\/pre>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0438\u0445 \u0432 \u0437\u0430\u0434\u0430\u0447\u0443:<\/p>\n<pre><code>prob += x + y &lt;= 2<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (\u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435), \u043e\u043d\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0446\u0435\u043b\u044c\u044e: (\u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435 If you add an expression (not a constraint), it will become the objective:)<\/p>\n<pre><code>prob += -4*x + y<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 &#171;\u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044c&#187;:<\/p>\n<pre><code>status = prob.solve()<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>LpStatus[status] > 'Optimal'<\/code><\/pre>\n<p>\u0418 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>value(x) > 2.0<\/code><\/pre>\n<p>\u041f\u043e\u043b\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f\u00a0<a href=\"https:\/\/coin-or.github.io\/pulp\/\" rel=\"noopener noreferrer nofollow\">https:\/\/coin-or.github.io\/pulp\/<\/a>.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PuLP \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434<\/h2>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0431\u0435\u043b\u043a\u0430\u043c\u0438, \u0436\u0438\u0440\u0430\u043c\u0438 \u0438 \u0443\u0433\u043b\u0435\u0432\u043e\u0434\u0430\u043c\u0438 ( \u0411\u0416\u0423) \u043d\u0430 100 \u0433\u0440. \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430:<\/p>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\">\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p><strong>\u0411\u0435\u043b\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>\u0416\u0438\u0440\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>\u0423\u0433\u043b\u0435\u0432\u043e\u0434\u044b<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041a\u0430\u0440\u0442\u043e\u0444\u0435\u043b\u044c \u0444\u0440\u0438<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>3,4<\/p>\n<\/td>\n<td>\n<p>15<\/p>\n<\/td>\n<td>\n<p>41<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041a\u043e\u0442\u043b\u0435\u0442\u0430<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>14,1<\/p>\n<\/td>\n<td>\n<p>15,7<\/p>\n<\/td>\n<td>\n<p>6,6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u0425\u043b\u0435\u0431<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>8,8<\/p>\n<\/td>\n<td>\n<p>3,3<\/p>\n<\/td>\n<td>\n<p>46,7<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041f\u043e\u043c\u0438\u0434\u043e\u0440<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>1,1<\/p>\n<\/td>\n<td>\n<p>0,2<\/p>\n<\/td>\n<td>\n<p>3,8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041e\u0433\u0443\u0440\u0435\u0446<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>0,8<\/p>\n<\/td>\n<td>\n<p>0,1<\/p>\n<\/td>\n<td>\n<p>2,5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>6<\/p>\n<\/td>\n<td>\n<p>5<\/p>\n<\/td>\n<td>\n<p>45<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c:<\/p>\n<pre><code class=\"bash\">pip install pulp<\/code><\/pre>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c:<\/p>\n<pre><code class=\"python\">import pulp as pl   data = {     '\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430 \u0444\u0440\u0438': {'\u0411': 3.4, '\u0416': 15,  '\u0423': 41},     '\u041a\u043e\u0442\u043b\u0435\u0442\u0430': {'\u0411': 14.1, '\u0416': 15.7, '\u0423':      6.6},     '\u0425\u043b\u0435\u0431': {'\u0411': 8.8, '\u0416': 3.3, '\u0423':  46.7},     '\u041f\u043e\u043c\u0438\u0434\u043e\u0440': {'\u0411': 1.1,  '\u0416': 0.2, '\u0423': 3.8},     '\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c': {'\u0411': 6, '\u0416': 5, '\u0423': 45},     '\u041e\u0433\u0443\u0440\u0435\u0446': {'\u0411': 0.8, '\u0416': 0.1, '\u0423': 2.5}, }   # \u041c\u0430\u043a\u0440\u043e\u043d\u0443\u0442\u0440\u0438\u0435\u043d\u0442\u044b (\u0411\u0416\u0423), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c needed = {'\u0411': 30, '\u0416': 25, '\u0423': 60}  # \u041c\u0438\u043d\u0438\u043c\u0443\u043c 10 \u0433\u0440. \u043d\u0430\u0434\u043e \u0441\u044a\u0435\u0441\u0442\u044c, \u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f\u043c\u0438 # \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e MIN = 0.1 # \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c 150 \u0433\u0440. MAX = 1.5   prob = pl.LpProblem(\"The Nutrients Problem\", pl.LpMinimize) # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 food = pl.LpVariable.dicts('Food', data, MIN, MAX) for nutrient in list('\u0411\u0416\u0423'):     # \u0414\u043b\u044f \u0431\u0435\u043b., \u0436\u0438\u0440\u043e\u0432 \u0438 \u0443\u0433\u043b. \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f     prob += pl.lpSum([data[k][nutrient] * food[k]                       for k in data]) == needed[nutrient]  prob.writeLP(\"Nutrients.lp\") prob.solve()  # \u041d\u0435\u043b\u044c\u0437\u044f \u0441\u044a\u0435\u0441\u0442\u044c -\u043c\u0438\u043d\u0443\u0441 10 \u0433\u0440. \u043e\u0433\u0443\u0440\u0446\u043e\u0432. \u0417\u043d\u0430\u0447\u0438\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435\u0442, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044c 1 # \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 if any((v.varValue or 0) &lt; 0 for v in prob.variables()) is False:     for v in prob.variables():         if not v.varValue:             continue         name = v.name.replace('Food_', '')         weight = int(v.varValue*100)         print(f'{name}: {weight} \u0433\u0440.')<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 (\u043e\u043d\u0430 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430):<\/p>\n<pre><code class=\"python\">prob.writeLP(\"Nutrients.lp\")<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u0430\u0439\u043b Nutrients.pl,  \u0435\u0441\u043b\u0438 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c \u043d\u0435\u0433\u043e, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e:<\/p>\n<pre><code>\\* The_Nutrients_Problem *\\ Minimize OBJ: __dummy Subject To _C1: 3.4 Food_\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430_\u0444\u0440\u0438 + 14.1 Food_\u041a\u043e\u0442\u043b\u0435\u0442\u0430 + 6 Food_\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439_\u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c  + 0.8 Food_\u041e\u0433\u0443\u0440\u0435\u0446 + 1.1 Food_\u041f\u043e\u043c\u0438\u0434\u043e\u0440 + 8.8 Food_\u0425\u043b\u0435\u0431 = 30 _C2: 15 Food_\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430_\u0444\u0440\u0438 + 15.7 Food_\u041a\u043e\u0442\u043b\u0435\u0442\u0430 + 5 Food_\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439_\u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c  + 0.1 Food_\u041e\u0433\u0443\u0440\u0435\u0446 + 0.2 Food_\u041f\u043e\u043c\u0438\u0434\u043e\u0440 + 3.3 Food_\u0425\u043b\u0435\u0431 = 25 _C3: 41 Food_\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430_\u0444\u0440\u0438 + 6.6 Food_\u041a\u043e\u0442\u043b\u0435\u0442\u0430 + 45 Food_\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439_\u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c  + 2.5 Food_\u041e\u0433\u0443\u0440\u0435\u0446 + 3.8 Food_\u041f\u043e\u043c\u0438\u0434\u043e\u0440 + 46.7 Food_\u0425\u043b\u0435\u0431 = 60 Bounds  0.1 &lt;= Food_\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430_\u0444\u0440\u0438 &lt;= 1.5  0.1 &lt;= Food_\u041a\u043e\u0442\u043b\u0435\u0442\u0430 &lt;= 1.5  0.1 &lt;= Food_\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439_\u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c &lt;= 1.5  0.1 &lt;= Food_\u041e\u0433\u0443\u0440\u0435\u0446 &lt;= 1.5  0.1 &lt;= Food_\u041f\u043e\u043c\u0438\u0434\u043e\u0440 &lt;= 1.5  0.1 &lt;= Food_\u0425\u043b\u0435\u0431 &lt;= 1.5  __dummy = 0 End<\/code><\/pre>\n<h4>\u041e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h4>\n<p>\u0415\u0441\u0442\u044c \u0431\u0430\u0439\u043a\u0430, \u0447\u0442\u043e \u0434\u0440\u0435\u0432\u043d\u0438\u0435 \u0440\u0438\u043c\u043b\u044f\u043d\u0435 \u0445\u043e\u0434\u0438\u043b\u0438 \u0441 \u0433\u0443\u0441\u0438\u043d\u044b\u043c \u043f\u0435\u0440\u044b\u0448\u043a\u043e\u043c \u043d\u0430 \u043f\u0438\u0440, \u0447\u0442\u043e\u0431\u044b \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0449\u0435\u043a\u043e\u0442\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0433\u043e\u0440\u043b\u043e, \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0436\u0435\u043b\u0443\u0434\u043e\u043a \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043f\u0438\u0440\u0448\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043b\u044c\u0448\u0435. \u041d\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0431\u044b \u041c\u0438\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u0434\u0440\u0435\u0432\u043d\u0435\u0439 \u0440\u0438\u043c\u043b\u044f\u043d\u043a\u043e\u0439, \u0438 \u0445\u043e\u0434\u0438\u043b\u0430 \u0441 \u043f\u0435\u0440\u043e\u043c, \u0442\u043e \u044d\u0442\u043e \u0431\u044b \u0435\u0439 \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u043e, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u0434\u0430\u0441\u0442 \u0441\u044a\u0435\u0441\u0442\u044c &#8212; \u043c\u0438\u043d\u0443\u0441 100 \u0433\u0440\u0430\u043c\u043c \u043a\u0430\u0440\u0442\u043e\u0448\u043a\u0438 \u0444\u0440\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043b \u0432 \u043a\u043e\u0434\u0435 \u0442\u0430\u043a\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438. <\/p>\n<p>\u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/Alexmod\/macronutrients\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431<\/a><\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u041c\u0438\u0430 \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u0432\u0435\u0441\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0441 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u044b\u043c\u0438 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0438 \u0441 \u044f\u0441\u043d\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c 30 \u0433\u0440. \u0431\u0435\u043b\u043a\u0430, 25 \u0433\u0440. \u0436\u0438\u0440\u043e\u0432 \u0438 60 \u0433\u0440. \u0443\u0433\u043b\u0435\u0432\u043e\u0434\u043e\u0432, \u0442\u043e \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u0441\u044a\u0435\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430 \u0444\u0440\u0438: 10 \u0433\u0440. <\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u0442\u043b\u0435\u0442\u0430: 128 \u0433\u0440. <\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c: 10 \u0433\u0440. (<s>\u041f\u043e\u0441\u043b\u0435 \u0412\u0438\u043d\u0441\u0435\u043d\u0442\u0430 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0435\u0433\u043e \u043f\u0438\u0442\u044c<\/s>)<\/p>\n<\/li>\n<li>\n<p>\u041e\u0433\u0443\u0440\u0435\u0446: 150 \u0433\u0440. <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043c\u0438\u0434\u043e\u0440: 150 \u0433\u0440. <\/p>\n<\/li>\n<li>\n<p>\u0425\u043b\u0435\u0431: 71 \u0433\u0440.<\/p>\n<\/li>\n<\/ul>\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\/578796\/\"> https:\/\/habr.com\/ru\/articles\/578796\/<\/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<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u0430\u0440\u0442\u043e\u0444\u0435\u043b\u044c \u0444\u0440\u0438, \u043a\u043e\u0442\u043b\u0435\u0442\u0430, \u0445\u043b\u0435\u0431, \u043f\u043e\u043c\u0438\u0434\u043e\u0440, \u043e\u0433\u0443\u0440\u0435\u0446 \u0438 \u043c\u043e\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c. \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u044a\u0435\u0441\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 30 \u0433\u0440. \u0431\u0435\u043b\u043a\u0430, 25 \u0433\u0440. \u0436\u0438\u0440\u043e\u0432 \u0438 60 \u0433\u0440. \u0443\u0433\u043b\u0435\u0432\u043e\u0434\u043e\u0432? \u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u044f \u0431\u0430\u043b\u043e\u0432\u0430\u043b\u0441\u044f \u0438 \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/post\/576348\/\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u0442\u0440\u0438\u0446<\/a>, \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 &#8212; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0438 python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/coin-or\/pulp\" rel=\"noopener noreferrer nofollow\">PuLP<\/a>.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e PuLP (Python Linear programming)<\/h2>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e. <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e 0 &lt;= x &lt;= 3, \u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439: <\/p>\n<pre><code>x = LpVariable(\"x\", 0, 3)<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439  0 &lt;= y &lt;= 1:<\/p>\n<pre><code>y = LpVariable(\"y\", 0, 1)<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f LpProblem()  \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<pre><code>prob = LpProblem(\"\u041c\u043e\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043a\u0430\", LpMinimize)<\/code><\/pre>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0438\u0445 \u0432 \u0437\u0430\u0434\u0430\u0447\u0443:<\/p>\n<pre><code>prob += x + y &lt;= 2<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (\u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435), \u043e\u043d\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0446\u0435\u043b\u044c\u044e: (\u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435 If you add an expression (not a constraint), it will become the objective:)<\/p>\n<pre><code>prob += -4*x + y<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 &#171;\u0440\u0435\u0448\u0430\u0442\u0435\u043b\u044c&#187;:<\/p>\n<pre><code>status = prob.solve()<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>LpStatus[status] > 'Optimal'<\/code><\/pre>\n<p>\u0418 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>value(x) > 2.0<\/code><\/pre>\n<p>\u041f\u043e\u043b\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f\u00a0<a href=\"https:\/\/coin-or.github.io\/pulp\/\" rel=\"noopener noreferrer nofollow\">https:\/\/coin-or.github.io\/pulp\/<\/a>.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PuLP \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434<\/h2>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0431\u0435\u043b\u043a\u0430\u043c\u0438, \u0436\u0438\u0440\u0430\u043c\u0438 \u0438 \u0443\u0433\u043b\u0435\u0432\u043e\u0434\u0430\u043c\u0438 ( \u0411\u0416\u0423) \u043d\u0430 100 \u0433\u0440. \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430:<\/p>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\">\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p><strong>\u0411\u0435\u043b\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>\u0416\u0438\u0440\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>\u0423\u0433\u043b\u0435\u0432\u043e\u0434\u044b<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041a\u0430\u0440\u0442\u043e\u0444\u0435\u043b\u044c \u0444\u0440\u0438<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>3,4<\/p>\n<\/td>\n<td>\n<p>15<\/p>\n<\/td>\n<td>\n<p>41<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041a\u043e\u0442\u043b\u0435\u0442\u0430<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>14,1<\/p>\n<\/td>\n<td>\n<p>15,7<\/p>\n<\/td>\n<td>\n<p>6,6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u0425\u043b\u0435\u0431<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>8,8<\/p>\n<\/td>\n<td>\n<p>3,3<\/p>\n<\/td>\n<td>\n<p>46,7<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041f\u043e\u043c\u0438\u0434\u043e\u0440<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>1,1<\/p>\n<\/td>\n<td>\n<p>0,2<\/p>\n<\/td>\n<td>\n<p>3,8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041e\u0433\u0443\u0440\u0435\u0446<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>0,8<\/p>\n<\/td>\n<td>\n<p>0,1<\/p>\n<\/td>\n<td>\n<p>2,5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c<\/p>\n<\/td>\n<td data-colwidth=\"178\" width=\"178\">\n<p>6<\/p>\n<\/td>\n<td>\n<p>5<\/p>\n<\/td>\n<td>\n<p>45<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c:<\/p>\n<pre><code class=\"bash\">pip install pulp<\/code><\/pre>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c:<\/p>\n<pre><code class=\"python\">import pulp as pl   data = {     '\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430 \u0444\u0440\u0438': {'\u0411': 3.4, '\u0416': 15,  '\u0423': 41},     '\u041a\u043e\u0442\u043b\u0435\u0442\u0430': {'\u0411': 14.1, '\u0416': 15.7, '\u0423':      6.6},     '\u0425\u043b\u0435\u0431': {'\u0411': 8.8, '\u0416': 3.3, '\u0423':  46.7},     '\u041f\u043e\u043c\u0438\u0434\u043e\u0440': {'\u0411': 1.1,  '\u0416': 0.2, '\u0423': 3.8},     '\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c': {'\u0411': 6, '\u0416': 5, '\u0423': 45},     '\u041e\u0433\u0443\u0440\u0435\u0446': {'\u0411': 0.8, '\u0416': 0.1, '\u0423': 2.5}, }   # \u041c\u0430\u043a\u0440\u043e\u043d\u0443\u0442\u0440\u0438\u0435\u043d\u0442\u044b (\u0411\u0416\u0423), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c needed = {'\u0411': 30, '\u0416': 25, '\u0423': 60}  # \u041c\u0438\u043d\u0438\u043c\u0443\u043c 10 \u0433\u0440. \u043d\u0430\u0434\u043e \u0441\u044a\u0435\u0441\u0442\u044c, \u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f\u043c\u0438 # \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e MIN = 0.1 # \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c 150 \u0433\u0440. MAX = 1.5   prob = pl.LpProblem(\"The Nutrients Problem\", pl.LpMinimize) # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 food = pl.LpVariable.dicts('Food', data, MIN, MAX) for nutrient in list('\u0411\u0416\u0423'):     # \u0414\u043b\u044f \u0431\u0435\u043b., \u0436\u0438\u0440\u043e\u0432 \u0438 \u0443\u0433\u043b. \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f     prob += pl.lpSum([data[k][nutrient] * food[k]                       for k in data]) == needed[nutrient]  prob.writeLP(\"Nutrients.lp\") prob.solve()  # \u041d\u0435\u043b\u044c\u0437\u044f \u0441\u044a\u0435\u0441\u0442\u044c -\u043c\u0438\u043d\u0443\u0441 10 \u0433\u0440. \u043e\u0433\u0443\u0440\u0446\u043e\u0432. \u0417\u043d\u0430\u0447\u0438\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435\u0442, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044c 1 # \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 if any((v.varValue or 0) &lt; 0 for v in prob.variables()) is False:     for v in prob.variables():         if not v.varValue:             continue         name = v.name.replace('Food_', '')         weight = int(v.varValue*100)         print(f'{name}: {weight} \u0433\u0440.')<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 (\u043e\u043d\u0430 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430):<\/p>\n<pre><code class=\"python\">prob.writeLP(\"Nutrients.lp\")<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u0430\u0439\u043b Nutrients.pl,  \u0435\u0441\u043b\u0438 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c \u043d\u0435\u0433\u043e, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e:<\/p>\n<pre><code>\\* The_Nutrients_Problem *\\ Minimize OBJ: __dummy Subject To _C1: 3.4 Food_\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430_\u0444\u0440\u0438 + 14.1 Food_\u041a\u043e\u0442\u043b\u0435\u0442\u0430 + 6 Food_\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439_\u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c  + 0.8 Food_\u041e\u0433\u0443\u0440\u0435\u0446 + 1.1 Food_\u041f\u043e\u043c\u0438\u0434\u043e\u0440 + 8.8 Food_\u0425\u043b\u0435\u0431 = 30 _C2: 15 Food_\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430_\u0444\u0440\u0438 + 15.7 Food_\u041a\u043e\u0442\u043b\u0435\u0442\u0430 + 5 Food_\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439_\u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c  + 0.1 Food_\u041e\u0433\u0443\u0440\u0435\u0446 + 0.2 Food_\u041f\u043e\u043c\u0438\u0434\u043e\u0440 + 3.3 Food_\u0425\u043b\u0435\u0431 = 25 _C3: 41 Food_\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430_\u0444\u0440\u0438 + 6.6 Food_\u041a\u043e\u0442\u043b\u0435\u0442\u0430 + 45 Food_\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439_\u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c  + 2.5 Food_\u041e\u0433\u0443\u0440\u0435\u0446 + 3.8 Food_\u041f\u043e\u043c\u0438\u0434\u043e\u0440 + 46.7 Food_\u0425\u043b\u0435\u0431 = 60 Bounds  0.1 &lt;= Food_\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430_\u0444\u0440\u0438 &lt;= 1.5  0.1 &lt;= Food_\u041a\u043e\u0442\u043b\u0435\u0442\u0430 &lt;= 1.5  0.1 &lt;= Food_\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439_\u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c &lt;= 1.5  0.1 &lt;= Food_\u041e\u0433\u0443\u0440\u0435\u0446 &lt;= 1.5  0.1 &lt;= Food_\u041f\u043e\u043c\u0438\u0434\u043e\u0440 &lt;= 1.5  0.1 &lt;= Food_\u0425\u043b\u0435\u0431 &lt;= 1.5  __dummy = 0 End<\/code><\/pre>\n<h4>\u041e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h4>\n<p>\u0415\u0441\u0442\u044c \u0431\u0430\u0439\u043a\u0430, \u0447\u0442\u043e \u0434\u0440\u0435\u0432\u043d\u0438\u0435 \u0440\u0438\u043c\u043b\u044f\u043d\u0435 \u0445\u043e\u0434\u0438\u043b\u0438 \u0441 \u0433\u0443\u0441\u0438\u043d\u044b\u043c \u043f\u0435\u0440\u044b\u0448\u043a\u043e\u043c \u043d\u0430 \u043f\u0438\u0440, \u0447\u0442\u043e\u0431\u044b \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0449\u0435\u043a\u043e\u0442\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0433\u043e\u0440\u043b\u043e, \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0436\u0435\u043b\u0443\u0434\u043e\u043a \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043f\u0438\u0440\u0448\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043b\u044c\u0448\u0435. \u041d\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0431\u044b \u041c\u0438\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u0434\u0440\u0435\u0432\u043d\u0435\u0439 \u0440\u0438\u043c\u043b\u044f\u043d\u043a\u043e\u0439, \u0438 \u0445\u043e\u0434\u0438\u043b\u0430 \u0441 \u043f\u0435\u0440\u043e\u043c, \u0442\u043e \u044d\u0442\u043e \u0431\u044b \u0435\u0439 \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u043e, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u0434\u0430\u0441\u0442 \u0441\u044a\u0435\u0441\u0442\u044c &#8212; \u043c\u0438\u043d\u0443\u0441 100 \u0433\u0440\u0430\u043c\u043c \u043a\u0430\u0440\u0442\u043e\u0448\u043a\u0438 \u0444\u0440\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043b \u0432 \u043a\u043e\u0434\u0435 \u0442\u0430\u043a\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438. <\/p>\n<p>\u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/Alexmod\/macronutrients\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431<\/a><\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u041c\u0438\u0430 \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u0432\u0435\u0441\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0441 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u044b\u043c\u0438 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0438 \u0441 \u044f\u0441\u043d\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c 30 \u0433\u0440. \u0431\u0435\u043b\u043a\u0430, 25 \u0433\u0440. \u0436\u0438\u0440\u043e\u0432 \u0438 60 \u0433\u0440. \u0443\u0433\u043b\u0435\u0432\u043e\u0434\u043e\u0432, \u0442\u043e \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u0441\u044a\u0435\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041a\u0430\u0440\u0442\u043e\u0448\u043a\u0430 \u0444\u0440\u0438: 10 \u0433\u0440. <\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u0442\u043b\u0435\u0442\u0430: 128 \u0433\u0440. <\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043a\u0442\u0435\u0439\u043b\u044c: 10 \u0433\u0440. (<s>\u041f\u043e\u0441\u043b\u0435 \u0412\u0438\u043d\u0441\u0435\u043d\u0442\u0430 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0435\u0433\u043e \u043f\u0438\u0442\u044c<\/s>)<\/p>\n<\/li>\n<li>\n<p>\u041e\u0433\u0443\u0440\u0435\u0446: 150 \u0433\u0440. <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043c\u0438\u0434\u043e\u0440: 150 \u0433\u0440. <\/p>\n<\/li>\n<li>\n<p>\u0425\u043b\u0435\u0431: 71 \u0433\u0440.<\/p>\n<\/li>\n<\/ul>\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\/578796\/\"> https:\/\/habr.com\/ru\/articles\/578796\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-382568","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/382568","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=382568"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/382568\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}