File size: 1,579 Bytes
e412146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Test basique du système MLE."""
import sys
sys.path.insert(0, '.')

import numpy as np
from mle.mle_system import MLESystem
from mle.memory import VECTOR_SIZE

np.random.seed(42)

print("Initializing MLESystem...")
mle = MLESystem(memory_capacity=100, online_learning=True)

print(f"Memory size: {mle.memory.size}")
print(f"Router vectors: {mle.router.get_stats()['n_vectors']}")

# Test basique
vec = np.zeros(VECTOR_SIZE, dtype=np.uint8)
vec[np.random.choice(VECTOR_SIZE, size=200, replace=False)] = 1

print(f"\nProcessing vector with {np.sum(vec)} active bits...")
result = mle.process(vec)

print(f"Converged: {result.converged}")
print(f"Iterations: {result.n_iterations}")
if result.energy_trajectory:
    print(f"Final energy: {result.energy_trajectory[-1]:.1f}")
    print(f"Energy trajectory: {[f'{e:.1f}' for e in result.energy_trajectory[:10]]}")

# Test binding
print("\nTesting binding...")
a = np.zeros(VECTOR_SIZE, dtype=np.uint8)
a[np.random.choice(VECTOR_SIZE, size=200, replace=False)] = 1

b = np.zeros(VECTOR_SIZE, dtype=np.uint8)
b[np.random.choice(VECTOR_SIZE, size=200, replace=False)] = 1

bound = mle.binder.bind(a, b)
recovered = mle.binder.unbind(bound, a)
similarity = np.mean(recovered == b)
print(f"Binding similarity: {similarity:.3f}")

# Test requête
print("\nTesting query...")
neighbors = mle.query(vec, k=3)
print(f"Found {len(neighbors)} neighbors")

# Metrics
print("\nMetrics summary:")
summary = mle.get_metrics_summary()
for section, data in summary.items():
    print(f"  {section}: {data}")

print("\n✓ All basic tests passed!")