From 89be6c60f83873b92ea5cfa0b5aa488a4a5744be Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Fran=C3=A7ois=20Couchot?= Date: Thu, 28 Nov 2013 09:01:47 +0100 Subject: [PATCH] qqelques modif en dev --- exp_controle_asynchrone/simulMWSN.py | 96 ++++++++++++++++++---------- 1 file changed, 61 insertions(+), 35 deletions(-) diff --git a/exp_controle_asynchrone/simulMWSN.py b/exp_controle_asynchrone/simulMWSN.py index fbd48aa..8bbeddb 100644 --- a/exp_controle_asynchrone/simulMWSN.py +++ b/exp_controle_asynchrone/simulMWSN.py @@ -444,10 +444,10 @@ def initialisation(): def __evalue_maj_theta__(): global u, v, la, w, theta , q, Ps, Rh, eta, x, valeurFonctionDuale - nbexp = 5 + nbexp = 10 res = {} m = [] - itermax = 10000 + itermax = 100000 def __maj_theta(k): om = omega/(mt.pow(k,0.75)) @@ -464,7 +464,6 @@ def __evalue_maj_theta__(): 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 @@ -474,6 +473,8 @@ def __evalue_maj_theta__(): print "init" print init exit + sm = smax + if k == itermax: print "nbre d'iteration trop grand" print "init" @@ -489,46 +490,71 @@ def __evalue_maj_theta__(): +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__() -#ASYNC = True -#taux_succes = 0.9 -#__evalue_maj_theta__() + if k == itermax: + print "nbre d'iteration trop grand" + print "init" + print init + exit + print "###############" + print k + print "###############" + m += [k] -""" -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 (min(m),max(m),float(sum(m))/nbexp,m),m -""" - 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 -""" -""" - k +=1 -""" +ASYNC = False +__une_seule_exp__("config_initiale.py") +#__evalue_maj_theta__() +#ASYNC = True +#taux_succes = 0.9 +#__evalue_maj_theta__() + + -- 2.39.5