Spaces:
Runtime error
Runtime error
File size: 2,139 Bytes
e369f76 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import matplotlib.pyplot as plt
import numpy as np
def plot_phi(all_agents_history, filename=None):
plt.figure(figsize=(10, 6))
for i, agent_history in enumerate(all_agents_history):
plt.plot(agent_history['phi'], label=f'Agent {i+1} Phi')
plt.xlabel('Step')
plt.ylabel('Phi')
plt.title('Agent Phi Over Time')
plt.legend()
plt.grid(True)
if filename is not None:
plt.savefig(filename, dpi=300, bbox_inches='tight')
plt.close()
def plot_tau(all_agents_history, filename=None):
plt.figure(figsize=(10, 6))
for i, agent_history in enumerate(all_agents_history):
plt.plot(agent_history['tau_eff'], label=f'Agent {i+1} Tau Eff')
plt.xlabel('Step')
plt.ylabel('Tau Effective')
plt.title('Agent Tau Effective Over Time')
plt.legend()
plt.grid(True)
if filename is not None:
plt.savefig(filename, dpi=300, bbox_inches='tight')
plt.close()
def plot_fitness(all_agents_history, filename=None):
plt.figure(figsize=(10, 6))
for i, agent_history in enumerate(all_agents_history):
plt.plot(agent_history['fitness'], label=f'Agent {i+1} Fitness')
plt.xlabel('Step')
plt.ylabel('Fitness')
plt.title('Agent Fitness Over Time')
plt.legend()
plt.grid(True)
if filename is not None:
plt.savefig(filename, dpi=300, bbox_inches='tight')
plt.close()
def plot_coherence(coherence_list, filename=None):
plt.figure(figsize=(10, 6))
plt.plot(coherence_list)
plt.xlabel('Step')
plt.ylabel('Average Phi')
plt.title('System Coherence Over Time (Average Phi)')
plt.grid(True)
if filename is not None:
plt.savefig(filename, dpi=300, bbox_inches='tight')
plt.close()
def plot_stability(stability_list, filename=None):
plt.figure(figsize=(10, 6))
plt.plot(stability_list)
plt.xlabel('Step')
plt.ylabel('Variance of Phi')
plt.title('System Stability Over Time (Variance of Phi)')
plt.grid(True)
if filename is not None:
plt.savefig(filename, dpi=300, bbox_inches='tight')
plt.close()
print("visualization.py updated successfully.")
|