private KeyValPair GenerateNextFromG_X(ConditionalDistribution curG_X, SimulationObject prvAgent, SpatialZone currZone, int agentID) { List <KeyValPair> curCom = curG_X.GetCommulativeValue( prvAgent, currZone, agentID); double randVal = myRand.NextDoubleInRange(0, (double) ((KeyValPair)curCom[curCom.Count - 1]).Value); for (int i = 0; i < curCom.Count; i++) { if (randVal <= ((KeyValPair)curCom[i]).Value) { KeyValPair myPair; myPair.Category = ((KeyValPair)curCom[i]).Category; myPair.Value = curG_X.GetValue(curG_X.GetDimensionName(), myPair.Category, prvAgent.GetNewJointKey(curG_X.GetDimensionName()), currZone); return myPair; } } return new KeyValPair(); }