X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/desynchronisation-controle.git/blobdiff_plain/90e98a89726a12ad0e1d68d39c993aa73b3c4230..bc18d50297e1b6798015a28bc91eee4f7f3752ca:/exp_controle_asynchrone/simulMWSN.py?ds=sidebyside diff --git a/exp_controle_asynchrone/simulMWSN.py b/exp_controle_asynchrone/simulMWSN.py index 4844593..bf17462 100644 --- a/exp_controle_asynchrone/simulMWSN.py +++ b/exp_controle_asynchrone/simulMWSN.py @@ -468,6 +468,7 @@ 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 @@ -492,7 +493,6 @@ def __evalue_maj_theta__(nbexp,out=False): arret = errorq < error k+=1 variation = "+" if smax > sm else "-" - sm = smax print variation, if k%100 ==0 : print "k:",k,"erreur sur q", errorq, "et q:",q @@ -510,7 +510,9 @@ def __evalue_maj_theta__(nbexp,out=False): print "variation trop grande" print "init" print init - sy.exit(0) + exit + sm = smax + if k == itermax: print "nbre d'iteration trop grand" print "init" @@ -526,49 +528,71 @@ def __evalue_maj_theta__(nbexp,out=False): +def __une_seule_exp__(fichier_donees): + global u, v, la, w, theta , q, Ps, Rh, eta, x, valeurFonctionDuale + initialisation() + + fichier = open(fichier_donees, "r") + instructions ={} + for line in fichier: + l = line.split("=") + instructions[l[0]] = eval(l[1]) + u, v, la, w, q, Ps, Rh, eta, x, = instructions['u'], instructions['v'], instructions['la'], instructions['w'], instructions['q'], instructions['Ps'], instructions['Rh'], instructions['eta'], instructions['x'] + nbexp = 1 + res = {} + m = [] + itermax = 100000 + + def __maj_theta(k): + om = omega/(mt.pow(k,0.75)) + return om + for idxexp in range(nbexp): + mxg = 0 + k = 1 + arret = False + sm = 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 + 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 smax - sm > 500: + print "variation trop grande" + print "init" + print init + exit + sm = smax -ASYNC = False -__evalue_maj_theta__(1,True) - + if k == itermax: + print "nbre d'iteration trop grand" + print "init" + print init + exit + print "###############" + print k + print "###############" + m += [k] -#ASYNC = True -#taux_succes = 0.9 -#__evalue_maj_theta__() + print (min(m),max(m),float(sum(m))/nbexp,m),m -""" -initialisation() -k = 1 -arret = False -while k < 10000 and not arret : - (u,v,la,w,theta,eta,q,Ps,Rh,x,valeurFonctionDuale,ar)=maj(k,maj_theta) - arret = ar - k+=1 - errorq = abs(min(q.values())-max(q.values())) - print "errorq",errorq - arret = errorq < error -""" -""" - print "u",u - print "w",w - print "theta",theta - print "eta", eta - print "q",q - print "v",v - print "lambda",la - print "Ps",Ps - print "Rh",Rh - print "x",x -""" +ASYNC = False +__une_seule_exp__("config_initiale.py") +#__evalue_maj_theta__() +#ASYNC = True +#taux_succes = 0.9 +#__evalue_maj_theta__() -""" - k +=1 -"""