functionMain.py 1.3 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. path = D_file + str(ID) + "/"
  29. os.mkdir(path)
  30. fileWrite(NBC2,NBC1,2,path)
  31. fileWrite(NBC3,NBC2,3,path)
  32. fileWrite(NBC4,NBC3,4,path)
  33. fileWrite(NBC5,NBC4,5,path)
  34. return int(ID)
  35. def CalculPourcentage(Portefeuille,Actions,Frais):
  36. val = Portefeuille
  37. for act in Actions:
  38. val+=act.getValue()
  39. val-=(Frais*3.9)
  40. return (val/initPortefeuille)
  41. def MAJQuotidient(jou,Actions):
  42. for act in Actions:
  43. act.MajQuotidient(jou)
  44. def MAJ1min(minu,Actions):
  45. tab=[]
  46. for act in Actions:
  47. act.Maj1min(minu)
  48. tab.append(act.getTable())
  49. return tab