void EventNumberContainer::display_nonzeroEvents(){ unsigned long N = _event_label.size(); cout << "Event Label \t sub-Label \t n Events"<<endl; coutline(40); for(int i=0; i<N; i++){ if(_n_event[i]>0) cout << _event_label[i]<<"\t"<<_event_sublabel[i]<<"\t"<<_n_event[i]<<endl; } coutline(40); }
void dcDataFrame::display() { unsigned int n = _rowname.size(); unsigned int ncol = _value.getNbCols(); cout << endl << "dcDataFrame Content:"<<endl; string sep = "\t\t|\t"; if (ncol==0) cout << "EMPTY!"<<endl; // Print headers if (ncol>0) { cout << "_rowname" << sep; for (int i=0; i<ncol; i++) cout << _colname[i] << sep; cout<<endl; } if (ncol==1) { coutline(20); for (int i=0; i<n; i++) { cout << _rowname[i] << sep << _value[i] <<endl; } coutline(20); } if (ncol>1) { coutline(80); for (int i=0; i<n; i++) { cout << _rowname[i] << sep; for (int j=0;j<ncol; j++) cout << _value(i,j)<<"\t"; cout << endl; } coutline(80); } }
void simulator::displayInfo() { coutline(40); cout<<" === SIMULATOR INFO ==="<<endl; cout << "Population size: "<<_indiv.size()<<endl; cout << "# E compartments: " << _nE <<endl; cout << "# I compartments: " << _nI <<endl; cout << "sigma rates:"; displayVector(_sigma); cout << "gamma rates:"; displayVector(_gamma); double R0 = _beta/_gamma[0]*_nI; cout << "R0 = "<<R0<<endl; cout << "Number of events: "<<_time.size()<<endl; cout << "Last date: "<<_time[_time.size()-1]<<endl; cout << "Cumul incidence: "<<_cumIncidence[_cumIncidence.size()-1]<<endl; coutline(40); }
int main(int argc, const char * argv[]) { // UNIT JOB FOR CALIBRATION // ====================== // // ARG #1: JOB NUMBER // ARG #2: NUMBER OF LHS EXECUTIONS PER JOB // ARG #3: MONTE CARLO RUNS (FOR EACH LHS) // For performance monitoring // - do not delete - timeval tim; gettimeofday(&tim, NULL); double t1=tim.tv_sec+(tim.tv_usec/1000000.0); if (argc<3) { cout <<endl << " ERROR in Job Unit ('main_jobUnit.cpp'): not enough arguments" << endl; exit(1); } cout << endl << " === JOB UNIT #"<<argv[1]<<" (nrows="<< argv[2] <<") ==="<<endl; // Parameters file name string fname = _DIR_CALIB + "calib_LHS_SF_input_" ; int i_job = atoi(argv[1]); int nrows = atoi(argv[2]); int nMC_calibration = atoi(argv[3]); // === PRE CALIBRATION === // Start from an unpartnered population // Initialize empty Population object Population P0(0); // Read starting population from a file // output of "generateIndividuals.R" P0.initFromFile("startPopulation.csv", "in_STI.csv", "in_STI_SFincrease.csv", "in_HIVrebound.csv"); // Set all parameters P0.setAllParameters(); // Set-up pre-calibration simulation double horizon_preCalib = 60.0; double timestep_preCalib = 0.25; Simulation S_preCalib(horizon_preCalib, timestep_preCalib, P0, 0); // Pre-calibration run to form partnerships first bool logIndivInfo = false; bool doSex = false; bool traceNetwork = false; bool displayProgress = 0; S_preCalib.runAllEvents_horizon(doSex, logIndivInfo, traceNetwork, displayProgress); // Seed STIs' initial prevalence S_preCalib.STI_set_initial_prevalence("in_STI_initial_prevalence.csv"); coutline(80); cout << " PRE CALIBRATION POPULATION:"; S_preCalib.get_population().displayInfo(false); Population P1 = S_preCalib.get_population(); // == END PRE-CALIBRATION == // ================= // Horizon for the calibration string file_calibration = _DIR_CALIB + "in_calibration.csv"; double horizon_calib = getParameterFromFile("horizon_calib", file_calibration); double timeStep_calib = getParameterFromFile("timeStep_calib", file_calibration); // Runs the calibration using the // parameters limits defined in the files defined by the job number calibration_LHS_fromFile(_DIR_CALIB + "calibration_filename_wrapper.csv", // Parameters (pre-sampled) fname + "DMG_"+int2string(i_job)+".csv", fname + "FORM_"+int2string(i_job)+".csv", fname + "SPOUSAL_"+int2string(i_job)+".csv", fname + "DISSOL_"+int2string(i_job)+".csv", fname + "SEXACT_"+int2string(i_job)+".csv", fname + "STIFTR_V_"+int2string(i_job)+".csv", fname + "STIFTR_B_"+int2string(i_job)+".csv", fname + "STIFTR_P_"+int2string(i_job)+".csv", fname + "STIFTR_F_"+int2string(i_job)+".csv", nrows, i_job, P1, horizon_calib, timeStep_calib, nMC_calibration); // -------------------------------------------------------------- // COMPUTER TIME MONITORING - do not delete! gettimeofday(&tim, NULL); double t2=tim.tv_sec+(tim.tv_usec/1000000.0); int minutes = (int)((t2-t1)/60.0); double sec = (t2-t1)-minutes*60.0; // -------------------------------------------------------------- cout << endl << "~~~> JOB UNIT #"<<argv[1]<<" was completed in "; cout << minutes<<" min "<<sec<<" sec" << endl; return 0; }
int main(int argc, const char * argv[]) { // ============================================== // SERIAL FARMING WRAPPER FOR MONTE CARLO RUNS // ============================================== // // Integrity checks stopif(argc<=1,"Serial Farming: not enough arguments!"); // retrieve the type of execution std::string arg1(argv[1]); bool doSingleRun = (arg1=="singlerun"?true:false); bool doScenario = (arg1=="scenario"?true:false); stopif(!doSingleRun && !doScenario, "Serial Farming: unknown execution type!"); // DEBUG informations system("date"); system("pwd"); // Clean all previous output files // (some files are incremental, so can get huge) system("./cleanout"); // simple time stamp ofstream fstart("SF_MC_timestamp.txt"); fstart<<"dummy"<<endl; // retrieve execution parameters int nMCtotal = getParameterFromFile("MCiter", _DIR_IN + "in_simulation.csv"); int nCPU = getParameterFromFile("nCPU", _DIR_IN + "in_simulation.csv"); int nMCperCPU = nMCtotal/nCPU; coutline(80); cout << "*** SINGLE SIMULATION WITH "<<nMCtotal<<" MC ITERATIONS ***"<<endl; // Mandatory code checks //CODECHECK_mandatory(); // Launch unit jobs (1 for each CPU) for (int i_job = 1; i_job <= nCPU; i_job++) { // -- for sharcnet -- // string sharc_cmd = "sqsub -o alljobs.out -r 1d --mpp 1G ./stiagent_U " // + int2string(i_job) + " " + int2string(nrows)+ " " + int2string(nMC_calibration); // Determine the type of execution string unit_name; if (doSingleRun) unit_name = "./tphiv_U_MC "; if (doScenario) unit_name = "./tphiv_U_SCEN "; // DEBUG if (doScenario) cout <<endl<<" SCENARIO MODE"<<endl; // ----- // Execution string local_cmd = unit_name + int2string(i_job) + " " + int2string(nMCperCPU) + " &"; string cmd_line = local_cmd; system(cmd_line.c_str()); cout << "Unit job " + int2string(i_job) + "/"<<nCPU<<" launched..." <<endl; } return 0; }