예제 #1
0
        public void Save()
        {
            _household.Export();

            foreach (var person in _household.Persons)
            {
                person.Export();
            }

            foreach (var householdDay in _household.HouseholdDays)
            {
                householdDay.Export();

                if (Global.Settings.UseJointTours)
                {
                    foreach (var jointTour in householdDay.JointToursList)
                    {
                        jointTour.Export();
                    }

                    foreach (var fullHalfTour in householdDay.FullHalfToursList)
                    {
                        fullHalfTour.Export();
                    }

                    foreach (var fullHalfTour in householdDay.FullHalfToursList)
                    {
                        fullHalfTour.Export();
                    }

                    foreach (var partialHalfTour in householdDay.PartialHalfToursList)
                    {
                        partialHalfTour.Export();
                    }
                }

                foreach (var personDay in householdDay.PersonDays)
                {
                    personDay.Export();

                    if (personDay.Tours == null)
                    {
                        continue;
                    }

                    if (personDay.Tours.Count > 1)
                    {
                        // sorts tours chronologically
                        personDay.Tours.Sort((tour1, tour2) => tour1.OriginDepartureTime.CompareTo(tour2.OriginDepartureTime));
                    }

                    foreach (var tour in personDay.Tours)
                    {
                        tour.Export();

                        if (tour.HalfTourFromOrigin != null && tour.HalfTourFromDestination != null)
                        {
                            foreach (var trip in tour.HalfTourFromOrigin.Trips.Invert())
                            {
                                trip.SetTourSequence(tour.Sequence);
                                trip.SetTripValueOfTime();
                                trip.Export();

                                ChoiceModelUtility.WriteTripForTDM(trip, ChoiceModelFactory.TDMTripListExporter);
                            }

                            foreach (var trip in tour.HalfTourFromDestination.Trips)
                            {
                                trip.SetTourSequence(tour.Sequence);
                                trip.SetTripValueOfTime();
                                trip.Export();

                                ChoiceModelUtility.WriteTripForTDM(trip, ChoiceModelFactory.TDMTripListExporter);
                            }
                        }

                        if (tour.Subtours.Count > 1)
                        {
                            // sorts subtours chronologically
                            tour.Subtours.Sort((tour1, tour2) => tour1.OriginDepartureTime.CompareTo(tour2.OriginDepartureTime));
                        }

                        foreach (var subtour in tour.Subtours)
                        {
                            subtour.SetParentTourSequence(tour.Sequence);
                            subtour.Export();

                            if (subtour.HalfTourFromOrigin == null || subtour.HalfTourFromDestination == null)
                            {
                                continue;
                            }

                            foreach (var trip in subtour.HalfTourFromOrigin.Trips.Invert())
                            {
                                trip.SetTourSequence(subtour.Sequence);
                                trip.Export();

                                ChoiceModelUtility.WriteTripForTDM(trip, ChoiceModelFactory.TDMTripListExporter);
                            }

                            foreach (var trip in subtour.HalfTourFromDestination.Trips)
                            {
                                trip.SetTourSequence(subtour.Sequence);
                                trip.Export();

                                ChoiceModelUtility.WriteTripForTDM(trip, ChoiceModelFactory.TDMTripListExporter);
                            }
                        }
                    }
                }
            }
        }