mercredi 8 septembre 2021

How to draw a conclusion from several statements?

import numpy as np

#Input the number of columns and rows of the interval matrix A and its elements.
rows_a = int(input("Enter the number of rows of matrix A : " ))
column_a = int(input("Enter the number of columns of matrix A: "))

print("Enter the elements of the lower bound matrix A:")
lowerboundA= [[float(input())  for i in range(column_a)] for j in range(rows_a)]
print("Lower bound matrix A=: ")
for n in lowerboundA:
    print(n)
    
print("Enter the elements of the upper bound matrix A:")
upperboundA= [[float(input())  for i in range(column_a)] for j in range(rows_a)]
print("Upper bound matrix A=: ")
for m in upperboundA:
    print(m)

#Input the number of columns and rows of the interval matrix C and its elements.
rows_c = int(input("Enter the number of rows matrix C : " ))
column_c = int(input("Enter the number of columns in the matrix C: "))

print("Input the elements of the lower bound matrix C:")
lowerboundC= [[float(input()) for i in range(column_c)] for j in range(rows_c)]
print("Lower bound matrix C=: ")
for n in lowerboundC:
    print(n)   
    
print("Input the elements of the upper bound matrix C:")
upperboundC= [[float(input()) for i in range(column_c)] for j in range(rows_c)]
print("upper bound matrix C =: ")
for m in upperboundC:
    print(m) 
        
#Input the elements of the interval matrix B
print("Input the elements of the lower bound matrix B:")
lowerboundB= [[float(input()) for i in range(column_c)] for j in range(rows_a)]
print("Lower bound Matrix B=: ")
for n in lowerboundB:
    print(n)
   
print("Input the elements of the upper bound matrix B:")
upperboundB= [[float(input()) for i in range(column_c)] for j in range(rows_a)]
print("Upper bound matrix B=: ")
for m in upperboundB:
    print(m) 
            
#all input
ubA = np.array(upperboundA)
ubAT= np.transpose(ubA)
lbA = np.array(lowerboundA)
lbAT= np.transpose(lbA)
ubC = np.array(upperboundC)
ubCT= np.transpose(ubC)
lbC = np.array(lowerboundC)
lbCT= np.transpose(lbC)
ubB = np.array(upperboundB)
ubCT= np.transpose(ubC)
lbB = np.array(lowerboundB)
lbBT= np.transpose(lbB)   

def entry0(matrixM, matrixN, i):
    matrixA = matrixN.copy()
    matrixA[i]= matrixM[i]
    return matrixA
def entry1(matrixM, matrixN, j):
    matrixC = matrixN.copy()
    matrixC[:,j]= matrixM[:,j]
    return matrixC
def entry2(matrixM, matrixN, i, j):
    matrixB = matrixN.copy()
    matrixB[i][j] = matrixM[i][j]
    return matrixB

for p in range(rows_a):
    for u in range(column_c):
        print( f"\n*****\np = {p+1}, u = {u+1}\n*****" )
            

#Determine the matrix A(p)
        Ap = entry0( lbA,ubA, p)
        ApT = entry0( lbA,ubA, p).transpose()
        print("Matrix A(p)=: ")
        print(Ap)
            
#Determine the matrix   C(u) 
        Cu = entry1( lbC,ubC, u)    
        CuT = entry1( lbC,ubC, u).transpose()
        print("Matrix C(u)=: ")
        print(CuT)

#Determine the matrix  B(pu)
            
        Bpu = entry2(ubB, lbB, p, u)
        print("Matrix B(pu)=: ")
        print(Bpu)
        
#Determine the matrix X*(A,B)
        XAb = np.array([[min(-a+b for a, b in zip(column_a , rows_c)) 
                    for rows_c  in zip(*Bpu)]
                            for column_a in ApT])
        print("\nX*(A,b) =: ") 
        print(XAb)
        
#Determine the matrix  X*(A,B,C)    
        X = np.array([[min(-a+b for b,a in zip(rows_c , column_a)) 
                    for column_a  in zip(*CuT)]
                            for rows_c in XAb])
        print("\nX*(A,b,c) =: ") 
        print(X)

#Determine the matrix A.X*(A,B,C)     
        AX = np.array([[max(a+b for a,b in zip(rows_a , column_c)) 
                    for rows_a  in zip(*X)]
                            for column_c in Ap])
        print("\nA(p).X*(A,b,c) =: ") 
        print(AX)
        
#Determine the matrix A.X*(A,B,C).C    
        AXC = np.array([[max(a+b for a,b in zip(rows_a , column_c)) 
                    for rows_a  in zip(*Cu)]
                            for column_c in AX])
        print("\nA(p).X*(A,b,c).C(u) =: ") 
        print(AXC)
            
#conclusion
        if (np.allclose(AXC,Bpu)==True):
            print("A(p).X*(A,b,c).C(u) = B(pu)");  
        else:
            print("A(p).X*(A,b,c).C(u) not equal B(pu)"); 

The conclusions in the code above are the conclusion for each p and u. Based on these conclusions I want to make a final conclusion is if for all p and u have conclusion that the matrix is equal then the final conclusion is the equal matrix but if for every u and p there is a conclusion that the matrix is not equal then the final conclusion is the matrix is not equal. In other words, I want to deduce the conclusion from each of p and u. How?

Aucun commentaire:

Enregistrer un commentaire