private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, IPersonDayWrapper personDay, IHouseholdDayWrapper householdDay, int maxPurpose, int choice = Constants.DEFAULT_VALUE)
        {
            IEnumerable <PersonDayWrapper> orderedPersonDays = householdDay.PersonDays.OrderBy(p => p.GetJointTourParticipationPriority()).ToList().Cast <PersonDayWrapper>();

            IPersonWrapper    person          = personDay.Person;
            IHouseholdWrapper household       = householdDay.Household;
            IParcelWrapper    residenceParcel = household.ResidenceParcel;

            int carOwnership =
                household.VehiclesAvailable == 0
                                 ? Global.Settings.CarOwnerships.NoCars
                                 : household.VehiclesAvailable < household.HouseholdTotals.DrivingAgeMembers
                                      ? Global.Settings.CarOwnerships.LtOneCarPerAdult
                                      : Global.Settings.CarOwnerships.OneOrMoreCarsPerAdult;

            int noCarsFlag         = FlagUtility.GetNoCarsFlag(carOwnership);
            int carCompetitionFlag = FlagUtility.GetCarCompetitionFlag(carOwnership);

            int    votALSegment                    = household.GetVotALSegment();
            int    transitAccessSegment            = household.ResidenceParcel.TransitAccessSegment();
            double personalBusinessAggregateLogsum = Global.AggregateLogsums[household.ResidenceParcel.ZoneId]
                                                     [Global.Settings.Purposes.PersonalBusiness][carOwnership][votALSegment][transitAccessSegment];
            double shoppingAggregateLogsum = Global.AggregateLogsums[household.ResidenceParcel.ZoneId]
                                             [Global.Settings.Purposes.Shopping][carOwnership][votALSegment][transitAccessSegment];
            double mealAggregateLogsum = Global.AggregateLogsums[household.ResidenceParcel.ZoneId]
                                         [Global.Settings.Purposes.Meal][carOwnership][votALSegment][transitAccessSegment];
            double socialAggregateLogsum = Global.AggregateLogsums[household.ResidenceParcel.ZoneId]
                                           [Global.Settings.Purposes.Social][carOwnership][votALSegment][transitAccessSegment];
            double totalAggregateLogsum = Global.AggregateLogsums[household.ResidenceParcel.ZoneId]
                                          [Global.Settings.Purposes.HomeBasedComposite][carOwnership][votALSegment][transitAccessSegment];

            // var recreationAggregateLogsum = Global.AggregateLogsums[household.ResidenceParcel.ZoneId]
            // [Global.Settings.Purposes.Recreation][carOwnership][votALSegment][transitAccessSegment];
            //  var medicalAggregateLogsum = Global.AggregateLogsums[household.ResidenceParcel.ZoneId]
            //  [Global.Settings.Purposes.Medical][carOwnership][votALSegment][transitAccessSegment];

            int[] nonMandPerstype = new int[8];
            int[] mandPerstype    = new int[8];

            //int mandatoryAdult=0;
            //int mandatoryChild=0;
            //int nonMandatoryWorker=0;
            //int nonMandatoryNonWorker=0;
            //int nonMandatoryRetired=0;
            //int nonMandatoryChild=0;

            int countNonMandatory = 0;
            int countMandatory    = 0;

            double workLogsum   = 0;
            double schoolLogsum = 0;

            //int worksAtHome=0;
            int countWorkingAtHome = 0;

            int workDestinationArrivalTime   = 0;
            int workDestinationDepartureTime = 0;

            int numStopPurposes = 0;
            int numTourPurposes = 0;

            numTourPurposes = (personDay.CreatedEscortTours > 1).ToFlag() + (personDay.CreatedShoppingTours > 1).ToFlag() + (personDay.CreatedMealTours > 1).ToFlag() +
                              (personDay.CreatedPersonalBusinessTours > 1).ToFlag() + (personDay.CreatedSocialTours > 1).ToFlag() +
                              (personDay.CreatedRecreationTours > 1).ToFlag() + (personDay.CreatedMedicalTours > 1).ToFlag();


            numStopPurposes = (personDay.SimulatedEscortStops > 1).ToFlag() + (personDay.SimulatedShoppingStops > 1).ToFlag() + (personDay.SimulatedMealStops > 1).ToFlag() +
                              (personDay.SimulatedPersonalBusinessStops > 1).ToFlag() + (personDay.SimulatedSocialStops > 1).ToFlag() +
                              (personDay.SimulatedRecreationStops > 1).ToFlag() + (personDay.SimulatedMedicalStops > 1).ToFlag();


            if (person.UsualWorkParcel == null || person.UsualWorkParcelId == household.ResidenceParcelId)
            {
                workLogsum = 0;
            }
            else
            {
                workDestinationArrivalTime   = ChoiceModelUtility.GetDestinationArrivalTime(Global.Settings.Models.WorkTourModeModel);
                workDestinationDepartureTime = ChoiceModelUtility.GetDestinationDepartureTime(Global.Settings.Models.WorkTourModeModel);
                ChoiceProbabilityCalculator.Alternative nestedAlternative = Global.ChoiceModelSession.Get <WorkTourModeTimeModel>().RunNested(personDay, residenceParcel, person.UsualWorkParcel, workDestinationArrivalTime, workDestinationDepartureTime, household.VehiclesAvailable);

                workLogsum = nestedAlternative == null ? 0 : nestedAlternative.ComputeLogsum();
            }

            if (person.UsualSchoolParcel == null || person.UsualSchoolParcelId == household.ResidenceParcelId)
            {
                schoolLogsum = 0;
            }
            else
            {
                int destinationArrivalTime   = ChoiceModelUtility.GetDestinationArrivalTime(Global.Settings.Models.SchoolTourModeModel);
                int destinationDepartureTime = ChoiceModelUtility.GetDestinationDepartureTime(Global.Settings.Models.SchoolTourModeModel);
                ChoiceProbabilityCalculator.Alternative nestedAlternative = Global.ChoiceModelSession.Get <SchoolTourModeTimeModel>().RunNested(personDay, residenceParcel, person.UsualSchoolParcel, destinationArrivalTime, destinationDepartureTime, household.VehiclesAvailable);

                schoolLogsum = nestedAlternative == null ? 0 : nestedAlternative.ComputeLogsum();
            }

            //if (personDay.WorksAtHomeFlag == 1) {
            //    worksAtHome =1;
            //}


            int count = 0;

            foreach (PersonDayWrapper pDay in orderedPersonDays)
            {
                count++;
                if (count > 8)
                {
                    break;
                }
                if (pDay.WorksAtHomeFlag == 1)
                {
                    countWorkingAtHome++;
                }
                if (pDay.PatternType == 1)
                {
                    countMandatory++;
                }
                if (pDay.PatternType == 2)
                {
                    countNonMandatory++;
                }
            }


            // NONE_OR_HOME

            ChoiceProbabilityCalculator.Alternative alternative = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.NoneOrHome, true, choice == Global.Settings.Purposes.NoneOrHome);

            alternative.Choice = Global.Settings.Purposes.NoneOrHome;
            //alternative.AddUtilityTerm(2, (personDay.GetTotalCreatedTours()== 2).ToFlag());
            //alternative.AddUtilityTerm(3,  (personDay.GetTotalCreatedTours()==3).ToFlag());
            alternative.AddUtilityTerm(4, (personDay.GetTotalCreatedTours() >= 4).ToFlag());
            alternative.AddUtilityTerm(5, (numStopPurposes >= 1).ToFlag());
            alternative.AddUtilityTerm(6, (numTourPurposes >= 2).ToFlag());
            alternative.AddUtilityTerm(7, personDay.CreatedWorkTours + personDay.CreatedSchoolTours);
            alternative.AddUtilityTerm(8, (personDay.JointTours));
            alternative.AddUtilityTerm(9, Math.Log(1 + (workDestinationDepartureTime - workDestinationArrivalTime) / 60));
            //alternative.AddUtilityTerm(10,  (household.Size==1).ToFlag());
            //alternative.AddNestedAlternative(11, 0, 200);

            // WORK
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.Work, false, choice == Global.Settings.Purposes.Work);
            alternative.Choice = Global.Settings.Purposes.Work;
            alternative.AddUtilityTerm(198, 1);
            //alternative.AddNestedAlternative(12, 1, 200);

            //  SCHOOL
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.School, false, choice == Global.Settings.Purposes.School);
            alternative.Choice = Global.Settings.Purposes.School;
            alternative.AddUtilityTerm(199, 1);
            //alternative.AddNestedAlternative(12, 1, 200);

            // ESCORT
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.Escort, maxPurpose <= Global.Settings.Purposes.Escort && personDay.CreatedEscortTours > 0, choice == Global.Settings.Purposes.Escort);
            alternative.Choice = Global.Settings.Purposes.Escort;

            alternative.AddUtilityTerm(11, 1);
            alternative.AddUtilityTerm(12, (personDay.PatternType == 2).ToFlag());
            alternative.AddUtilityTerm(13, personDay.JointTours);
            alternative.AddUtilityTerm(14, (personDay.EscortStops > 0).ToFlag());
            alternative.AddUtilityTerm(15, (personDay.CreatedEscortTours > 1).ToFlag());
            alternative.AddUtilityTerm(17, (household.HouseholdType == Global.Settings.HouseholdTypes.TwoPlusWorkerStudentAdultsWithChildren).ToFlag() + (
                                           household.HouseholdType == Global.Settings.HouseholdTypes.TwoPlusAdultsOnePlusWorkersStudentsWithChildren).ToFlag());
            alternative.AddUtilityTerm(20, (household.HouseholdType == Global.Settings.HouseholdTypes.OneAdultWithChildren).ToFlag());
            alternative.AddUtilityTerm(25, (person.PersonType == Global.Settings.PersonTypes.PartTimeWorker).ToFlag());
            alternative.AddUtilityTerm(28, (person.PersonType == Global.Settings.PersonTypes.ChildUnder5).ToFlag());
            alternative.AddUtilityTerm(29, (person.PersonType == Global.Settings.PersonTypes.ChildAge5Through15).ToFlag());
            alternative.AddUtilityTerm(31, (person.PersonType == Global.Settings.PersonTypes.UniversityStudent).ToFlag());
            alternative.AddUtilityTerm(32, countMandatory);
            // alternative.AddUtilityTerm(33, personDay.CreatedWorkTours);

            //alternative.AddNestedAlternative(12, 1, 200);

            // PERSONAL_BUSINESS
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.PersonalBusiness, maxPurpose <= Global.Settings.Purposes.PersonalBusiness && personDay.CreatedPersonalBusinessTours > 0, choice == Global.Settings.Purposes.PersonalBusiness);
            alternative.Choice = Global.Settings.Purposes.PersonalBusiness;
            alternative.AddUtilityTerm(41, 1);
            alternative.AddUtilityTerm(42, (personDay.PatternType == 2).ToFlag());
            alternative.AddUtilityTerm(43, (personDay.PersonalBusinessStops > 0).ToFlag());
            alternative.AddUtilityTerm(44, personalBusinessAggregateLogsum);
            alternative.AddUtilityTerm(45, (household.HouseholdType == Global.Settings.HouseholdTypes.IndividualWorkerStudent).ToFlag());
            alternative.AddUtilityTerm(46, (household.HouseholdType == Global.Settings.HouseholdTypes.IndividualNonworkerNonstudent).ToFlag());
            alternative.AddUtilityTerm(47, (personDay.CreatedWorkTours + personDay.CreatedSchoolTours));


            // SHOPPING
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.Shopping, maxPurpose <= Global.Settings.Purposes.Shopping && personDay.CreatedShoppingTours > 0, choice == Global.Settings.Purposes.Shopping);
            alternative.Choice = Global.Settings.Purposes.Shopping;

            alternative.AddUtilityTerm(61, 1);
            alternative.AddUtilityTerm(52, (personDay.PatternType == 2).ToFlag());
            alternative.AddUtilityTerm(54, (personDay.ShoppingStops > 0).ToFlag());
            //alternative.AddUtilityTerm(55, Math.Log(1+person.Household.ResidenceParcel.EmploymentRetailBuffer2));
            alternative.AddUtilityTerm(56, shoppingAggregateLogsum);
            alternative.AddUtilityTerm(57, (person.PersonType == Global.Settings.PersonTypes.RetiredAdult).ToFlag());
            alternative.AddUtilityTerm(58, (household.HouseholdType == Global.Settings.HouseholdTypes.OnePlusWorkerStudentAdultsAndOnePlusNonworkerNonstudentAdultsWithoutChildren).ToFlag());
            alternative.AddUtilityTerm(60, (household.HouseholdType == Global.Settings.HouseholdTypes.IndividualWorkerStudent).ToFlag());
            alternative.AddUtilityTerm(69, (person.PersonType == Global.Settings.PersonTypes.UniversityStudent).ToFlag());
            alternative.AddUtilityTerm(70, (household.Has100KPlusIncome).ToFlag());

            // MEAL
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.Meal, maxPurpose <= Global.Settings.Purposes.Meal && personDay.CreatedMealTours > 0, choice == Global.Settings.Purposes.Meal);
            alternative.Choice = Global.Settings.Purposes.Meal;
            alternative.AddUtilityTerm(71, 1);
            alternative.AddUtilityTerm(72, (personDay.PatternType == 2).ToFlag());
            alternative.AddUtilityTerm(74, mealAggregateLogsum);
            alternative.AddUtilityTerm(80, (household.HouseholdType == Global.Settings.HouseholdTypes.IndividualWorkerStudent).ToFlag());
            alternative.AddUtilityTerm(82, (household.HouseholdType == Global.Settings.HouseholdTypes.TwoPlusNonworkerNonstudentAdultsWithoutChildren).ToFlag());
            alternative.AddUtilityTerm(85, (person.PersonType == Global.Settings.PersonTypes.RetiredAdult).ToFlag());

            // SOCIAL
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.Social, maxPurpose <= Global.Settings.Purposes.Social && personDay.CreatedSocialTours > 0, choice == Global.Settings.Purposes.Social);
            alternative.Choice = Global.Settings.Purposes.Social;

            alternative.AddUtilityTerm(111, 1);
            alternative.AddUtilityTerm(112, (personDay.PatternType == 2).ToFlag());
            alternative.AddUtilityTerm(113, household.HouseholdTotals.ChildrenUnder16);
            //alternative.AddUtilityTerm(114, socialAggregateLogsum);
            alternative.AddUtilityTerm(115, Math.Log(1 + person.Household.ResidenceParcel.HouseholdsBuffer2));
            alternative.AddUtilityTerm(122, (household.HouseholdType == Global.Settings.HouseholdTypes.TwoPlusNonworkerNonstudentAdultsWithoutChildren).ToFlag());
            alternative.AddUtilityTerm(123, (person.PersonType == Global.Settings.PersonTypes.PartTimeWorker).ToFlag());
            alternative.AddUtilityTerm(126, (person.PersonType == Global.Settings.PersonTypes.ChildUnder5).ToFlag());
            alternative.AddUtilityTerm(127, (person.PersonType == Global.Settings.PersonTypes.ChildAge5Through15).ToFlag());
            alternative.AddUtilityTerm(130, (person.PersonType == Global.Settings.PersonTypes.RetiredAdult).ToFlag());

            // RECREATION
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.Recreation, maxPurpose <= Global.Settings.Purposes.Recreation && personDay.CreatedRecreationTours > 0, choice == Global.Settings.Purposes.Recreation);
            alternative.Choice = Global.Settings.Purposes.Recreation;
            alternative.AddUtilityTerm(111, 1);
            alternative.AddUtilityTerm(112, (personDay.PatternType == 2).ToFlag());
            alternative.AddUtilityTerm(113, household.HouseholdTotals.ChildrenUnder16);
            //alternative.AddUtilityTerm(114, totalAggregateLogsum);
            alternative.AddUtilityTerm(115, Math.Log(1 + person.Household.ResidenceParcel.HouseholdsBuffer2));
            alternative.AddUtilityTerm(122, (household.HouseholdType == Global.Settings.HouseholdTypes.TwoPlusNonworkerNonstudentAdultsWithoutChildren).ToFlag());
            alternative.AddUtilityTerm(123, (person.PersonType == Global.Settings.PersonTypes.PartTimeWorker).ToFlag());
            alternative.AddUtilityTerm(126, (person.PersonType == Global.Settings.PersonTypes.ChildUnder5).ToFlag());
            alternative.AddUtilityTerm(127, (person.PersonType == Global.Settings.PersonTypes.ChildAge5Through15).ToFlag());
            alternative.AddUtilityTerm(128, (household.Has100KPlusIncome).ToFlag());

            // MEDICAL
            alternative        = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.Medical, maxPurpose <= Global.Settings.Purposes.Medical && personDay.CreatedMedicalTours > 0, choice == Global.Settings.Purposes.Medical);
            alternative.Choice = Global.Settings.Purposes.Medical;
            alternative.AddUtilityTerm(131, 1);
            alternative.AddUtilityTerm(132, Math.Log(1 + household.ResidenceParcel.EmploymentMedicalBuffer2));
            alternative.AddUtilityTerm(133, (person.PersonType == Global.Settings.PersonTypes.RetiredAdult).ToFlag());
            //alternative.AddNestedAlternative(11, 1, 60);
        }
        private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, IPersonDayWrapper personDay, IHouseholdDayWrapper householdDay, int nCallsForTour, int[] simulatedMandatoryTours, int choice = Constants.DEFAULT_VALUE)
        {
            IHouseholdWrapper household = personDay.Household;

            IEnumerable <PersonDayWrapper> orderedPersonDays = householdDay.PersonDays.OrderBy(p => p.GetJointTourParticipationPriority()).ToList().Cast <PersonDayWrapper>();


            int carOwnership =
                household.VehiclesAvailable == 0
                                 ? Global.Settings.CarOwnerships.NoCars
                                 : household.VehiclesAvailable < household.HouseholdTotals.DrivingAgeMembers
                                      ? Global.Settings.CarOwnerships.LtOneCarPerAdult
                                      : Global.Settings.CarOwnerships.OneOrMoreCarsPerAdult;

            int noCarsFlag         = FlagUtility.GetNoCarsFlag(carOwnership);
            int carCompetitionFlag = FlagUtility.GetCarCompetitionFlag(carOwnership);

            int votALSegment         = household.GetVotALSegment();
            int transitAccessSegment = household.ResidenceParcel.TransitAccessSegment();

            double workTourLogsum    = 0;
            double schoolTourLogsum  = 0;
            double schoolPclUniStu   = 0;
            double schoolPclStudents = 0;
            double schoolIntrDens    = 0;
            double workPclWrkrs      = 0;
            double workIntrDens      = 0;
            int    noUsualWorkZone   = 1;


            if (personDay.Person.UsualWorkParcelId != Constants.DEFAULT_VALUE && personDay.Person.UsualWorkParcelId != Global.Settings.OutOfRegionParcelId)
            {
                if (personDay.Person.UsualDeparturePeriodFromWork != Constants.DEFAULT_VALUE && personDay.Person.UsualArrivalPeriodToWork != Constants.DEFAULT_VALUE)
                {
                    ChoiceProbabilityCalculator.Alternative nestedAlternative = Global.ChoiceModelSession.Get <WorkTourModeTimeModel>().RunNested(personDay, personDay.Person.Household.ResidenceParcel, personDay.Person.UsualWorkParcel, (int)personDay.Person.UsualArrivalPeriodToWork, (int)personDay.Person.UsualDeparturePeriodFromWork, personDay.Person.Household.HouseholdTotals.DrivingAgeMembers);
                    workTourLogsum = nestedAlternative == null ? 0 : nestedAlternative.ComputeLogsum();
                    workPclWrkrs   = Math.Log(1 + (personDay.Person.UsualWorkParcel.EmploymentTotalBuffer2)) / 10;
                    workIntrDens   = Math.Log(1 + personDay.Person.UsualWorkParcel.C34RatioBuffer1());
                }
                else
                {
                    ChoiceProbabilityCalculator.Alternative nestedAlternative = Global.ChoiceModelSession.Get <WorkTourModeTimeModel>().RunNested(personDay, personDay.Person.Household.ResidenceParcel, personDay.Person.UsualWorkParcel, Global.Settings.Times.EightAM, Global.Settings.Times.FivePM, personDay.Person.Household.HouseholdTotals.DrivingAgeMembers);
                    workTourLogsum = nestedAlternative == null ? 0 : nestedAlternative.ComputeLogsum();
                }

                noUsualWorkZone = 0;
            }


            if (personDay.Person.UsualSchoolParcelId != 0 && personDay.Person.UsualSchoolParcelId != -1 && personDay.Person.UsualSchoolParcelId != Global.Settings.OutOfRegionParcelId)
            {
                schoolPclUniStu = Math.Log(1 + (personDay.Person.UsualSchoolParcel.StudentsUniversityBuffer2)) / 10;
                ChoiceProbabilityCalculator.Alternative schoolNestedAlternative = Global.ChoiceModelSession.Get <SchoolTourModeTimeModel>().RunNested(personDay, personDay.Person.Household.ResidenceParcel, personDay.Person.UsualSchoolParcel, Global.Settings.Times.EightAM, Global.Settings.Times.TwoPM, personDay.Person.Household.HouseholdTotals.DrivingAgeMembers);
                schoolTourLogsum = schoolNestedAlternative == null ? 0 : schoolNestedAlternative.ComputeLogsum();
            }


            int countNonMandatory = (from personDayHH in orderedPersonDays where personDayHH.PatternType == 2 select personDayHH.PatternType).Count();

            bool schoolAvailableFlag = true;

            if (!personDay.Person.IsStudent || (!Global.Configuration.IsInEstimationMode && personDay.Person.UsualSchoolParcel == null))
            {
                schoolAvailableFlag = false;
            }

            // NONE_OR_HOME

            ChoiceProbabilityCalculator.Alternative alternative = choiceProbabilityCalculator.GetAlternative(Global.Settings.Purposes.NoneOrHome, nCallsForTour > 1, choice == Global.Settings.Purposes.NoneOrHome);

            alternative.Choice = Global.Settings.Purposes.NoneOrHome;
            alternative.AddUtilityTerm(3, (nCallsForTour > 2).ToFlag());


            // USUAL WORK
            alternative        = choiceProbabilityCalculator.GetAlternative(1, (personDay.Person.UsualWorkParcelId > 0 && simulatedMandatoryTours[2] == 0 && simulatedMandatoryTours[3] == 0), choice == 1);
            alternative.Choice = 1;
            alternative.AddUtilityTerm(21, 1);
            alternative.AddUtilityTerm(23, workTourLogsum);
            alternative.AddUtilityTerm(25, (personDay.Person.IsPartTimeWorker).ToFlag());
            alternative.AddUtilityTerm(26, (personDay.Person.IsUniversityStudent).ToFlag());
            alternative.AddUtilityTerm(28, (personDay.Person.Household.Has100KPlusIncome).ToFlag());
            alternative.AddUtilityTerm(29, personDay.Person.Household.ResidenceParcel.MixedUse2Index1());
            alternative.AddUtilityTerm(30, (personDay.Person.Age <= 30).ToFlag());
            alternative.AddUtilityTerm(31, workPclWrkrs);
            alternative.AddUtilityTerm(32, ((simulatedMandatoryTours[1] > 0).ToFlag()));
            alternative.AddUtilityTerm(33, workIntrDens);
            alternative.AddUtilityTerm(36, (personDay.WorksAtHomeFlag));
            alternative.AddUtilityTerm(38, (personDay.Person.Household.ResidenceParcel.GetDistanceToTransit() > 1).ToFlag());

            // OTHER WORK
            alternative        = choiceProbabilityCalculator.GetAlternative(2, (personDay.Person.IsWorker && simulatedMandatoryTours[3] == 0), choice == 2);
            alternative.Choice = 2;
            alternative.AddUtilityTerm(41, 1);
            alternative.AddUtilityTerm(42, (personDay.Person.IsPartTimeWorker).ToFlag());
            alternative.AddUtilityTerm(43, (personDay.Person.IsUniversityStudent).ToFlag());
            alternative.AddUtilityTerm(45, personDay.Person.Household.ResidenceParcel.MixedUse2Index1());
            alternative.AddUtilityTerm(47, (personDay.Person.Age <= 30).ToFlag());
            alternative.AddUtilityTerm(48, noUsualWorkZone);
            alternative.AddUtilityTerm(49, workIntrDens);
            alternative.AddUtilityTerm(50, workPclWrkrs);
            alternative.AddUtilityTerm(51, countNonMandatory);
            alternative.AddUtilityTerm(52, ((simulatedMandatoryTours[2] > 0).ToFlag()));
            alternative.AddUtilityTerm(53, (household.HouseholdTotals.AllWorkers == 1).ToFlag());
            alternative.AddUtilityTerm(55, noCarsFlag + carCompetitionFlag);
            alternative.AddUtilityTerm(56, (personDay.Person.Household.ResidenceParcel.GetDistanceToTransit() > 1).ToFlag());
            alternative.AddUtilityTerm(57, (personDay.Person.Household.Has0To25KIncome).ToFlag());

            // SCHOOL
            alternative        = choiceProbabilityCalculator.GetAlternative(3, schoolAvailableFlag, choice == 3);
            alternative.Choice = 3;
            alternative.AddUtilityTerm(61, 1);
            alternative.AddUtilityTerm(62, schoolTourLogsum);
            alternative.AddUtilityTerm(63, noCarsFlag + carCompetitionFlag);
            alternative.AddUtilityTerm(64, personDay.Person.Household.ResidenceParcel.MixedUse2Index1());
            alternative.AddUtilityTerm(65, (personDay.Person.IsChildUnder5).ToFlag());
            alternative.AddUtilityTerm(66, (personDay.Person.IsUniversityStudent).ToFlag());
            alternative.AddUtilityTerm(67, (personDay.Person.IsDrivingAgeStudent).ToFlag());
            alternative.AddUtilityTerm(68, schoolPclUniStu);
            alternative.AddUtilityTerm(69, schoolPclStudents);
            alternative.AddUtilityTerm(71, ((simulatedMandatoryTours[3] > 0).ToFlag()));
            alternative.AddUtilityTerm(72, schoolIntrDens);
            alternative.AddUtilityTerm(73, (personDay.Person.Age > 25).ToFlag());
            alternative.AddUtilityTerm(74, (personDay.Person.Household.ResidenceParcel.GetDistanceToTransit() > 1).ToFlag());
        }