Here is my python code for implementing ANP with pyanp package, what do you think about it, any problems with it? " import sys
import os
import json
from PySide6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
                               QTableWidget, QTableWidgetItem, QPushButton, QFileDialog,
                               QTabWidget, QSplitter, QLabel, QLineEdit, QComboBox, QMessageBox,
                               QTreeWidget, QTreeWidgetItem, QInputDialog, QListWidget)
from PySide6.QtGui import QAction, QIcon
from PySide6.QtCore import Qt, Signal, Slot
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from pyanp import *

class ANPMatrixWidget(QWidget):
    matrix_changed = Signal()

    def __init__(self, size, name):
        super().__init__()
        self.size = size
        self.name = name
        self.layout = QVBoxLayout(self)
        self.table = QTableWidget(size, size)
        self.layout.addWidget(QLabel(name))
        self.layout.addWidget(self.table)

        for i in range(size):
            for j in range(size):
                if i == j:
                    item = QTableWidgetItem("1")
                    item.setFlags(Qt.ItemIsEnabled)
                else:
                    item = QTableWidgetItem("1")
                self.table.setItem(i, j, item)

        self.table.itemChanged.connect(self.update_matrix)

    def update_matrix(self):
        for i in range(self.size):
            for j in range(self.size):
                if i != j:
                    try:
                        value = float(self.table.item(i, j).text())
                        self.table.item(j, i).setText(f"{1/value:.4f}")
                    except ValueError:
                        QMessageBox.warning(self, "Invalid Input", "Please enter a valid number.")
                        self.table.item(i, j).setText("1")
        self.matrix_changed.emit()

    def get_matrix(self):
        matrix = np.ones((self.size, self.size))
        for i in range(self.size):
            for j in range(self.size):
                matrix[i, j] = float(self.table.item(i, j).text())
        return matrix

class ANPVisualizationWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.layout = QVBoxLayout(self)
        self.figure = plt.figure(figsize=(8, 6))
        self.canvas = FigureCanvas(self.figure)
        self.layout.addWidget(self.canvas)

    def update_graph(self, anp_network):
        self.figure.clear()
        G = nx.DiGraph()
        
        colors = plt.cm.rainbow(np.linspace(0, 1, len(anp_network.clusters)))
        node_colors = {}
        
        for i, cluster in enumerate(anp_network.clusters):
            for node in cluster.nodes:
                G.add_node(node.name)
                node_colors[node.name] = colors[i]

        for connection in anp_network.connections:
            from_cluster, to_cluster = connection
            for from_node in from_cluster.nodes:
                for to_node in to_cluster.nodes:
                    G.add_edge(from_node.name, to_node.name)

        pos = nx.spring_layout(G)
        nx.draw(G, pos, with_labels=True, node_color=[node_colors[node] for node in G.nodes()],
                node_size=3000, font_size=8, font_weight='bold')

        self.canvas.draw()

class ANPMainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("ANP Application")
        self.setGeometry(100, 100, 1200, 800)

        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)
        self.main_layout = QVBoxLayout(self.central_widget)

        self.create_ribbon()
        self.create_main_area()

        self.anp_network = ANPNetwork("ANP Model")
        self.current_cluster = None
        self.current_matrix = None

    def create_ribbon(self):
        ribbon = QTabWidget()
        self.main_layout.addWidget(ribbon)

        home_tab = QWidget()
        home_layout = QHBoxLayout(home_tab)

        file_group = QWidget()
        file_layout = QVBoxLayout(file_group)
        new_button = QPushButton("New")
        new_button.setIcon(QIcon.fromTheme("document-new"))
        open_button = QPushButton("Open")
        open_button.setIcon(QIcon.fromTheme("document-open"))
        save_button = QPushButton("Save")
        save_button.setIcon(QIcon.fromTheme("document-save"))
        file_layout.addWidget(new_button)
        file_layout.addWidget(open_button)
        file_layout.addWidget(save_button)

        model_group = QWidget()
        model_layout = QVBoxLayout(model_group)
        add_cluster_button = QPushButton("Add Cluster")
        add_cluster_button.setIcon(QIcon.fromTheme("list-add"))
        add_node_button = QPushButton("Add Node")
        add_node_button.setIcon(QIcon.fromTheme("list-add"))
        add_connection_button = QPushButton("Add Connection")
        add_connection_button.setIcon(QIcon.fromTheme("list-add"))
        model_layout.addWidget(add_cluster_button)
        model_layout.addWidget(add_node_button)
        model_layout.addWidget(add_connection_button)

        calculate_group = QWidget()
        calculate_layout = QVBoxLayout(calculate_group)
        calculate_button = QPushButton("Calculate ANP")
        calculate_button.setIcon(QIcon.fromTheme("system-run"))
        calculate_layout.addWidget(calculate_button)

        home_layout.addWidget(file_group)
        home_layout.addWidget(model_group)
        home_layout.addWidget(calculate_group)

        ribbon.addTab(home_tab, "Home")

        new_button.clicked.connect(self.new_project)
        open_button.clicked.connect(self.open_project)
        save_button.clicked.connect(self.save_project)
        add_cluster_button.clicked.connect(self.add_cluster)
        add_node_button.clicked.connect(self.add_node)
        add_connection_button.clicked.connect(self.add_connection)
        calculate_button.clicked.connect(self.calculate_anp)

    def create_main_area(self):
        splitter = QSplitter(Qt.Horizontal)
        self.main_layout.addWidget(splitter)

        self.model_tree = QTreeWidget()
        self.model_tree.setHeaderLabel("ANP Model")
        self.model_tree.itemClicked.connect(self.select_model_item)

        self.matrix_area = QWidget()
        self.matrix_layout = QVBoxLayout(self.matrix_area)

        self.visualization = ANPVisualizationWidget()

        splitter.addWidget(self.model_tree)
        splitter.addWidget(self.matrix_area)
        splitter.addWidget(self.visualization)

    def new_project(self):
        self.anp_network = ANPNetwork("ANP Model")
        self.current_cluster = None
        self.current_matrix = None
        self.update_model_tree()
        self.update_matrix_area()
        self.visualization.update_graph(self.anp_network)

    def open_project(self):
        file_name, _ = QFileDialog.getOpenFileName(self, "Open Project", "", "JSON Files (*.json)")
        if file_name:
            with open(file_name, 'r') as f:
                data = json.load(f)
            self.anp_network = ANPNetwork.from_json(data)
            self.update_model_tree()
            self.visualization.update_graph(self.anp_network)

    def save_project(self):
        file_name, _ = QFileDialog.getSaveFileName(self, "Save Project", "", "JSON Files (*.json)")
        if file_name:
            data = self.anp_network.to_json()
            with open(file_name, 'w') as f:
                json.dump(data, f)

    def add_cluster(self):
        name, ok = QInputDialog.getText(self, "Add Cluster", "Enter cluster name:")
        if ok and name:
            self.anp_network.add_cluster(ANPCluster(name))
            self.update_model_tree()
            self.visualization.update_graph(self.anp_network)

    def add_node(self):
        if not self.anp_network.clusters:
            QMessageBox.warning(self, "Error", "Please add a cluster first.")
            return

        cluster_names = [cluster.name for cluster in self.anp_network.clusters]
        cluster_name, ok = QInputDialog.getItem(self, "Add Node", "Select cluster:", cluster_names, 0, False)
        
        if ok and cluster_name:
            node_name, ok = QInputDialog.getText(self, "Add Node", "Enter node name:")
            if ok and node_name:
                cluster = next(c for c in self.anp_network.clusters if c.name == cluster_name)
                cluster.add_node(ANPNode(node_name))
                self.update_model_tree()
                self.visualization.update_graph(self.anp_network)

    def add_connection(self):
        if len(self.anp_network.clusters) < 2:
            QMessageBox.warning(self, "Error", "Please add at least two clusters.")
            return

        cluster_names = [cluster.name for cluster in self.anp_network.clusters]
        from_cluster, ok1 = QInputDialog.getItem(self, "Add Connection", "From cluster:", cluster_names, 0, False)
        to_cluster, ok2 = QInputDialog.getItem(self, "Add Connection", "To cluster:", cluster_names, 0, False)

        if ok1 and ok2 and from_cluster and to_cluster:
            from_cluster_obj = next(c for c in self.anp_network.clusters if c.name == from_cluster)
            to_cluster_obj = next(c for c in self.anp_network.clusters if c.name == to_cluster)
            self.anp_network.add_connection(from_cluster_obj, to_cluster_obj)
            self.update_model_tree()
            self.visualization.update_graph(self.anp_network)

    def update_model_tree(self):
        self.model_tree.clear()
        root = QTreeWidgetItem(self.model_tree, [self.anp_network.name])
        
        for cluster in self.anp_network.clusters:
            cluster_item = QTreeWidgetItem(root, [cluster.name])
            for node in cluster.nodes:
                QTreeWidgetItem(cluster_item, [node.name])

        connections_item = QTreeWidgetItem(root, ["Connections"])
        for connection in self.anp_network.connections:
            QTreeWidgetItem(connections_item, [f"{connection[0].name} -> {connection[1].name}"])

        self.model_tree.expandAll()

    def select_model_item(self, item, column):
        if item.parent() is None:  # Root or Connections
            self.current_cluster = None
            self.current_matrix = None
        elif item.parent().text(0) == "Connections":
            from_cluster, to_cluster = item.text(0).split(" -> ")
            self.current_cluster = None
            self.current_matrix = (from_cluster, to_cluster)
        else:  # Cluster or Node
            self.current_cluster = item.parent().text(0) if item.parent().parent() else item.text(0)
            self.current_matrix = None

        self.update_matrix_area()

    def update_matrix_area(self):
        for i in reversed(range(self.matrix_layout.count())): 
            self.matrix_layout.itemAt(i).widget().setParent(None)

        if self.current_matrix:
            from_cluster, to_cluster = self.current_matrix
            from_cluster_obj = next(c for c in self.anp_network.clusters if c.name == from_cluster)
            to_cluster_obj = next(c for c in self.anp_network.clusters if c.name == to_cluster)
            
            matrix = self.anp_network.get_comparison_matrix(from_cluster_obj, to_cluster_obj)
            if matrix is None:
                matrix = np.ones((len(from_cluster_obj.nodes), len(to_cluster_obj.nodes)))
            
            matrix_widget = ANPMatrixWidget(matrix.shape[0], f"{from_cluster} -> {to_cluster}")
            matrix_widget.matrix_changed.connect(self.update_matrix)
            self.matrix_layout.addWidget(matrix_widget)

        elif self.current_cluster:
            cluster = next(c for c in self.anp_network.clusters if c.name == self.current_cluster)
            matrix = self.anp_network.get_inner_dependency_matrix(cluster)
            if matrix is None:
                matrix = np.eye(len(cluster.nodes))
            
            matrix_widget = ANPMatrixWidget(matrix.shape[0], f"{self.current_cluster} Inner Dependency")
            matrix_widget.matrix_changed.connect(self.update_matrix)
            self.matrix_layout.addWidget(matrix_widget)

    def update_matrix(self):
        if self.current_matrix:
            from_cluster, to_cluster = self.current_matrix
            from_cluster_obj = next(c for c in self.anp_network.clusters if c.name == from_cluster)
            to_cluster_obj = next(c for c in self.anp_network.clusters if c.name == to_cluster)
            
            matrix_widget = self.matrix_layout.itemAt(0).widget()
            self.anp_network.set_comparison_matrix(from_cluster_obj, to_cluster_obj, matrix_widget.get_matrix())
        
        elif self.current_cluster:
            cluster = next(c for c in self.anp_network.clusters if c.name == self.current_cluster)
            matrix_widget = self.matrix_layout.itemAt(0).widget()
            self.anp_network.set_inner_dependency_matrix(cluster, matrix_widget.get_matrix())

    def calculate_anp(self):
        try:
            results = self.anp_network.calculate()
            
            result_text = "ANP Results:\n\n"
            for cluster_name, node_results in results.items():
                result_text += f"{cluster_name}:\n"
                for node_name, value in node_results.items():
                    result_text += f"  {node_name}: {value:.4f}\n"
                result_text += "\n"

            QMessageBox.information(self, "ANP Results", result_text)
        except Exception as e:
            QMessageBox.warning(self, "Error", f"An error occurred during calculation: {str(e)}")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = ANPMainWindow()
    window.show()
    sys.exit(app.exec())"