functionMain.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import os.path
  2. import random
  3. from define import *
  4. #define
  5. def fileWrite(NBneurone,NBneuroneMoins1,N,path):
  6. weight=[]
  7. add=[]
  8. for i in range(NBneurone):
  9. weight.append(random.uniform(-1.0, 1))
  10. tmp=[]
  11. for j in range(MulParNeurone):
  12. tmp.append(random.randrange(0,NBneuroneMoins1))
  13. add.append(tmp)
  14. F_weight = open(path + "poids"+str(N)+".wei","w")
  15. F_AddPos = open(path + "Addresse"+str(N)+".pos","w")
  16. for i in weight :
  17. F_weight.write(str(i)+"\n")
  18. for i in add :
  19. F_AddPos.write(str(i)+"\n")
  20. F_AddPos.close()
  21. F_weight.close()
  22. def GenerateFile():
  23. F_resume = open("resume.txt","r")
  24. file_lines = F_resume.readlines()
  25. F_resume.close ()
  26. last_line = file_lines [ len ( file_lines ) -1]
  27. ID=int(last_line.split(":")[0])+1
  28. print ("Numero du test : " + str(ID))
  29. path = D_file + str(ID) + "/"
  30. os.mkdir(path)
  31. fileWrite(NBC2,NBC1,2,path)
  32. fileWrite(NBC3,NBC2,3,path)
  33. fileWrite(NBC4,NBC3,4,path)
  34. fileWrite(NBC5,NBC4,5,path)
  35. return int(ID)
  36. def CalculPourcentage(Portefeuille,Actions,Frais):
  37. val = Portefeuille
  38. for act in Actions:
  39. val+=act.getValue()
  40. val-=(Frais*3.9)
  41. return (val/initPortefeuille)
  42. def MAJQuotidient(jou,Actions):
  43. for act in Actions:
  44. act.MajQuotidient(jou)
  45. def MAJ1min(minu,Actions):
  46. tab=[]
  47. for act in Actions:
  48. act.Maj1min(minu)
  49. tab.extend(act.getTable())
  50. return tab