Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from drawing import *
- from reduction_to_canonical_form import *
- from CreateW import *
- from os import system
- N = int(input("Введите число переменных: "))
- M = int(input("Введите количество уравнения: "))
- Functional_koeff = []
- for i in range(N):
- Functional_koeff.append(float(input(f"L_{i+1}: ") ) )
- print("f = ", end= "")
- ShowFunctional(N, Functional_koeff)
- B = [] #вектор
- A = [] #матрица
- for i in range(M):
- A.append([])
- for j in range(N):
- A[i].append("*")
- for i in range(M):
- for j in range(N):
- system("cls")
- ShowMatrixElement(A, i, j)
- A[i][j]=(float(input(f"A_{i+1,j+1}=")))
- system("cls")
- ShowMatrixElement(A, -1, -1)
- input()
- system("cls")
- for i in range(M):
- B.append(float(input(f"B_{i+1}=")))
- print(A)#отладка
- print(B)#отладка
- input()
- while(True):
- system("cls")
- enter = input('Определите ограничение: ')
- if(enter == "Больше"):
- more = True
- break
- elif(enter == "Меньше"):
- more = False
- break
- #more = True if enter == "Больше" else False if enter == "Меньше" else exit(0)
- #Это тернарный оператор. Он нужен, чтобы писать в одну стрчоку вместо нескольких
- for i in range(M):
- for j in range(N):
- print(f"{A[i][j]}x_{j+1}", end = " ")
- print(end=( (f"\u2265 {B[i]}\n" if more else f"\u2264 {B[i]}\n" ) if (j == N-1) else "+ " ) )
- print("F = ", end ="");ShowFunctional(N, Functional_koeff)
- SetToCanon(A, N, M, more)
- input()
- system("cls")
- for i in range(M):
- for j in range( len( A[0] ) ):
- print(f"{A[i][j]}x_{j+1}", end = " ")
- if j != ( len(A[0])-1 ):
- print(end=" + ")
- print(f"={B[i]}", end="\n\n")
- for i in range(M):
- for j in range( len( A[0] ) ):
- A[i][j] = A[i][j]*-1
- headers = []
- for j in range(len(A[0])):
- headers.append(f'x_{j+1}')
- column = []
- for i in range(len(A)):
- column.append(f'y_{i+1}')
- #W = []
- #ShowTable(A, B, W, column, headers)
- input_W = CreateW(A, B, column, headers)
- ShowTable(A, B, column, headers, input_W)
- for i in range(M):
- u=ChooseVariables(A, B, CreateW(A, B, column, headers))
- #print(headers[u[1]])#отладка
- ChangeVariables(A, B, u[0], u[1], column, headers, True)
- G = RemoveExtraVars(A, B, N, column, headers)
- A = G[0]
- B = G[1]
- column = G[2]
- headers = G[3]
- Functional_koeff = ChangeFunctional(column, Functional_koeff)
- input_F = CreateF(A, B, Functional_koeff)
- ShowTable(A, B, column, headers, input_F)
- count = 0
- while(CheckCondition(input_F) and count <= 20):
- count += 1
- u = ChooseVariables(A, B, input_F)
- ChangeVariables(A, B, u[0], u[1], column, headers, False, input_F)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement