123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- #ifndef _HPP_PARASCAN
- #define _HPP_PARASCAN
- #include <utility>
- #include <vector>
- #include <string>
- #include "libcsim.hpp"
- //#include "simmodules.hpp"
- using namespace std;
- // forward declarations
- class PictureSequenceInput;
- class TiXmlElement;
- class SimLoop;
- class VecConnection;
- class SimMod_CompetitiveInhibition;
- class Interval
- {
- public:
- Interval(float LowBound, float HighBound)
- :mValues(LowBound,HighBound)
- {};
- Interval(pair<float,float> LowAndHighBound): mValues(LowAndHighBound){}
- float LowBound(){return mValues.first;}
- float HighBound(){return mValues.second;}
- float Range(){return mValues.second-mValues.first;}
- bool isValid(){return mValues.second >= mValues.first;}
- private:
- pair<float,float> mValues;
- };
- class ParaScanValues
- {
- public:
- ParaScanValues(pair<float,float> Range, int NValues);
- ParaScanValues(vector<float> _Values);
- const vector<float>& Values();
- void print();
- private:
- vector<float> mValues;
- };
- vector<float> GenerateScanParaValues(float LowBound, float HighBound, int NValues);
- /**
- Interface-Klasse für Parameter-Scan-Hilfsklassen
- Benutzung:
- bool ChangeNextPara=para1->next();
- if (ChangeNextPara) {ChangeNextPara=para2->next();}
- if (ChangeNextPara) {ChangeNextPara=para3->next();}
- SingleValuePara::next() setzt den Parameter um einen Wert weiter.
- Noch unklar: Schreiben in Parameter-XML-Datei.
- SingleValuePara::next() gibt true zurück, wenn der aktuelle Parameter bei Null neu beginnt (rewind), und daher der darauf folgende um einen Wert weitergesetzt werden muss.
- Daher ist para1 analog zur Laufvariablen der innersten Schleife, wenn man es mit verschachtelten For-Schleifen implementieren würde.
- */
- class IScanPara
- {
- public:
- virtual bool Next()=0;
- virtual void SetPara()=0;
- virtual void WriteXmlAttribute(TiXmlElement* para)=0;
- virtual void Hello()=0;
- };
- /**
- Basis-Klasse für Parameter-Scan-Hilfsklassen mit einem Parameter-Wert
- */
- class SingleValuePara: public IScanPara
- {
- protected:
- string ParaName;
- vector<float> ValueList;
- size_t NValues, CurVal;
- public:
- SingleValuePara() {};
- SingleValuePara(string _ParaName, vector<float> _ValueList);
- virtual bool Next();
- virtual void SetPara()=0;
- virtual void WriteXmlAttribute(TiXmlElement* para);
- void Hello();
- };
- /**
- Basis-Klasse für Parameter-Scan-Hilfsklassen mit zwei Parameter-Werten
- */
- class TwoValuesPara: public IScanPara
- {
- protected:
- string Para1Name;
- string Para2Name;
- vector<float> Value1List;
- vector<float> Value2List;
- size_t NValues1, NValues2, CurVal1, CurVal2;
- public:
- TwoValuesPara() {};
- TwoValuesPara(string _Para1Name,
- string _Para2Name,
- vector<float> _Value1List,
- vector<float> _Value2List);
- virtual bool Next();
- virtual void SetPara()=0;
- virtual void WriteXmlAttribute(TiXmlElement* para);
- void Hello();
- };
- /** SimLoopPara: parameters which MainSimLoop can pass to the right SimObjects
- */
- class SimLoopPara: public SingleValuePara
- {
- private:
- SimLoop* MainSimLoop;
- ParaType ptype;
- public:
- SimLoopPara(SimLoop* _SimLoop,
- ParaType _ptype,
- vector<float> _ValueList,
- string _ParaName);
- void SetPara();
- };
- /** Input and Stimulus-Contrast of PictureSequenceInput
- */
- class ContrastInputPara: public TwoValuesPara
- {
- private:
- PictureSequenceInput* PInput;
- public:
- ContrastInputPara(PictureSequenceInput* _PInput,
- vector<float> _BackgroundStrength,
- vector<float> _StimContrast);
- void SetPara();
- void SetParaBackgroundOnly();
- };
- /** Strength of lateral Inhibition
- */
- class InhExStrengthPara: public SingleValuePara
- {
- private:
- SimMod_CompetitiveInhibition* CompInh;
- public:
- InhExStrengthPara(SimMod_CompetitiveInhibition* _CompInh,
- vector<float> _InhExStrength,
- string _ParaName="InhExStrength")
- :SingleValuePara(_ParaName, _InhExStrength), CompInh(_CompInh)
- {};
- void SetPara();
- };
- /** noise amplitude of provided layer
- */
- class NoiseAmplitudePara: public SingleValuePara
- {
- private:
- layer* mLayer;
- public:
- NoiseAmplitudePara( layer* _layer,
- vector<float> _NoiseAmplitude,
- string _ParaName="NoiseAmplitude")
- : mLayer(_layer), SingleValuePara(_ParaName, _NoiseAmplitude)
- {};
- void SetPara();
- };
- /** vary parameters of Gaussian connection profile
- e.g. range and strength of lateral excitation
- */
- class GaussConProfilePara: public TwoValuesPara
- {
- private:
- VecConnection* con;
- float MaxDelay, MinDelay, OldRangeVal, OldStrengthVal;
- public:
- GaussConProfilePara(VecConnection* _con, vector<float> Range, vector<float> Strength, float _MinDelay=0, float _MaxDelay=0);
- void SetPara();
- };
- //template<class T1, class T2>
- class ChangableTwoValuePara: public TwoValuesPara
- {
- private:
- Changable* mParaChangeTarget;
- float mValue1, mOldValue1;
- float mValue2, mOldValue2;
- public:
- ChangableTwoValuePara(const string& NameVal1,
- const string& NameVal2,
- vector<float> Values1,
- vector<float> Values2,
- Changable* ObjectToBeChanged);
- void SetPara();
- };
- typedef vector<IScanPara*>::iterator ScanParaIter;
- /**
- Helper class for parameter scan
- */
- class ParameterCollection
- {
- private:
- vector<IScanPara*> ScanParaList;
- public:
- ParameterCollection(){};
- void AddPara(IScanPara* para) {ScanParaList.push_back(para); para->Hello();};
- void AddContrastInputPara(PictureSequenceInput* _PInput,
- vector<float> _BackgroundStrength,
- vector<float> _StimContrast);
- bool NextPara();
- void SetPara();
- void WriteXmlAttributes(TiXmlElement* para);
- void testNetwork (const pair<float,float>& InputInterval,
- const float& SecondsPerParameter,
- input* TestInput );
- };
- bool TestParameterCollection();
- #endif // _HPP_PARASCAN
|