objsim.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <libcsim.hpp>
  6. ////////////////////
  7. const int Ne = 1600; // excitatory neurons
  8. const int Ni = Ne/4; // inhibitory neurons
  9. const int N = Ne+Ni; // total number of neurons
  10. const int M = N/10; // the number of synapses per neuron
  11. const int D = 20; // maximal axonal conduction delay
  12. float sm = 10.0; // maximal synaptic strength
  13. const int PS = 10; // max pattern size
  14. const int PO = 9; // pattern overlap
  15. const int NP = 100; // number of patterns
  16. const int PTIME = 20; // time per pattern in ms
  17. const float ISTRENGTH = 20; // input strength
  18. const float TAULEARN = 150; //
  19. int ipat[NP][PS]; // input pattern array
  20. int ppt; // pattern pointer
  21. int ptime; // pattern time
  22. int testtime; // time to next test stimulus
  23. int simphase; // simulation phase; 0: training; 1: test
  24. int main()
  25. {
  26. InitLibCSim();
  27. int i, j, k, sec, t;
  28. liflayer *exlayer;
  29. exlayer=new liflayer(800);
  30. exlayer->SetSpikeFileName("exspikes.dat");
  31. input *inp = new input(exlayer, 5);
  32. layer *inhlayer= new layer(200);
  33. connection *ccc = new connection(exlayer,exlayer);
  34. ccc->ConnectDirectional(0.035, 6);
  35. ccc->SetFileName("exexweights.dat");
  36. ccc->Save();
  37. ccc->SetLearn(false);
  38. connection *cei = new connection(exlayer,inhlayer);
  39. cei->ConnectRandom(0.025,0.1);
  40. cei->SetFileName("exinhweights.dat");
  41. cei->SetLearn(false);
  42. connection *cie = new connection(inhlayer,exlayer);
  43. cie->ConnectRandom(0.5,-2);
  44. cie->SetLearn(false);
  45. for (sec=0; sec<60*60*24; sec++) // simulation of 1 day
  46. {
  47. cout << "sec= " << sec << " ";
  48. // if ((sec%10)<9) simphase=0; else simphase=1;
  49. for (t=0;t<1000;t++) // simulation of 1 sec
  50. {
  51. exlayer->proceede(t);
  52. inhlayer->proceede(t);
  53. ccc->proceede(t);
  54. cei->proceede(t);
  55. cie->proceede(t);
  56. if (t>200 && t<400) inp->proceede();
  57. }
  58. exlayer->prepare();
  59. inhlayer->prepare();
  60. ccc->prepare();
  61. cei->prepare();
  62. cie->prepare();
  63. }
  64. }