def prepare_for_primal_simplex(matrix,original_matrix,base_columns):
	
	end_c = matrix.shape[1]-matrix.shape[0]-1
	original_matrix = parse_to_fpi(original_matrix)


	original_matrix = put_tableux_form(original_matrix)
	original_matrix[1:original_matrix.shape[0], 0:end_c ] = matrix[1:matrix.shape[0], 0:end_c ]
	original_matrix[1:original_matrix.shape[0], -1 ] = matrix[1:matrix.shape[0], -1]
	
	original_matrix = put_canonical_form(original_matrix,base_columns)

	solve_primal_simplex(original_matrix,base_columns)
def simplex(matrix):
    method = verify_method(matrix)

    if method == 0:
        return solve_primal_simplex(matrix)
    elif method == 1:
        return solve_dual_simplex(matrix)
    else:
        return solve_auxiliary_lp(matrix)
def main():
    f = open(sys.argv[1], 'r')

    lines = int(f.readline()) + 1		#Wrong test input. Sum +1 was required
    columns = int(f.readline()) + 1

    matrix_str = f.readline()
    matrix = np.array(np.mat(matrix_str).reshape(lines,columns),dtype=float)
    matrix = matrix.astype('object')

    method = verify_method(matrix)

    if method == 0:
        solve_primal_simplex(matrix)
    elif method == 1:
        solve_dual_simplex(matrix)
    else:
        solve_auxiliary_lp(matrix)
    f.close()