/** \brief minimal.cpp is a minimal reference simulation to show how to use the objsimlibrary \author Frank Michler */ #include "sys.hpp" #include "debug.hpp" #include #include #include #include #include #include #include #include //////////////////// int main(int argc, char** argv) { std::string SimName("minimal"); cout << testfunction(); clock_t cpu_start, cpu_end; double cpu_time_used; ////////////////Begin//ProcessCommandLineArguments////////////// cpu_start = clock(); // define some directories std::string HomeDir(getenv("HOME")); std::string BaseDir(HomeDir+"/prog/objsim"); std::string ConfigDir(HomeDir+"/prog/objsim/"+SimName); std::string ConfigFile(ConfigDir+"/settings_"+SimName+".cfg"); // 'a' = dummy; do not use -a !! (setOption without second para doesn't work!!) /** AnyOptionWrapper takes care of simulation parameters 1. names of variables and default parameters are defined. 2. if the config file "settings_" has an entry with the same name as one of the defined variables, the variable is set to the value in the config file. 3. if a command line parameter with the same name as one of the variables is given, the corresponding variable is set to the command line value value. As an example look at "AnyWrapParaInt(InputNx, 10);" AnyWrapParaInt is a macro for defining an integer parameter InputNx is used as the name of the variable, as the identifyer string in the config file settings_minimal.cfg and as the identifyer for the command line argument. The default value for InputNx is 10. This value is used when no config file entry and no command line argument with this name is given. If the config file contains the line "InputNx : 8", InputNx is set to 8. If furthermore, the executable is called with InputNx as command line parameter: "simminimal --InputNx 12", InputNx is set to 12. If command line option MakeDefaultConfig is set (it is a flag, so you don't give a value): "simminimal --MakeDefaultConfig --InputNx 12" then the values of all parameters will be written in the config file settings_minimal.cfg. (fm) 10.11.2008 */ AnyOptionWrapper *myAnyWrap = new AnyOptionWrapper(argc, argv, ConfigFile.c_str()); CSimStandardOptions StdOpt(myAnyWrap); AnyWrapParaStringCmdOnly(SimControlName, ""); AnyWrapParaFloat(WeightStrength, 0.5); AnyWrapParaFloat(Connectivity, 0.1); AnyWrapParaInt(InputNx, 10); AnyWrapParaInt(InputNy, 10); myAnyWrap->process(); ////////////////End//ProcessCommandLineArguments////////////// ////////////////Begin//InitializeGlobalSimLoop SimLoop* MainSimLoop = InitLibCSim(); MainSimLoop->SetDataDirectory(StdOpt.DataDirectory.c_str()); float dt=MainSimLoop->GetDeltaT(); // milli sec cout << "int main(): dt = " << dt << "\n"; myAnyWrap->Save((MainSimLoop->GetDataDirectory() + "/backup_settings").c_str()); delete myAnyWrap; system(("cp progversion.txt "+MainSimLoop->GetDataDirectory()).c_str()); ////////////////End//InitializeGlobalSimLoop int i, j, k, sec, t; ////////////////End//ProcessCommandLineArguments////////////// ////////////////////////////////////////////// //////// Setup Neuron Layer izh8layer* MyLayer = new izh8layer(InputNx*InputNy, IzhParaThalamoCortical); MyLayer->SetName("MyLayer"); MyLayer->SetupPositions(InputNx, InputNy, true); // MyLayer->TuneNoiseAmplitude(3); MyLayer->SetNoiseAmplitude(0.0035926); MainSimLoop->AddSimElement(MyLayer); ////////// Setup connections connection *MyConnection = new connection(MyLayer, MyLayer, csimInputChannel_AMPA); MyConnection->SetName("MyConnection"); if (!StdOpt.LoadWeights || (MyConnection->Load() != 0)) { MyConnection->ConnectRandom(Connectivity, WeightStrength); } MyConnection->Save(); MainSimLoop->AddSimElement(MyConnection); ////////// Setup Input vector > StimulusArray; int NStim=2; float PatternSize=1./float(NStim); for (int i=0;i CurStimArray(InputNx*InputNy); int DiffStart = int(i*PatternSize*InputNx*InputNy); int DiffStop = int((i+1)*PatternSize*InputNx*InputNy); if ((DiffStart <=InputNx*InputNy) && (DiffStop <=InputNx*InputNy)) { for (int xx=DiffStart;xxSetPictureArray(StimulusArray); MyInput->SetName("TwoPatternInput"); // Input->SetMode(csimInputRandom); MainSimLoop->AddSimElement(MyInput); //////////////////////////////////// int trial, step; sec =0; int TotalTime=0; MainSimLoop->Hallo(); MainSimLoop->SaveSimInfo(); cout << "StdOpt.NTrials" << StdOpt.NTrials << "StdOpt.NSteps" << StdOpt.NSteps << "\n"; fflush(stdout); for (trial=0; trialproceede(1000*step+t); } MainSimLoop->prepare(step); } if (SimControlName != "") system((BaseDir + "/scripts/mytksend " + SimControlName + " SetTrialNr " +stringify(trial)+ " &").c_str()); } cpu_end=clock(); cpu_time_used = ((double) (cpu_end - cpu_start)) / CLOCKS_PER_SEC; cout << "\n\n***********CpuTimeUsed= " << cpu_time_used << " seconds \n"; if (StdOpt.SimFinishButton) system((BaseDir + "/scripts/bluetclbutton Simulation finished &").c_str()); }