Logic Particle
Автор: Myblogband
Загружено: 2024-07-12
Просмотров: 22
Описание:
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
from ipywidgets import interact, FloatSlider
Function to create a decision graph
def create_decision_graph(nodes=5):
G = nx.DiGraph()
for i in range(nodes):
G.add_node(i, value=np.random.rand())
for i in range(1, nodes):
G.add_edge(0, i)
return G
Function to calculate energy based on node value and some parameters
def calculate_energy(value, coefficient):
return coefficient * value**2
Interactive visualization function
def interactive_logic_energy(coefficient):
G = create_decision_graph()
energies = [calculate_energy(G.nodes[node]['value'], coefficient) for node in G.nodes]
pos = nx.spring_layout(G)
fig, ax = plt.subplots()
nx.draw(G, pos, ax=ax, with_labels=True, node_color=energies, cmap=plt.cm.viridis)
Visualize node energies
for node, (x, y) in pos.items():
ax.text(x, y + 0.1, f"{energies[node]:.2f}", bbox=dict(facecolor='white', alpha=0.5), horizontalalignment='center')
plt.title('Interactive Logical Structure and Energy Number Visualization')
plt.show()
Interactive slider for coefficient
interact(interactive_logic_energy, coefficient=FloatSlider(min=0.1, max=10.0, step=0.1, value=1.0))
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: