""" MPVR v1 - Multi-Path Vector Routing Preuve de concept MTTV-flp Simule Raft vs MPVR avec routage énergétique et mémoire (4e dimension) """ import random, itertools def simulate(rounds=100, failure=50): nodes=[0,1,2,3,4] failed=1 memory={n:1.2 for n in nodes} results=[] random.seed(101) for r in range(1,rounds+1): alive=[n for n in nodes if not (n==failed and r>=failure)] followers=[n for n in [1,2,3,4] if n in alive] costs={} for i,j in itertools.combinations(nodes,2): if i in alive and j in alive: c=random.uniform(0.5,2.0) costs[(i,j)]=costs[(j,i)]=c def best(a,b): best=costs.get((a,b),9) for m in alive: if m in (a,b): continue c=costs.get((a,m),9)+costs.get((m,b),9) if c=quorum: break if len(chosen)