rl_exp.cc - Methods file for rl_exp.h - some experiment details for CAR simulations



// methods for rl_exp.h, experiments that relate to reinforcement-learning // systems. /* Some default val. in C quotes */ #include "rl_exp.h" const char *const Garety91dat::ERROR=" >>---> Garety91dat error : " ; const char *const RBWelcomeDat::ERROR=" >>---> RBWelcomeDat error : " ; // -------------------------------------------------------------------------- Exp_CAR_I::Exp_CAR_I() : CAR3() /*, iter(10) */ { /* NB iter.parNo assignement hidden here ! */ // First, complicated stuff to do with all the iteration parametres : // (file stuff -> vide infra) /* int iparN = iter.ParNo() ; iterParPtr = new float* [iparN+1]; iterIterNo = new float* [iparN+1]; iterEndPtr = new float* [iparN+1]; // Items conscerning influences outside of each oscil. unit // - cf. menu1 in os2t6m.cc // 1A-C: Kxx :range ... and No. of pts. for iteration : Kxx_e = .1 ; Kxx_N = 6. ; iterParPtr[1]= &Kxx; iterEndPtr[1]= &Kxx_e; iterIterNo[1]= &Kxx_N; ... // Items concerning insides of osc. units - cf Menu2 // 2A-C: Main var. concerning oscil. beh AND limiting local response ! Kxy_e = 1.0 * Kxy; Kxy_N = 1. ; iterParPtr[5]= &Kxy ; iterEndPtr[5]= &Kxy_e ; iterIterNo[5]= &Kxy_N ; ... // 2N-O: Assoc/Perc. Qm ratio QmR_e = 1.0 * QmR; QmR_N = 1. ; // iterParPtr[9]= &QmR; iterEndPtr[9]= &QmR_e ; iterIterNo[9]= &QmR_N ; */ // Parametres concerning number of runs of various types done : protN = 3 ; // No. of different protocols per experiment prelimTrN = 100.0 ; // no US or modulation run-in before extp. trials lrnTrN = 50.0 ; // US (and CSs) for this many. runN = 3.0; // default just a few, geared towards display not stats. resPrevNo = 30.0 ; // default - no response prevention " extnBlockTrN = 120 ; RefreshParams() ; // calc. resPrevSt, resPSt, resPEn, // runTrialN, extBlTrN, tRunN and set curTrN to zero. } // end of Exp_CAR_I ctor // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Exp_CAR_I::RefreshParams() { curTrN = 0 ; // If we refresh expt. params, reset Trial N ! extBlTrN = roundfl(extnBlockTrN) ; resPrevSt = prelimTrN+lrnTrN+extBlTrN+1 ; resPSt = roundfl(resPrevSt) ; if (resPrevNo > 1-SMALLFLTSIG) resPEn = roundfl(resPrevSt+resPrevNo-1) ; else resPEn = resPSt - 1 ; // so No of resp. prev. trials, resPEn-resPSt+1 = 0 runTrialN = roundfl(prelimTrN+lrnTrN+extBlTrN+resPrevNo+extBlTrN) ; tRunN = roundfl(protN * runN) ; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int Exp_CAR_I::selGActNoRetDgnResPrev(int state) { if ((curTrN < resPSt) || (curTrN > resPEn)) return selGActNoRetDgn( state ) ; else return Stay() ; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Exp_CAR_I::AuxOutput(float exp_apMod, float exp_AvAt, float exp_ShAmp) { ofstream comments ; // For params etc. comments.open("Exp_I_nb.txt", ios::out); if (comments) { comments <<"\nParametres :\n " ; comments <<"\n appetMod : "<< exp_apMod ; comments <<"\n averMod : "<< exp_AvAt ; comments <<"\n lrnTrN : "<< lrnTrN ; comments <<"\n lrnR (L for V): "<< lrnR ; comments <<"\n lrnRPol (L for policy) : "<< lrnRPol ; comments <<"\n cost of shuttling : "<< shuttleRet ; comments <<"\n Expt. Shock ampl. : "<< exp_ShAmp ; comments <<"\n Vigour modulation : "<< vigourMod ; comments <<"\n Gibbs temperature : "<< Temp ; comments <<"\n Discount rate D: "<< D ; comments <<"\n shuttle action deg.: "<< ShuttleDgn() ; comments <<"\n stay action deg.: "<< StayDgn() ; comments <<"\n total No. of Runs : "<< TRunN() ; comments <<"\n No. of Resp. Prev. trials: "<< ResPrevTrN() ; comments <<"\n No. of Extn. block trials: "<< ExtBlockTrN() ; comments <<"\n\n Epochs: 100 PrelimTrN() trials -> LrnTrN()"; comments <<" learning trials -> block of Extinction trials -> \n" ; comments <<" resPrevNo response prevention trials -> another block of Extinction trials. \n" ; comments <<"\n Protocols: 1, 2 & 3 : PrlimTrN -> no US, no Modulation"; comments <<"\n 1, in addition : N. learning , Modulated extinction"; comments <<"\n 2, in addition : Modulated Learning, Modulated extn."; comments <<"\n 3, in addition : Modulated Learning, 'N' (unmodulated) extn.\n"; } // end write comments, parametres etc. comments.close(); ofstream epochs ; // epochs.open("lrn.out", ios::out); if (epochs) { epochs << PrelimTrN()+1 << '\t' << 0 << '\n' ; epochs << PrelimTrN()+LrnTrN() << '\t' << 0 << '\n' ; } epochs.close(); if ( ResPrevTrN() >= 1 ) { epochs.open("r_p.out", ios::out); if (epochs) { epochs << ResPrevSt() << '\t' << 0 << '\n' ; epochs << ResPrevEn() << '\t' << 0 << '\n' ; } epochs.close(); } } // ================================================================= // eof.