private List<SimulationObject> GeneratePersons(SpatialZone currZone, int numPerson, Person initAgent, bool warmUpStatus, OutputFileWriter currWriter) { int seltdDim = 0; List<ConditionalDistribution> condList = currZone.GetPersonDataCollectionsList(); var generatedAgents = new List<SimulationObject>(); Person prevAgent = initAgent; ImportanceSampler currImpSampler = new ImportanceSampler(); int iter = 0; if(warmUpStatus == true) { iter = Constants.WARMUP_ITERATIONS; } else { iter = Constants.SKIP_ITERATIONS * numPerson; } Person newAgent = new Person(); StringBuilder builder = new StringBuilder(); for(int i = 0; i < iter; i++) { seltdDim = randGen.NextInRange(0, condList.Count - 1); DiscreteCondDistribution currDist = (DiscreteCondDistribution)condList[seltdDim]; /*if (currDist.GetDimensionName() == "HouseholdSize2") { newAgent = (Person) currImpSampler.GetNextAgent( currZone.myHhldSize2Marginal, currDist, currDist.GetDimensionName(), (SimulationObject) prevAgent, currZone); } else if (currDist.GetDimensionName() == "Age") { newAgent = (Person)currImpSampler.GetNextAgent( currZone.myAgeMarginal, currDist, currDist.GetDimensionName(), (SimulationObject)prevAgent, currZone); } else*/ if(currDist.GetDimensionName() == "Sex") { newAgent = (Person)currImpSampler.GetNextAgent( currZone.mySexMarginal, currDist, currDist.GetDimensionName(), (SimulationObject)prevAgent, currZone); } /*else if (currDist.GetDimensionName() == "EducationLevel") { newAgent = (Person)currImpSampler.GetNextAgent( currZone.myEducationMarginal, currDist, currDist.GetDimensionName(), (SimulationObject)prevAgent, currZone); }*/ else { List<KeyValPair> currComm = currDist.GetCommulativeValue( prevAgent.GetNewJointKey(currDist.GetDimensionName()) , currZone); newAgent = (Person)GenerateNextAgent(currComm, (SimulationObject)prevAgent, currDist.GetDimensionName()); } prevAgent = newAgent; if(warmUpStatus == false && (i % Constants.SKIP_ITERATIONS == 0)) { //generatedAgents.Add(newAgent); builder.Append((int)newAgent.GetAge()); builder.Append(','); builder.Append(newAgent.GetZoneID()); builder.Append(','); builder.Append((int)newAgent.GetSex()); builder.Append(','); builder.Append((int)newAgent.GetHhldSize()); builder.Append(','); builder.Append((int)newAgent.GetEducationLevel()); currWriter.WriteToFile(builder.ToString()); builder.Clear(); } } return generatedAgents; }