public Person GetNextAgentPerson(DiscreteMarginalDistribution f_x, ConditionalDistribution g_x, string dimension, Person prvAgent, SpatialZone currZone) { KeyValPair currDimVal; double currProb = 0.00; double currRatio = 0.00; int cnt = 0; do { currDimVal = GenerateNextFromG_X(g_x, prvAgent, currZone,0); currProb = f_x.GetValue(currDimVal.Category); currRatio = currProb / currDimVal.Value; if (currRatio > 1.00) { currRatio = 1.00; } if (cnt > 10000) { currRatio = 1; } cnt++; } while (myRand.NextDouble() > currRatio); // Create the household object based on the currDimVal.category return (Person)prvAgent.CreateNewCopy( g_x.GetDimensionName(), Int16.Parse(currDimVal.Category),0); }