simmod_localinh.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // C++ Implementation: simmod_localinh
  3. //
  4. // Description:
  5. //
  6. //
  7. // Author: Frank Michler,,, <frank@pc13365>, (C) 2010
  8. //
  9. // Copyright: See COPYING file that comes with this distribution
  10. //
  11. //
  12. #include "sys.hpp" // for libcwd
  13. #include "debug.hpp" // for libcwd
  14. #include "objsimexception.hpp"
  15. #include "objsimlibrary.hpp"
  16. #include "simmod_localinh.hpp"
  17. SimMod_LocalInh::SimMod_LocalInh(AnyOptionWrapper* _opt)
  18. : SimModule(_opt), mInhLayer(0), mConInhEx(0), mConExInh(0), mConnectivity(0.5), mNumberOfChanges(0)
  19. {
  20. }
  21. SimMod_LocalInh::~SimMod_LocalInh()
  22. {
  23. }
  24. void SimMod_LocalInh::SetCmdLineOptions()
  25. {
  26. myAnyWrap->setOption( "LocInh_Range", 'a', &mRange, 0.08);
  27. myAnyWrap->setOption( "LocInh_InhExNeuronRatio", 'a', &mInhExNeuronRatio, 1);
  28. myAnyWrap->setOption( "LocInh_InhExStrength", 'a', &mInhExStrength, 0.2);
  29. myAnyWrap->setOption( "LocInh_ExInhStrength", 'a', &mExInhStrength, 2.0);
  30. myAnyWrap->setOption( "LocInh_GlobalExInhStrength", 'a', &mGlobalExInhStrength, 2.0);
  31. myAnyWrap->setOption( "LocInh_GlobalInhExStrength", 'a', &mGlobalInhExStrength, 2.0);
  32. }
  33. layer* SimMod_LocalInh::Setup (SimLoop* _MainSimLoop,
  34. layer* _ExLayer,
  35. bool LoadWeights,
  36. bool VecCon
  37. )
  38. {
  39. MainSimLoop = _MainSimLoop;
  40. if (!_ExLayer) throw ObjSimException("_ExLayer is NULL");
  41. // setup InhLayer
  42. int NExNeurons = _ExLayer->NNeurons();
  43. int ExNeuronsNx = _ExLayer->NeuronsNx();
  44. int ExNeuronsNy = _ExLayer->NeuronsNy();
  45. int NInhNeurons = static_cast<int>(NExNeurons*mInhExNeuronRatio);
  46. mInhLayer = new DecoLifLayer(NInhNeurons, DecoParaInhibitory);
  47. mInhLayer->SetupPositions(static_cast<int>(mInhExNeuronRatio*ExNeuronsNx),
  48. static_cast<int>(mInhExNeuronRatio*ExNeuronsNy),
  49. true);
  50. mInhLayer->SetName("LocInh_InhLayer");
  51. MainSimLoop->AddSimElement(mInhLayer);
  52. // connecting InhLayer to _ExLayer
  53. mConInhEx = new VecConnection(mInhLayer, _ExLayer, csimInputChannel_GABAa, false);
  54. mConInhEx->SetName("LocInh_ConInhEx");
  55. mConInhEx->ConnectSelf(mInhExStrength, 1, 0);
  56. // mConInhEx->ConnectGaussian(0.01, mInhExStrength, 1,0, true);
  57. mConInhEx->Save();
  58. MainSimLoop->AddSimElement(mConInhEx);
  59. // connecting _ExLayer to InhLayer
  60. mConExInh = new VecConnection(_ExLayer, mInhLayer, csimInputChannel_NMDA_AMPA, true);
  61. mConExInh->SetName("LocInh_ConExInh");
  62. RangeConnectionParameters ConExInhParameter(mRange, mExInhStrength, 1,0, mConnectivity, true);
  63. //mConExInh->ConnectGaussian(mRange, mExInhStrength, 1,0, true);
  64. mConExInh->ConnectCircular(ConExInhParameter);
  65. mConExInh->Save();
  66. MainSimLoop->AddSimElement(mConExInh);
  67. }
  68. void SimMod_LocalInh::changeParameter(ParameterSet * ParaSet)
  69. {
  70. TwoParameters<float,float>* RangeAndSetrngth = dynamic_cast<TwoParameters<float,float>* >(ParaSet);
  71. if (RangeAndSetrngth) {
  72. RangeConnectionParameters ConExInhParameter(
  73. RangeAndSetrngth->first,
  74. RangeAndSetrngth->second,
  75. 1,
  76. 0,
  77. mConnectivity,
  78. true);
  79. mConExInh->DeleteSynapseArrays();
  80. mConExInh->ConnectCircular(ConExInhParameter);
  81. //mConExInh->Save(mNumberOfChanges++);
  82. }
  83. }