{"id":361315,"date":"2024-05-21T01:11:12","date_gmt":"2024-05-21T01:11:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=361315"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=361315","title":{"rendered":"<span>\u041b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u043c\u0435\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <strong><em>v<\/em><\/strong>, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <strong><em>a<\/em><\/strong> \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c <strong><em>b<\/em><\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\begin{equation*}   300x_5+80x_6-1219x_7-x_8 \\rightarrow  max \\\\   x_2-8x_5-2x_6+30x_7+\\frac{1}{2}x_8 = 0 \\\\   x_1+\\frac{19}{2}x_5+\\frac{5}{2}x_6-38x_7-\\frac{2}{3}x_8=0 \\\\   x_3+40x_5-3x_6+90x_7+x_8=1 \\\\   x_4+x_8=1\\\\ x_1,x_2,\u2026,x_8\\ge0 \\end{equation*}\" alt=\"\\begin{equation*}   300x_5+80x_6-1219x_7-x_8 \\rightarrow  max \\\\   x_2-8x_5-2x_6+30x_7+\\frac{1}{2}x_8 = 0 \\\\   x_1+\\frac{19}{2}x_5+\\frac{5}{2}x_6-38x_7-\\frac{2}{3}x_8=0 \\\\   x_3+40x_5-3x_6+90x_7+x_8=1 \\\\   x_4+x_8=1\\\\ x_1,x_2,\u2026,x_8\\ge0 \\end{equation*}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/14f\/3c1\/276\/14f3c1276d40a92c0cecef28828d5950.svg\" width=\"331\" height=\"191\"\/><\/p>\n<pre><code class=\"python\">import pandas as pd #\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u043c\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446 import copy<\/code><\/pre>\n<pre><code class=\"python\">v = [0.,0.,0.,0.,300.,80.,-1219.,-1.] a = [[0,1,0,0,-8,-2,30,1\/2],      [1,0,0,0,19\/2,5\/2,-38,-2\/3],      [0,0,1,0,40,-3,90,1],      [0,0,0,1,0,0,0,1] ] b = [0,0,1,1]<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e \u0432\u0435\u043a\u0442\u043e\u0440-\u0441\u0442\u0440\u043e\u043a\u0430\u043c.<\/p>\n<pre><code class=\"python\">def rev(lst):     return [ -i for i in lst ]<\/code><\/pre>\n<pre><code class=\"python\">lin_prog = a lin_prog.insert(4,rev(v)) lin_prog[4].insert(0,0) for x in range(4):   lin_prog[x].insert(0,b[x]) task = pd.DataFrame(columns = ['X_','X1','X2','X3','X4','X5','X6','X7','X8'],data = lin_prog) print(task)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/58f\/1bd\/f46\/58f1bdf46d67d3b3a877cce2e22457ae.png\" alt=\"\u0412\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" title=\"\u0412\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" width=\"590\" height=\"142\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/58f\/1bd\/f46\/58f1bdf46d67d3b3a877cce2e22457ae.png\"\/><\/p>\n<div><figcaption>\u0412\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430\u0448\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u0435. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0446\u0438\u043a\u043b \u0441 \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u0448\u0438\u0445 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044f.  <\/p>\n<pre><code class=\"python\">def iter(a):   max_x = 0   max_y = 0   while a[4][max_x]>=0:     max_x+=1     if max_x>8:        print('\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e')       return a   for x in range(max_x,9):     if abs(a[4][x])>abs(a[4][max_x]) and a[4][x]&lt;0 and a[4][x]!=0 and  a[1][x]>=0 and  a[2][x]>=0 and  a[3][x]>=0 :        max_x = x   while a[max_y][max_x]&lt;=0:     max_y+=1   for y in range(5):     if a[y][max_x] &lt;=0: continue     if a[y][max_x]>0 and abs(a[y][0]\/a[y][max_x])&lt;abs(a[max_y][0]\/a[max_y][max_x]): max_y = y   b = copy.deepcopy(a)   for i in range(5):     for j in range(9):       if i==max_y:         b[i][j]= a[i][j]\/a[max_y][max_x]       if i!=max_y: b[i][j]=a[i][j]- a[i][max_x]*a[max_y][j]\/a[max_y][max_x]   return b<\/code><\/pre>\n<pre><code class=\"python\">lin_prog_iter = copy.deepcopy(lin_prog) for x in range(7):   print(str(x)+' ITERATION\\n')   df = pd.DataFrame(columns = ['X_','X1','X2','X3','X4','X5','X6','X7','X8'],data = lin_prog_iter)   print(df,'\\n\\n')   lin_prog_iter=iter(lin_prog_iter)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e7d\/f04\/273\/e7df042737778087573351b2a8ea968d.png\" alt=\"0 - 3 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430\" title=\"0 - 3 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430\" width=\"687\" height=\"631\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e7d\/f04\/273\/e7df042737778087573351b2a8ea968d.png\"\/><\/p>\n<div><figcaption>0 &#8212; 3 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3b8\/5d5\/b5c\/3b85d5b5c8f817cab493c7570839b6e7.png\" alt=\"5 \u0438 6 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430\" title=\"5 \u0438 6 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430\" width=\"699\" height=\"420\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3b8\/5d5\/b5c\/3b85d5b5c8f817cab493c7570839b6e7.png\"\/><\/p>\n<div><figcaption>5 \u0438 6 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430\u00a0<strong>7 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438<\/strong>\u00a0\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0438\u043c\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e\u00a0<strong>\u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u0435<\/strong>. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044d\u0442\u043e\u043c\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435\u00a0<strong>X_<\/strong>\u00a0\u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043e\u0431\u043d\u0443\u043b\u044f\u044e\u0449\u0438\u0445 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438.  <\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f\u00a0<strong>\u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434<\/strong>. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439.  <\/p>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440 q \u2013\u00a0<strong>\u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u043d<\/strong>\u00a0(q>0), \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u0442 \u043d\u0443\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u043d.  <\/p>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440 q\u00a0<strong>\u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435<\/strong>\u00a0\u0432\u0435\u043a\u0442\u043e\u0440\u0430 p (q>p), \u0435\u0441\u043b\u0438 q-p>0. <\/p>\n<p>\u0421\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b, \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u00a0<strong>\u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439<\/strong>.  <\/p>\n<p><code>\u041b\u0435\u043c\u043c\u0430:<\/code>\u00a0\u0415\u0441\u043b\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u0430, \u0430 \u043d\u043e\u043c\u0435\u0440\u0430 \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0438\u0437 \u0431\u0430\u0437\u0438\u0441\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0442\u0430\u043a\u043e\u0432\u044b, \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<p><img class=\"formula\" source=\"\\begin{align}  \\vec{\\mathbf{S}}_r= (\\frac{\\mathbf{X}r0}{\\mathbf{X}rs}, ..., \\frac{\\mathbf{X}r0}{\\mathbf{X}rs}) &amp; = lexmin_{x_{sk>0}}\\{\\vec{\\mathbf{S}}_k\\}\\\\ (1) \\end{align}&#187; alt=&#187;\\begin{align}  \\vec{\\mathbf{S}}_r= (\\frac{\\mathbf{X}r0}{\\mathbf{X}rs}, &#8230;, \\frac{\\mathbf{X}r0}{\\mathbf{X}rs}) &amp; = lexmin_{x_{sk>0}}\\{\\vec{\\mathbf{S}}_k\\}\\\\ (1) \\end{align}&#187; src=&#187;https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e7\/610\/b63\/7e7610b63e1e9aa41a328aedfd6c2619.svg&#187; width=&#187;354&#8243; height=&#187;69&#8243;\/><\/p>\n<p>\u0442\u043e \u043d\u043e\u0432\u0430\u044f \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439.<\/p>\n<p><code>\u0422\u0435\u043e\u0440\u0435\u043c\u0430:<\/code>\u00a0\u0415\u0441\u043b\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0438\u0437 \u0431\u0430\u0437\u0438\u0441\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 (1), \u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0434\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0443 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0432\u0435\u0440\u0445\u0443, \u043a\u043e\u043d\u0435\u0447\u043d\u043e.  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0442\u0435\u043e\u0440\u0438\u044e, \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439.  <\/p>\n<pre><code class=\"python\">def iter_lex(a):   max_x = 0   max_y = 0   while a[4][max_x]>=0:     max_x+=1     if max_x>8:        print('\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e')       return a   for x in range(max_x,9):     if abs(a[4][x])>abs(a[4][max_x]) and a[4][x]&lt;0 and a[4][x]!=0 and  a[1][x]>=0 and  a[2][x]>=0 and  a[3][x]>=0 :        max_x = x   while a[max_y][max_x]&lt;=0:     max_y+=1   for y in range(5):     if a[y][max_x] &lt;=0: continue     if a[y][max_x]>0 and abs(a[y][0]\/a[y][max_x])&lt;abs(a[max_y][0]\/a[max_y][max_x]): max_y = y     if a[y][max_x]>0 and abs(a[y][0]\/a[y][max_x])==abs(a[max_y][0]\/a[max_y][max_x]):       for i in range(1,5):           if a[y][max_x]>0 and abs(a[y][i]\/a[y][max_x])==abs(a[max_y][i]\/a[max_y][max_x]): pass           if a[y][max_x]>0 and abs(a[y][i]\/a[y][max_x])&lt;abs(a[max_y][i]\/a[max_y][max_x]):              max_y = y             break   b = copy.deepcopy(a)   for i in range(5):     for j in range(9):       if i==max_y:         b[i][j]= a[i][j]\/a[max_y][max_x]       if i!=max_y: b[i][j]=a[i][j]- a[i][max_x]*a[max_y][j]\/a[max_y][max_x]   return b<\/code><\/pre>\n<pre><code>lin_prog_iter = copy.deepcopy(lin_prog) for x in range(4):   print(str(x)+' ITERATION\\n')   df = pd.DataFrame(columns = ['X_','X1','X2','X3','X4','X5','X6','X7','X8'],data = lin_prog_iter)   print(df,'\\n\\n')   lin_prog_iter=iter_lex(lin_prog_iter)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/52a\/df2\/bcd\/52adf2bcd7d96b0055ffb4154a407ddf.png\" alt=\"\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430\" title=\"\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430\" width=\"673\" height=\"686\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/52a\/df2\/bcd\/52adf2bcd7d96b0055ffb4154a407ddf.png\"\/><\/p>\n<div><figcaption>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e!<\/strong>  <\/p>\n<p><strong>\u0412\u044b\u0432\u043e\u0434:<\/strong>\u00a0\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u0446\u0438\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0434\u043b\u044f \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439.<\/p>\n<p>ipynb \u0444\u0430\u0439\u043b \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<div class=\"embed_link\">\n<div class=\"embed__thumb\" style=\"background-image: url(&quot;https:\/\/opengraph.githubassets.com\/2dd6d7b81053b9bbb6cade72c84d34668326780d7cd63142fcd75b92c96a861d\/Happynood\/lin_prog&quot;);\"><\/div>\n<div class=\"embed__caption\">\n<div class=\"embed__caption-title\"><span>GitHub &#8212; Happynood\/lin_prog: Implementation of the lexicographic simplex method in Python<\/span><\/div>\n<p><a href=\"https:\/\/github.com\/Happynood\/lin_prog\" target=\"_blank\" rel=\"noopener noreferrer nofollow\" class=\"embed__caption-link\">github.com<\/a><\/div>\n<\/div>\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\/776694\/\"> https:\/\/habr.com\/ru\/articles\/776694\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u043c\u0435\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <strong><em>v<\/em><\/strong>, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <strong><em>a<\/em><\/strong> \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c <strong><em>b<\/em><\/strong>.<\/p>\n<pre><code class=\"python\">import pandas as pd #\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u043c\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446 import copy<\/code><\/pre>\n<pre><code class=\"python\">v = [0.,0.,0.,0.,300.,80.,-1219.,-1.] a = [[0,1,0,0,-8,-2,30,1\/2],      [1,0,0,0,19\/2,5\/2,-38,-2\/3],      [0,0,1,0,40,-3,90,1],      [0,0,0,1,0,0,0,1] ] b = [0,0,1,1]<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e \u0432\u0435\u043a\u0442\u043e\u0440-\u0441\u0442\u0440\u043e\u043a\u0430\u043c.<\/p>\n<pre><code class=\"python\">def rev(lst):     return [ -i for i in lst ]<\/code><\/pre>\n<pre><code class=\"python\">lin_prog = a lin_prog.insert(4,rev(v)) lin_prog[4].insert(0,0) for x in range(4):   lin_prog[x].insert(0,b[x]) task = pd.DataFrame(columns = ['X_','X1','X2','X3','X4','X5','X6','X7','X8'],data = lin_prog) print(task)<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430\u0448\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u0435. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0446\u0438\u043a\u043b \u0441 \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u0448\u0438\u0445 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044f.  <\/p>\n<pre><code class=\"python\">def iter(a):   max_x = 0   max_y = 0   while a[4][max_x]>=0:     max_x+=1     if max_x>8:        print('\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e')       return a   for x in range(max_x,9):     if abs(a[4][x])>abs(a[4][max_x]) and a[4][x]&lt;0 and a[4][x]!=0 and  a[1][x]>=0 and  a[2][x]>=0 and  a[3][x]>=0 :        max_x = x   while a[max_y][max_x]&lt;=0:     max_y+=1   for y in range(5):     if a[y][max_x] &lt;=0: continue     if a[y][max_x]>0 and abs(a[y][0]\/a[y][max_x])&lt;abs(a[max_y][0]\/a[max_y][max_x]): max_y = y   b = copy.deepcopy(a)   for i in range(5):     for j in range(9):       if i==max_y:         b[i][j]= a[i][j]\/a[max_y][max_x]       if i!=max_y: b[i][j]=a[i][j]- a[i][max_x]*a[max_y][j]\/a[max_y][max_x]   return b<\/code><\/pre>\n<pre><code class=\"python\">lin_prog_iter = copy.deepcopy(lin_prog) for x in range(7):   print(str(x)+' ITERATION\\n')   df = pd.DataFrame(columns = ['X_','X1','X2','X3','X4','X5','X6','X7','X8'],data = lin_prog_iter)   print(df,'\\n\\n')   lin_prog_iter=iter(lin_prog_iter)<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>0 &#8212; 3 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>5 \u0438 6 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430\u00a0<strong>7 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438<\/strong>\u00a0\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0438\u043c\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e\u00a0<strong>\u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u0435<\/strong>. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044d\u0442\u043e\u043c\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435\u00a0<strong>X_<\/strong>\u00a0\u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043e\u0431\u043d\u0443\u043b\u044f\u044e\u0449\u0438\u0445 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438.  <\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f\u00a0<strong>\u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434<\/strong>. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439.  <\/p>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440 q \u2013\u00a0<strong>\u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u043d<\/strong>\u00a0(q>0), \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u0442 \u043d\u0443\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u043d.  <\/p>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440 q\u00a0<strong>\u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435<\/strong>\u00a0\u0432\u0435\u043a\u0442\u043e\u0440\u0430 p (q>p), \u0435\u0441\u043b\u0438 q-p>0. <\/p>\n<p>\u0421\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b, \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u00a0<strong>\u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439<\/strong>.  <\/p>\n<p><code>\u041b\u0435\u043c\u043c\u0430:<\/code>\u00a0\u0415\u0441\u043b\u0438 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u0430, \u0430 \u043d\u043e\u043c\u0435\u0440\u0430 \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0438\u0437 \u0431\u0430\u0437\u0438\u0441\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0442\u0430\u043a\u043e\u0432\u044b, \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<p>0}}\\{\\vec{\\mathbf{S}}_k\\}\\\\ (1) \\end{align}&#187; alt=&#187;\\begin{align}  \\vec{\\mathbf{S}}_r= (\\frac{\\mathbf{X}r0}{\\mathbf{X}rs}, &#8230;, \\frac{\\mathbf{X}r0}{\\mathbf{X}rs}) &amp; = lexmin_{x_{sk>0}}\\{\\vec{\\mathbf{S}}_k\\}\\\\ (1) \\end{align}&#187; src=&#187;https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e7\/610\/b63\/7e7610b63e1e9aa41a328aedfd6c2619.svg&#187; width=&#187;354&#8243; height=&#187;69&#8243;\/><\/p>\n<p>\u0442\u043e \u043d\u043e\u0432\u0430\u044f \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439.<\/p>\n<p><code>\u0422\u0435\u043e\u0440\u0435\u043c\u0430:<\/code>\u00a0\u0415\u0441\u043b\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0438\u0437 \u0431\u0430\u0437\u0438\u0441\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 (1), \u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0434\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0443 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0432\u0435\u0440\u0445\u0443, \u043a\u043e\u043d\u0435\u0447\u043d\u043e.  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0442\u0435\u043e\u0440\u0438\u044e, \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439.  <\/p>\n<pre><code class=\"python\">def iter_lex(a):   max_x = 0   max_y = 0   while a[4][max_x]>=0:     max_x+=1     if max_x>8:        print('\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e')       return a   for x in range(max_x,9):     if abs(a[4][x])>abs(a[4][max_x]) and a[4][x]&lt;0 and a[4][x]!=0 and  a[1][x]>=0 and  a[2][x]>=0 and  a[3][x]>=0 :        max_x = x   while a[max_y][max_x]&lt;=0:     max_y+=1   for y in range(5):     if a[y][max_x] &lt;=0: continue     if a[y][max_x]>0 and abs(a[y][0]\/a[y][max_x])&lt;abs(a[max_y][0]\/a[max_y][max_x]): max_y = y     if a[y][max_x]>0 and abs(a[y][0]\/a[y][max_x])==abs(a[max_y][0]\/a[max_y][max_x]):       for i in range(1,5):           if a[y][max_x]>0 and abs(a[y][i]\/a[y][max_x])==abs(a[max_y][i]\/a[max_y][max_x]): pass           if a[y][max_x]>0 and abs(a[y][i]\/a[y][max_x])&lt;abs(a[max_y][i]\/a[max_y][max_x]):              max_y = y             break   b = copy.deepcopy(a)   for i in range(5):     for j in range(9):       if i==max_y:         b[i][j]= a[i][j]\/a[max_y][max_x]       if i!=max_y: b[i][j]=a[i][j]- a[i][max_x]*a[max_y][j]\/a[max_y][max_x]   return b<\/code><\/pre>\n<pre><code>lin_prog_iter = copy.deepcopy(lin_prog) for x in range(4):   print(str(x)+' ITERATION\\n')   df = pd.DataFrame(columns = ['X_','X1','X2','X3','X4','X5','X6','X7','X8'],data = lin_prog_iter)   print(df,'\\n\\n')   lin_prog_iter=iter_lex(lin_prog_iter)<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e!<\/strong>  <\/p>\n<p><strong>\u0412\u044b\u0432\u043e\u0434:<\/strong>\u00a0\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u0446\u0438\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0434\u043b\u044f \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439.<\/p>\n<p>ipynb \u0444\u0430\u0439\u043b \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<div class=\"embed_link\">\n<div class=\"embed__thumb\" style=\"background-image: url(&quot;https:\/\/opengraph.githubassets.com\/2dd6d7b81053b9bbb6cade72c84d34668326780d7cd63142fcd75b92c96a861d\/Happynood\/lin_prog&quot;);\"><\/div>\n<div class=\"embed__caption\">\n<div class=\"embed__caption-title\"><span>GitHub &#8212; Happynood\/lin_prog: Implementation of the lexicographic simplex method in Python<\/span><\/div>\n<p><a href=\"https:\/\/github.com\/Happynood\/lin_prog\" target=\"_blank\" rel=\"noopener noreferrer nofollow\" class=\"embed__caption-link\">github.com<\/a><\/div>\n<\/div>\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\/776694\/\"> https:\/\/habr.com\/ru\/articles\/776694\/<\/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-361315","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/361315","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=361315"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/361315\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=361315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=361315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=361315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}