def primal_simplex_auxiliar_pl(matrix,base_columns,original_matrix): c_index = find_c_negative(matrix) unlimited_control = 0 if (c_index is not None): # We still have negative (-c) entries in tableaux line_index = find_pivot_primal_simplex(matrix,c_index) if (line_index is not None): # We have, in column c_index chosen, positive values in matrix A pivoting(matrix,line_index,c_index) base_columns[line_index] = c_index elif(matrix[0,c_index] < 0 ): #situação de pl ilimitada pass unlimited_control = 1 else: raise "Error - Choose c_index = 0, with an entire column less than or equal to zero" if(unlimited_control != 1): simplex_state = verify_state_primal_simplex(matrix) if(simplex_state): if ( (matrix[0,-1]) == 0 ): prepare_for_primal_simplex(matrix,original_matrix,base_columns) else: non_viability_certificate( matrix,base_columns) return elif(simplex_state is None): # Do simple dual pass else: primal_simplex_auxiliar_pl(matrix,base_columns,original_matrix)
def primal_simplex(matrix, base_columns): unlimited_control = False c_index = find_c_negative(matrix) if (c_index is not None): # We still have negative (-c) entries in tableaux line_index = find_pivot_primal_simplex(matrix, c_index) if ( line_index is not None ): # We have, in column c_index chosen, positive values in matrix A pivoting(matrix, line_index, c_index) base_columns[line_index] = c_index elif (matrix[0, c_index] < 0): # We haven't positive values in matrix A unlimited_control = True unlimited_certificate(matrix, c_index, base_columns) else: raise "Error - Choose c_index = 0, with an entire column less than or equal to zero" if (not unlimited_control): simplex_state = verify_state_primal_simplex(matrix) if (simplex_state): optimal_situation(matrix, base_columns) return elif (simplex_state is None): # Do simple dual pass else: primal_simplex(matrix, base_columns)
def dual_simplex(matrix,base_columns): inviability = False b_index = find_b_negative(matrix) if(b_index is not None): # We still have negative entries of b in tableaux column_index = find_pivot_dual_simplex(matrix,b_index) if(column_index is not None):# We have, in the line b_index chosen, negative values of A pivoting(matrix,b_index,column_index) base_columns[b_index] = column_index else: # Situation of inviability PL - positive A input with negative B input and X> = 0 inviability = True non_viability_certificate(matrix,base_columns) if(not inviability): simplex_state = verify_state_dual_simplex(matrix) if(simplex_state): optimal_situation(matrix,base_columns) return elif(simplex_state is None): # Do Auxiliary PL pass else: dual_simplex(matrix,base_columns)