functionMain.py 1.4 KB

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