X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/desynchronisation-controle.git/blobdiff_plain/b6e0e34a9afa3b4060edb6098e6fcc397979ffe8..e6cd9df3d469f7916d513610d3bc22ab055f790a:/exp_controle_asynchrone/simulMWSN.py?ds=sidebyside diff --git a/exp_controle_asynchrone/simulMWSN.py b/exp_controle_asynchrone/simulMWSN.py index 43083c4..218ecb7 100644 --- a/exp_controle_asynchrone/simulMWSN.py +++ b/exp_controle_asynchrone/simulMWSN.py @@ -16,7 +16,7 @@ epsilon = 1E-10 vrate = 0.8 p = 0.7 coteCarre = 50 -distanceEmmissionMax = 30 +distanceEmmissionMax = 20 nbiter = 1000 POS = 1 POS_NUL = 2 @@ -59,11 +59,12 @@ def afficheGraph(G,l,tx,ty,sink): img = cv.CreateImage ((tx, ty), 32, 3) cv.Rectangle(img, (0,0),(tx,ty), cv.Scalar(255,255,255), thickness=-1) def px((x,y)): - return(int(tx*x/coteCarre),ty-int(ty*y/coteCarre)) + u = float(tx)/(coteCarre + 2*distanceEmmissionMax) + return(int(distanceEmmissionMax*u + x * u),int(distanceEmmissionMax*u + y * u)) for i in set(range(len(l)))-set([sink]): (x,y) = l[i] pix,piy = px((x,y)) - demx = distanceEmmissionMax*tx/coteCarre + demx = distanceEmmissionMax*tx/(coteCarre+2*distanceEmmissionMax) cv.Circle(img, (pix,piy),demx, cv.Scalar(125,125,125)) for i in set(range(len(l)))-set([sink]): @@ -107,13 +108,13 @@ G.add_weighted_edges_from(lg) #nx.draw(G) #pb.show() -#(G,l) = genereGraph() +(G,l) = genereGraph() N = G.nodes() #V = list(set(sample(N,int(len(N)*vrate)))-set([sink])) V = list(set(N)-set([sink])) source = V print "source",source -#afficheGraph(G,l,500,500,sink) +afficheGraph(G,l,500,500,sink) #nx.draw(G) #pb.show() @@ -121,8 +122,7 @@ print "source",source - - +exit() #print G.edges(data=True) #TODO afficher le graphe et etre sur qu'il est connexe