Exemplo n.º 1
0
        private static void RunTourModels(IPersonDayWrapper personDay, int batchNumber)
        {
            if (!Global.Configuration.ShouldRunTourModels)
            {
                return;
            }

            // creates or adds tours to a person's day based on application or estimation mode
            // tours are created by purpose
            personDay.SetTours();

            foreach (var tour in personDay.Tours)
            {
#if RELEASE
                try {
#endif
                ChoiceModelFactory.TotalTimesTourModelSuiteRun[batchNumber]++;
                RunTourModelSuite(tour, batchNumber);

                if (!personDay.IsValid)
                {
                    if (Global.Configuration.IsInEstimationMode && Global.Configuration.EstimationModel == "IntermediateStopLocationModel")
                    {
                        Global.PrintFile.WriteEstimationRecordExclusionMessage("ChoiceModelRunner", "RunTourModels", tour.Household.Id, tour.Person.Sequence, -1, tour.Sequence, -1, -1, tour.HalfTour1Trips + tour.HalfTour2Trips);
                    }

                    return;
                }

                ChoiceModelFactory.TotalTimesTourTripModelsRun[batchNumber]++;
                RunTourTripModels(tour, batchNumber);

                if (!personDay.IsValid)
                {
                    return;
                }

                ChoiceModelFactory.TotalTimesTourSubtourModelsRun[batchNumber]++;
                RunSubtourModels(tour, batchNumber);

                if (!personDay.IsValid)
                {
                    return;
                }
#if RELEASE
            }
            catch (Exception e) {
                throw new TourModelException(string.Format("Error running tour models for {0}.", tour), e);
            }
#endif
            }
        }