/** * Simulate the Columbian health care system for a village. * * @return a list of patients refered to the next village */ public List <Patient> simulate() { // the list of patients refered from each child village Patient p; for (int i = 0; i < this.forward.Length; ++i) { Village v = this.forward [i]; List <Patient> val = new List <Patient> (); if (v != null) { val = v.simulate(); } for (int j = 0; j < val.Count; ++j) { hospital.putInHospital(val [j]); } } hospital.checkPatientsInside(returned); List <Patient> up = hospital.checkPatientsAssess(this); hospital.checkPatientsWaiting(); // generate new patients p = generatePatient(); if (p != null) { hospital.putInHospital(p); } return(up); }
/** * The main routnie which creates the data structures for the Columbian * health-care system and executes the simulation for a specified time. * * @param args the command line arguments */ public static void Main(String[] args, ILog ilog) { logger = ilog; parseCmdLine(args); Village.initVillageStatic(); Village top = Village.createVillage(maxLevel, 0, true, 1); if (printMsgs) { logger.InfoFormat("Columbian Health Care Simulator\nWorking..."); } for (int i = 0; i < maxTime; i++) { top.simulate(); } Results r = top.getResults(); if (printResult) { logger.InfoFormat("# People treated: " + (int)r.totalPatients); logger.InfoFormat("Avg. length of stay: " + r.totalTime / r.totalPatients); logger.InfoFormat("Avg. # of hospitals visited: " + r.totalHospitals / r.totalPatients); } logger.InfoFormat("Done!"); }