Advertisement
Oppaceted

main

May 20th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. from drawing import *
  2. from reduction_to_canonical_form import *
  3. from CreateW import CreateW
  4. from os import system
  5.  
  6.  
  7. N = int(input("Введите число переменных: "))
  8. M = int(input("Введите количество уравнения: "))
  9. Functional_koeff = []
  10. for i in range(N):
  11. Functional_koeff.append(float(input(f"L_{i+1}: ") ) )
  12. print("f = ", end= "")
  13. ShowFunctional(N, Functional_koeff)
  14. B = [] #вектор
  15. A = [] #матрица
  16.  
  17. for i in range(M):
  18. A.append([])
  19. for j in range(N):
  20. A[i].append("*")
  21.  
  22. for i in range(M):
  23. for j in range(N):
  24. system("cls")
  25. ShowMatrixElement(A, i, j)
  26. A[i][j]=(float(input(f"A_{i+1,j+1}=")))
  27. system("cls")
  28. ShowMatrixElement(A, -1, -1)
  29. input()
  30. system("cls")
  31. for i in range(M):
  32. B.append(float(input(f"B_{i+1}=")))
  33.  
  34.  
  35. print(A)#отладка
  36. print(B)#отладка
  37. input()
  38. while(True):
  39. system("cls")
  40. enter = input('Определите ограничение: ')
  41. if(enter == "Больше"):
  42. more = True
  43. break
  44. elif(enter == "Меньше"):
  45. more = False
  46. break
  47. #more = True if enter == "Больше" else False if enter == "Меньше" else exit(0)
  48. #Это тернарный оператор. Он нужен, чтобы писать в одну стрчоку вместо нескольких
  49.  
  50. for i in range(M):
  51. for j in range(N):
  52. print(f"{A[i][j]}x_{j+1}", end = " ")
  53. print(end=( (f"\u2265 {B[i]}\n" if more else f"\u2264 {B[i]}\n" ) if (j == N-1) else "+ " ) )
  54. print("F = ", end ="");ShowFunctional(N, Functional_koeff)
  55.  
  56. SetToCanon(A, N, M, more)
  57. input()
  58. system("cls")
  59.  
  60. for i in range(M):
  61. for j in range( len( A[0] ) ):
  62. print(f"{A[i][j]}x_{j+1}", end = " ")
  63. if j != ( len(A[0])-1 ):
  64. print(end=" + ")
  65. print(f"={B[i]}", end="\n\n")
  66.  
  67. for i in range(M):
  68. for j in range( len( A[0] ) ):
  69. A[i][j] = A[i][j]*-1
  70.  
  71. headers = []
  72. for j in range(len(A[0])):
  73. headers.append(f'x_{j+1}')
  74. column = []
  75. for i in range(len(A)):
  76. column.append(f'y_{i+1}')
  77.  
  78. #W = []
  79. #ShowTable(A, B, W, column, headers)
  80. ShowTable(A, B, column, headers)
  81. for i in range(M):
  82. u=ChooseVariables(A, B, CreateW(A, B, column, headers))
  83. print(headers[u[1]])#отладка
  84. ChangeVariables(A, B, u[0], u[1], column, headers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement