Read about our upcoming Code of Conduct on this issue

This instance was upgraded to Heptapod 0.28.1 today

Commit 2a2d06e3 authored by Aleksandr Bakhshiev's avatar Aleksandr Bakhshiev
Browse files

Some 'common' base classes have been added #2.

--HG--
branch : NamedIO
parent d1f60610fd24
......@@ -147,6 +147,9 @@
<CppCompile Include="..\..\Core\NPulseLTZone.cpp">
<BuildOrder>7</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\Core\NPulseLTZoneCommon.cpp">
<BuildOrder>16</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\Core\NPulseMembrane.cpp">
<BuildOrder>8</BuildOrder>
</CppCompile>
......@@ -162,6 +165,9 @@
<CppCompile Include="..\..\Core\NPulseSynapse.cpp">
<BuildOrder>10</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\Core\NPulseSynapseCommon.cpp">
<BuildOrder>17</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\Core\NPulseSynChannel.cpp">
<BuildOrder>11</BuildOrder>
</CppCompile>
......
......@@ -25,52 +25,6 @@ See file license.txt for more information
namespace NMSDK {
// NLTZone
// --------------------------
//
// --------------------------
NLTZone::NLTZone(void)
: Threshold("Threshold",this,&NLTZone::SetThreshold)
{
Neuron=0;
}
NLTZone::~NLTZone(void)
{
}
// --------------------------
// --------------------------
//
// --------------------------
//
bool NLTZone::SetThreshold(const double &value)
{
return true;
}
// --------------------------
// --------------------------
//
// --------------------------
//
bool NLTZone::ADefault(void)
{
Threshold=0.0;
return true;
}
// .
bool NLTZone::AReset(void)
{
CachedNumAConnectors=static_cast<double>(GetNumAConnectors(0));
return true;
}
// --------------------------
// NPulseLTZone
// --------------------------
//
......@@ -78,14 +32,7 @@ bool NLTZone::AReset(void)
NPulseLTZone::NPulseLTZone(void)
//: NADItem(name),
: TimeConstant("TimeConstant",this,&NPulseLTZone::SetTimeConstant),
PulseAmplitude("PulseAmplitude",this,&NPulseLTZone::SetPulseAmplitude),
PulseLength("PulseLength",this),
AvgInterval("AvgInterval",this),
NeuralPotential("NeuralPotential",this),
PrePotential("PrePotential",this),
PulseCounter("PulseCounter",this),
AvgFrequencyCounter("AvgFrequencyCounter",this),
PulseFlag("PulseFlag",this)
NeuralPotential("NeuralPotential",this)
{
}
......@@ -150,7 +97,7 @@ bool NPulseLTZone::CheckComponentType(UEPtr<UContainer> comp) const
//
bool NPulseLTZone::ADefault(void)
{
NLTZone::ADefault();
NPulseLTZoneCommon::ADefault();
vector<size_t> size;
SetNumOutputs(4);
......@@ -159,12 +106,7 @@ bool NPulseLTZone::ADefault(void)
//
TimeConstant=0.005;
PulseAmplitude=1;
PulseLength=0.001;
Threshold=0;//0.00001;
AvgInterval=1;
// NumInputs=2;
return true;
}
......@@ -181,14 +123,9 @@ bool NPulseLTZone::ABuild(void)
// .
bool NPulseLTZone::AReset(void)
{
NLTZone::AReset();
NPulseLTZoneCommon::AReset();
//
NeuralPotential=0;
PrePotential=0;
PulseCounter=0;
AvgFrequencyCounter->clear();
PulseFlag=false;
FillOutputData(0);
return true;
}
......@@ -215,15 +152,10 @@ bool NPulseLTZone::ACalculate(void)
NeuralPotential.v/=NumInputs/2.0;
}
// double prev=PrePotential;
PrePotential.v+=(NeuralPotential.v-PrePotential.v)/(TimeConstant.v*TimeStep);
// PrePotential=NeuralPotential.v;
// if(PulseCounter.v > 0)
// --PulseCounter;
double current_time=GetTime().GetDoubleTime();
if(PrePotential.v>=Threshold.v)
if(CheckPulseOn())
{
POutputData[0].Double[0]=PulseAmplitude.v;
POutputData[1].Double[0]=PulseAmplitude.v;
......@@ -232,7 +164,7 @@ bool NPulseLTZone::ACalculate(void)
PulseFlag=true;
}
else
if(PrePotential.v<=0)
if(CheckPulseOff())
{
PulseFlag=false;
POutputData[0].Double[0]=0;
......@@ -279,10 +211,22 @@ bool NPulseLTZone::ACalculate(void)
POutputData[3].Double[i]=*I;
if(MainOwner)
static_pointer_cast<NPulseNeuron>(MainOwner)->NumActiveOutputs.v+=CachedNumAConnectors;//static_cast<double>(GetNumAConnectors(0));
dynamic_pointer_cast<NPulseNeuronCommon>(MainOwner)->NumActiveOutputs.v+=CachedNumAConnectors;//static_cast<double>(GetNumAConnectors(0));
return true;
}
/// true
bool NPulseLTZone::CheckPulseOn(void)
{
return PrePotential.v>=Threshold.v;
}
/// true
bool NPulseLTZone::CheckPulseOff(void)
{
return PrePotential.v<=0;
}
// --------------------------
// NContinuesLTZone
......@@ -449,7 +393,7 @@ bool NContinuesLTZone::ACalculate(void)
POutputData[2].Double[0]=POutputData[0].Double[0];
if(MainOwner)
static_pointer_cast<NPulseNeuron>(MainOwner)->NumActiveOutputs.v+=CachedNumAConnectors;//static_cast<double>(GetNumAConnectors(0));
dynamic_pointer_cast<NPulseNeuronCommon>(MainOwner)->NumActiveOutputs.v+=CachedNumAConnectors;//static_cast<double>(GetNumAConnectors(0));
return true;
}
......@@ -578,7 +522,7 @@ bool NPulseSimpleLTZone::ACalculate(void)
POutputData[3]=generator.GetOutputData(3);
if(MainOwner)
static_pointer_cast<NPulseNeuron>(MainOwner)->NumActiveOutputs.v+=CachedNumAConnectors;//static_cast<double>(GetNumAConnectors(0));
dynamic_pointer_cast<NPulseNeuronCommon>(MainOwner)->NumActiveOutputs.v+=CachedNumAConnectors;//static_cast<double>(GetNumAConnectors(0));
return true;
}
......@@ -681,7 +625,7 @@ bool NContinuesSimpleLTZone::ACalculate(void)
POutputData[2].Double[0]=NeuralPotential.v;
if(MainOwner)
static_pointer_cast<NPulseNeuron>(MainOwner)->NumActiveOutputs.v+=CachedNumAConnectors;//static_cast<double>(GetNumAConnectors(0));
dynamic_pointer_cast<NPulseNeuronCommon>(MainOwner)->NumActiveOutputs.v+=CachedNumAConnectors;//static_cast<double>(GetNumAConnectors(0));
return true;
}
......
......@@ -18,71 +18,18 @@ See file license.txt for more information
#include "../../Nmsdk-BasicLib/Core/NSupport.h"
#include "../../Nmsdk-SourceLib/Core/NPulseGenerator.h"
#include "NPulseLTZoneCommon.h"
namespace NMSDK {
class NPulseNeuron;
class RDK_LIB_TYPE NLTZone: public UNet
{
public: //
//
RDK::ULProperty<double,NLTZone> Threshold;
public: //
//
NPulseNeuron* Neuron;
protected: //
protected: //
///
int CachedNumAConnectors;
public: //
// --------------------------
//
// --------------------------
NLTZone(void);
virtual ~NLTZone(void);
// --------------------------
// --------------------------
//
// --------------------------
//
bool SetThreshold(const double &value);
// --------------------------
// --------------------------
//
// --------------------------
protected:
//
virtual bool ADefault(void);
// .
virtual bool AReset(void);
// --------------------------
};
class RDK_LIB_TYPE NPulseLTZone: public NLTZone
class RDK_LIB_TYPE NPulseLTZone: public NPulseLTZoneCommon
{
public: //
//
RDK::ULProperty<double,NPulseLTZone> TimeConstant;
//
RDK::ULProperty<double,NPulseLTZone> PulseAmplitude;
//
RDK::ULProperty<double,NPulseLTZone> PulseLength;
//
RDK::ULProperty<double,NPulseLTZone> AvgInterval;
public: //
protected: //
......@@ -91,18 +38,6 @@ protected: //
//
RDK::ULProperty<double,NPulseLTZone,ptPubState> NeuralPotential;
//
RDK::ULProperty<double,NPulseLTZone,ptPubState> PrePotential;
//
RDK::ULProperty<int,NPulseLTZone,ptPubState> PulseCounter;
//
RDK::UCLProperty<list<double>,NPulseLTZone,ptPubState> AvgFrequencyCounter;
//
RDK::ULProperty<bool,NPulseLTZone,ptPubState> PulseFlag;
public: //
// --------------------------
//
......@@ -157,6 +92,12 @@ virtual bool AReset(void);
//
virtual bool ACalculate(void);
/// true
virtual bool CheckPulseOn(void);
/// true
virtual bool CheckPulseOff(void);
// --------------------------
};
......
// ===========================================================
// Version: 3.0.2
// ===========================================================
/* ***********************************************************
@Copyright Alexander V. Bakhshiev, 2016.
E-mail: alexab@ailab.ru
url: http://ailab.ru
This file - part of the project: Neuro Modeler Software Developer Kit (NMSDK)
File License: BSD License
Project License: BSD License
See file license.txt for more information
*********************************************************** */
#ifndef NPULSE_LTZONE_COMMON_CPP
#define NPULSE_LTZONE_COMMON_CPP
#include <numeric>
#include "NPulseLTZoneCommon.h"
#include "NPulseChannel.h"
#include "NPulseNeuron.h"
//#include "../BCL/NConnector.h"
namespace NMSDK {
// NLTZone
// --------------------------
//
// --------------------------
NLTZone::NLTZone(void)
: Threshold("Threshold",this,&NLTZone::SetThreshold)
{
Neuron=0;
}
NLTZone::~NLTZone(void)
{
}
// --------------------------
// --------------------------
//
// --------------------------
//
bool NLTZone::SetThreshold(const double &value)
{
return true;
}
// --------------------------
// --------------------------
//
// --------------------------
//
bool NLTZone::ADefault(void)
{
Threshold=0.0;
return true;
}
// .
bool NLTZone::AReset(void)
{
CachedNumAConnectors=static_cast<double>(GetNumAConnectors(0));
return true;
}
// --------------------------
// NPulseLTZoneCommon
// --------------------------
//
// --------------------------
NPulseLTZoneCommon::NPulseLTZoneCommon(void)
:
PulseAmplitude("PulseAmplitude",this,&NPulseLTZoneCommon::SetPulseAmplitude),
PulseLength("PulseLength",this),
AvgInterval("AvgInterval",this),
PrePotential("PrePotential",this),
PulseCounter("PulseCounter",this),
AvgFrequencyCounter("AvgFrequencyCounter",this),
PulseFlag("PulseFlag",this)
{
}
NPulseLTZoneCommon::~NPulseLTZoneCommon(void)
{
}
// --------------------------
// --------------------------
//
// --------------------------
//
bool NPulseLTZoneCommon::SetPulseAmplitude(const double &value)
{
if(value <= 0)
return false;
return true;
}
// --------------------------
// --------------------------
//
// --------------------------
//
NPulseLTZoneCommon* NPulseLTZoneCommon::New(void)
{
return new NPulseLTZoneCommon;
}
// --------------------------
// --------------------------
//
// --------------------------
//
//
// 'true'
// 'false'
bool NPulseLTZoneCommon::CheckComponentType(UEPtr<UContainer> comp) const
{
return false;
}
// --------------------------
// --------------------------
//
// --------------------------
//
bool NPulseLTZoneCommon::ADefault(void)
{
NLTZone::ADefault();
vector<size_t> size;
SetNumOutputs(4);
for(int i=0;i<NumOutputs;i++)
SetOutputDataSize(i,MMatrixSize(1,1));
//
AvgInterval=1;
PulseAmplitude=1;
PulseLength=0.001;
return true;
}
//
//
// Reset() Ready true
//
bool NPulseLTZoneCommon::ABuild(void)
{
return true;
}
// .
bool NPulseLTZoneCommon::AReset(void)
{
NLTZone::AReset();
//
PulseCounter=0;
PrePotential=0;
AvgFrequencyCounter->clear();
PulseFlag=false;
FillOutputData(0);
return true;
}
//
bool NPulseLTZoneCommon::ACalculate(void)
{
return true;
}
/// true
bool NPulseLTZoneCommon::CheckPulseOn(void)
{
return false;
}
/// true
bool NPulseLTZoneCommon::CheckPulseOff(void)
{
return false;
}
// --------------------------
}
#endif
// ===========================================================
// Version: 3.0.3
// ===========================================================
/* ***********************************************************
@Copyright Alexander V. Bakhshiev, 2016.
E-mail: alexab@ailab.ru
url: http://ailab.ru
This file - part of the project: Neuro Modeler Software Developer Kit (NMSDK)
File License: BSD License
Project License: BSD License
See file license.txt for more information
*********************************************************** */
#ifndef NPULSE_LTZONE_COMMON_H
#define NPULSE_LTZONE_COMMON_H
#include "../../Nmsdk-BasicLib/Core/NSupport.h"
#include "../../Nmsdk-SourceLib/Core/NPulseGenerator.h"
namespace NMSDK {
class NPulseNeuron;
class RDK_LIB_TYPE NLTZone: public UNet
{
public: //
//
RDK::ULProperty<double,NLTZone> Threshold;
public: //
//
NPulseNeuron* Neuron;
protected: //
protected: //
///
int CachedNumAConnectors;
public: //
// --------------------------
//
// --------------------------
NLTZone(void);
virtual ~NLTZone(void);
// --------------------------
// --------------------------
//
// --------------------------
//
bool SetThreshold(const double &value);
// --------------------------
// --------------------------
//
// --------------------------
protected:
//
virtual bool ADefault(void);
// .
virtual bool AReset(void);
// --------------------------
};
class RDK_LIB_TYPE NPulseLTZoneCommon: public NLTZone
{
public: //
//
RDK::ULProperty<double,NPulseLTZoneCommon> PulseAmplitude;
//
RDK::ULProperty<double,NPulseLTZoneCommon> PulseLength;
//
RDK::ULProperty<double,NPulseLTZoneCommon> AvgInterval;
public: //
//
//
RDK::ULProperty<double,NPulseLTZoneCommon,ptPubState> PrePotential;
protected: //
protected: //
//
RDK::ULProperty<int,NPulseLTZoneCommon,ptPubState> PulseCounter;
//
RDK::UCLProperty<list<double>,NPulseLTZoneCommon,ptPubState> AvgFrequencyCounter;
//
RDK::ULProperty<bool,NPulseLTZoneCommon,ptPubState> PulseFlag;
public: //
// --------------------------
//
// --------------------------
NPulseLTZoneCommon(void);
virtual ~NPulseLTZoneCommon(void);
// --------------------------
// --------------------------
//
// --------------------------
//
bool SetPulseAmplitude(const double &value);
// --------------------------
// --------------------------
//
// --------------------------
//
virtual NPulseLTZoneCommon* New(void);
// --------------------------
// --------------------------
//
// --------------------------
//
//
// 'true'
// 'false'
virtual bool CheckComponentType(UEPtr<UContainer> comp) const;
// --------------------------
// --------------------------
//
// --------------------------
protected: