X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/desynchronisation-controle.git/blobdiff_plain/1216fb04e58a581d9a4d2e77355aaf47bf989447..b6e0e34a9afa3b4060edb6098e6fcc397979ffe8:/exp_controle_asynchrone/simulMWSN.py?ds=sidebyside diff --git a/exp_controle_asynchrone/simulMWSN.py b/exp_controle_asynchrone/simulMWSN.py index 41e82c6..43083c4 100644 --- a/exp_controle_asynchrone/simulMWSN.py +++ b/exp_controle_asynchrone/simulMWSN.py @@ -9,12 +9,14 @@ from copy import deepcopy import sys as sy import cv as cv import cv2 as cv2 -error = 0.1 + +errorq = 0.1 +errorD = 1E-5 epsilon = 1E-10 vrate = 0.8 p = 0.7 coteCarre = 50 -distanceEmmissionMax = 20 +distanceEmmissionMax = 30 nbiter = 1000 POS = 1 POS_NUL = 2 @@ -105,13 +107,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() @@ -428,7 +430,7 @@ def maj(k,maj_theta,mxg,idxexp): #AfficheVariation(up,vp,lap,wp,thetap,etap,qp,Psp,Rhp,xp,valeurFonctionDualep) - arret = abs(valeurFonctionDuale-valeurFonctionDualep) < error + arret = abs(valeurFonctionDuale-valeurFonctionDualep) return (up,vp,lap,wp,thetap,etap,qp,Psp,Rhp,xp,valeurFonctionDualep,arret,mxg,smax) @@ -520,7 +522,6 @@ def initialisation_(): def __evalue_maj_theta__(nbexp,out=False): global u, v, la, w, theta , q, Ps, Rh, eta, x, valeurFonctionDuale - nbexp = 10 res = {} m = [] itermax = 100000 @@ -529,6 +530,7 @@ def __evalue_maj_theta__(nbexp,out=False): mem = [] om = omega/(mt.pow(k,0.75)) return om + liste_arret=[] for idxexp in range(nbexp): mxg = 0 if not(out): @@ -539,24 +541,31 @@ def __evalue_maj_theta__(nbexp,out=False): k = 1 arret = False sm = 0 + err, ar = 0,0 while k < itermax and not arret : (u,v,la,w,theta,eta,q,Ps,Rh,x,valeurFonctionDuale,ar,mxg,smax)=maj(k,__maj_theta,mxg,idxexp) - errorq = (max(q.values()) - min(q.values()))/min(q.values()) - arret = errorq < error + err = (max(q.values()) - min(q.values()))/min(q.values()) + + arret = err < errorq or ar < errorD k+=1 variation = "+" if smax > sm else "-" - print variation, - if k%100 ==0 : - print "k:",k,"erreur sur q", errorq, "et q:",q - print "maxg=", mxg + if out : print variation, + if k%500 ==0 : + print "k:", k, + "erreur sur q", + errorq, "erreur sur F", ar, "et q:", q + + if out : print "maxg=", mxg mem = [deepcopy(q),deepcopy(Ps),deepcopy(Rh),deepcopy(eta), deepcopy(x),deepcopy(u),deepcopy(v),deepcopy(la),deepcopy(w)] + """ if k%4500 == 0 : - print "#########\n",mem,"\#########\n" + + #print "#########\n",mem,"\#########\n" if k%4600 == 0 : - print "#########\n",mem,"\#########\n" - - + #print "#########\n",mem,"\#########\n" + """ + if smax - sm > 500: print "variation trop grande" @@ -564,20 +573,23 @@ def __evalue_maj_theta__(nbexp,out=False): print init exit sm = smax - + if k == itermax: print "nbre d'iteration trop grand" print "init" print init sy.exit(1) + else : + liste_arret += [(err, ar,k,errorD)] print "###############" print k print "###############" m += [k] - - print (min(m),max(m),float(sum(m))/nbexp,m),m - + + #print liste_arret + #print (min(m),max(m),float(sum(m))/nbexp,m),m + return liste_arret def __une_seule_exp__(fichier_donees): @@ -638,8 +650,13 @@ def __une_seule_exp__(fichier_donees): ASYNC = False -__une_seule_exp__("config_initiale.py") -#__evalue_maj_theta__() +#__une_seule_exp__("config_initiale.py") +listederes=[] +for k in list(np.logspace(-6, -3, num=15)): + errorD = k + listederes += __evalue_maj_theta__(5) + +print listederes #ASYNC = True #taux_succes = 0.9 #__evalue_maj_theta__() @@ -647,7 +664,7 @@ __une_seule_exp__("config_initiale.py") - +""" print "u",u print "v",v print "lambda",la @@ -660,7 +677,7 @@ print "Rh",Rh print "x",x print "L",valeurFonctionDuale - +""" # relation ente les variables primaires et secondaires ?