Example #1
0
        private static void ProcessHalfTours(ITourWrapper tour, int batchNumber)
        {
            // goes in two directions, from origin to destination and destination to origin
            for (var direction = Global.Settings.TourDirections.OriginToDestination; direction <= Global.Settings.TourDirections.TotalTourDirections; direction++)
            {
                // creates origin and destination half-tours
                // creates or adds a trip to a tour based on application or estimation mode
                tour.SetHalfTours(direction);

                // the half-tour from the origin to destination or the half-tour from the destination to origin
                // depending on the direction
                var halfTour = tour.GetHalfTour(direction);

                // halfTour.Trips will dynamically grow, so keep this in a for loop
                for (var i = 0; i < halfTour.Trips.Count; i++)
                {
                    var trip = halfTour.Trips[i];

#if RELEASE
                    try {
#endif
                    halfTour.SimulatedTrips++;

                    if (trip.IsHalfTourFromOrigin)
                    {
                        tour.HalfTour1Trips++;
                    }
                    else
                    {
                        tour.HalfTour2Trips++;
                    }

                    ChoiceModelFactory.TotalTimesTripModelSuiteRun[batchNumber]++;
                    //Global.PrintFile.WriteLine("Before - trip {0} sequence {1} orig parcel {2} orig zone {3}", trip.Id, trip.Sequence, trip.OriginParcelId, trip.OriginZoneKey);
                    //Global.PrintFile.WriteLine("Before - trip {0} sequence {1} dest parcel {2} dest zone {3}", trip.Id, trip.Sequence, trip.DestinationParcelId, trip.DestinationZoneKey);
                    RunTripModelSuite(tour, halfTour, trip, batchNumber);
                    //Global.PrintFile.WriteLine("*After - trip {0} sequence {1} orig parcel {2} orig zone {3}", trip.Id, trip.Sequence, trip.OriginParcelId, trip.OriginZoneKey);
                    //Global.PrintFile.WriteLine("*After - trip {0} sequence {1} dest parcel {2} dest zone {3}", trip.Id, trip.Sequence, trip.DestinationParcelId, trip.DestinationZoneKey);

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