+#__une_seule_exp__("config_initiale.py")
+#pour evaluerle test d'arret
+"""
+listederes=[]
+for k in list(np.logspace(-6, -3, num=15)):
+ errorD = k
+ listederes += __evalue_maj_theta__(5)
+
+print listederes
+"""
+
+
+
+
+def __comparePsh_et_Psh_avec8_3__(nbexp,out=False):
+ print "tttttttttttt"
+ global u, v, la, w, theta , q, Ps, Rh, eta, x, valeurFonctionDuale
+ res = {}
+ m,mp = [],[]
+ itermax = 100000
+
+ def __maj_theta(k):
+ mem = []
+ om = omega/(mt.pow(k,0.75))
+ return om
+ liste_arret=[]
+ for idxexp in range(nbexp):
+ mxg = 0
+ if not(out):
+ initialisation()
+ else :
+ initialisation_()
+
+ k = 1
+ arret = False
+ sm = 0
+ err, ar = 0,0
+ dur,dura=0,0
+
+ # duppliquee
+ while k < itermax and not arret :
+ (u,v,la,w,theta,eta,q,Ps,Rh,x,valeurFonctionDuale,ar,mxg,smax,ct,cta)=maj(k,__maj_theta,mxg,idxexp)
+ err = (max(q.values()) - min(q.values()))/min(q.values())
+ dur += ct
+ dura += cta
+ arret = err < errorq or ar < errorD
+ k+=1
+ variation = "+" if smax > sm else "-"
+ if out : print variation,
+ if k%100 ==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"
+ if k%4600 == 0 :
+ #print "#########m\n",mem,"\#########\n"
+ """
+
+
+ if smax - sm > 500:
+ print "variation trop grande"
+ print "init"
+ 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," avec optym"
+ print "###############"
+ m += [k]
+ ##fin de duplication
+
+
+
+ #remise a zero
+ q,Ps,Rh,eta,x,u,v,la,w=init[0],init[1],init[2],init[3],init[4],init[5],init[6],init[7],init[8]
+ k = 1
+ arret = False
+ sm = 0
+ err, ar = 0,0
+ dur,dura=0,0
+ # duppliquee
+ while k < itermax and not arret :
+ (u,v,la,w,theta,eta,q,Ps,Rh,x,valeurFonctionDuale,ar,mxg,smax,ct,cta)=maj(k,__maj_theta,mxg,idxexp,True)
+ err = (max(q.values()) - min(q.values()))/min(q.values())
+ dur += ct
+ dura += cta
+ arret = err < errorq or ar < errorD
+ k+=1
+ variation = "+" if smax > sm else "-"
+ if out : print variation,
+ if k%100 ==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"
+ if k%4600 == 0 :
+ #print "#########m\n",mem,"\#########\n"
+ """
+
+
+ if smax - sm > 500:
+ print "variation trop grande"
+ print "init"
+ 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,"sans optym"
+ print "###############"
+ mp += [k]
+
+
+ #print liste_arret
+ #print (min(m),max(m),float(sum(m))/nbexp,m),m
+ #return (liste_arret,dur,dura)
+ return (m,mp)
+
+
+
+# pour evaluer argmin
+"""
+listederes=[]
+k=0
+for k in list(np.logspace(-5, -3, num=10)):
+ print "k",k
+ errorD = k
+ listederes += [(k,__evalue_maj_theta__(3))]
+ k+=1
+print listederes
+"""
+
+# pour evaluer psh
+listederes=[]
+for k in list(np.logspace(-5, -3, num=10)):
+ print "Precision",k
+ errorD = k
+ listederes += [(k,__comparePsh_et_Psh_avec8_3__(10))]
+ k+=1
+print listederes
+
+
+
+
+
+
+print"#######################"
+
+