private static TWrapper CreateWrapper(ITrip trip, ITourWrapper tourWrapper, IHalfTour halfTour) { var type = typeof(TWrapper); var instance = Activator.CreateInstance(type, trip, tourWrapper, halfTour); return((TWrapper)instance); }
private static void RunTripModelSuite(ITourWrapper tour, IHalfTour halfTour, ITripWrapper trip, int batchNumber) { var nextTrip = GenerateIntermediateStop(halfTour, trip, batchNumber); SetIntermediateStopDestination(trip, nextTrip, batchNumber); SetTripModeAndTime(tour, trip, batchNumber); if (!trip.PersonDay.IsValid) { return; } // retrieves window based on whether or not the trip's tour is home-based or work-based var timeWindow = tour.IsHomeBasedTour ? tour.PersonDay.TimeWindow : tour.ParentTour.TimeWindow; if (trip.IsHalfTourFromOrigin && trip.Sequence == 1) { // occupies minutes in window between destination and stop timeWindow.SetBusyMinutes(tour.DestinationArrivalTime, trip.ArrivalTime); } else if (!trip.IsHalfTourFromOrigin && trip.Sequence == 1) { // occupies minutes in window between destination and stop timeWindow.SetBusyMinutes(tour.DestinationDepartureTime, trip.ArrivalTime); } else { // occupies minutes in window from previous stop to stop timeWindow.SetBusyMinutes(trip.GetPreviousTrip().DepartureTime, trip.ArrivalTime); } }
public TripWrapper(ITrip trip, ITourWrapper tourWrapper, IHalfTour halfTour) { _trip = trip; _exporter = Global .ContainerDaySim.GetInstance <IPersistenceFactory <ITrip> >() .Exporter; // relations properties Household = tourWrapper.Household; Person = tourWrapper.Person; PersonDay = tourWrapper.PersonDay; Tour = tourWrapper; HalfTour = halfTour; SetParcelRelationships(trip); // flags/choice model/etc. properties IsHalfTourFromOrigin = Direction == Global.Settings.TourDirections.OriginToDestination; }
public TripWrapper(IActumTrip trip, ITourWrapper tourWrapper, IHalfTour halfTour) //public TripWrapper(IActumTrip trip, IActumTourWrapper tourWrapper, IHalfTour halfTour) : base(trip, tourWrapper, halfTour) { _trip = (IActumTrip)trip; }
private static TWrapper CreateWrapper(ITourWrapper tourWrapper, ITripWrapper trip, int nextTripId, int intermediateStopPurpose, int destinationPurpose, IHalfTour halfTour) { var t = new TModel { Id = nextTripId, TourId = tourWrapper.Id, HouseholdId = tourWrapper.HouseholdId, PersonSequence = tourWrapper.PersonSequence, Day = tourWrapper.Day, Direction = trip.Direction, Sequence = trip.Sequence + 1, DestinationAddressType = trip.DestinationAddressType, DestinationParcelId = trip.DestinationParcelId, DestinationZoneKey = trip.DestinationZoneKey, OriginAddressType = trip.DestinationAddressType, OriginPurpose = intermediateStopPurpose, DestinationPurpose = destinationPurpose, DepartureTime = 180, ArrivalTime = 180, PathType = 1, ExpansionFactor = tourWrapper.Household.ExpansionFactor }; var type = typeof(TWrapper); var instance = Activator.CreateInstance(type, t, tourWrapper, halfTour); var wrapper = (TWrapper)instance; wrapper.IsToTourOrigin = trip.IsToTourOrigin; return(wrapper); }
ITripWrapper ITripCreator.CreateWrapper(ITourWrapper tourWrapper, ITripWrapper trip, int nextTripId, int intermediateStopPurpose, int destinationPurpose, IHalfTour halfTour) { return(CreateWrapper(tourWrapper, trip, nextTripId, intermediateStopPurpose, destinationPurpose, halfTour)); }
private static TWrapper CreateWrapper(ITourWrapper tourWrapper, int nextTripId, int direction, int sequence, bool isToTourOrigin, IHalfTour halfTour) { var t = new TModel { Id = nextTripId, TourId = tourWrapper.Id, HouseholdId = tourWrapper.HouseholdId, PersonSequence = tourWrapper.PersonSequence, Day = tourWrapper.Day, Direction = direction, Sequence = sequence + 1, OriginAddressType = tourWrapper.DestinationAddressType, OriginParcelId = tourWrapper.DestinationParcelId, OriginZoneKey = tourWrapper.DestinationZoneKey, OriginPurpose = tourWrapper.DestinationPurpose, DestinationAddressType = tourWrapper.OriginAddressType, DestinationParcelId = tourWrapper.OriginParcelId, DestinationZoneKey = tourWrapper.OriginZoneKey, DestinationPurpose = tourWrapper.IsHomeBasedTour ? Global.Settings.Purposes.NoneOrHome : Global.Settings.Purposes.Work, DepartureTime = 180, ArrivalTime = 180, PathType = 1, ExpansionFactor = tourWrapper.Household.ExpansionFactor, }; var type = typeof(TWrapper); var instance = Activator.CreateInstance(type, t, tourWrapper, halfTour); var wrapper = (TWrapper)instance; wrapper.IsToTourOrigin = isToTourOrigin; return(wrapper); }
ITripWrapper ITripCreator.CreateWrapper(ITourWrapper tourWrapper, int nextTripId, int direction, int sequence, bool isToTourOrigin, IHalfTour halfTour) { return(CreateWrapper(tourWrapper, nextTripId, direction, sequence, isToTourOrigin, halfTour)); }
ITripWrapper ITripCreator.CreateWrapper(ITrip trip, ITourWrapper tourWrapper, IHalfTour halfTour) { return(CreateWrapper(trip, tourWrapper, halfTour)); }
public TripWrapper(ITrip trip, ITourWrapper tourWrapper, IHalfTour halfTour) : base(trip, tourWrapper, halfTour) { _trip = (ILDTrip)trip; }
private static ITripWrapper GenerateIntermediateStop(IHalfTour halfTour, ITripWrapper trip, int batchNumber) { if (!Global.Configuration.ShouldRunIntermediateStopGenerationModel) { return(null); } ITripWrapper nextTrip = null; if (Global.Configuration.IsInEstimationMode) { // -- in estimation mode -- // sets the trip's destination purpose, determines whether or not a stop is generated in application mode // uses trip instead of nextTrip, deals with subtours with tour origin at work // need to set trip.IsToTourOrigin first trip.IsToTourOrigin = trip.Sequence == trip.HalfTour.Trips.Count(); // last trip in half tour var intermediateStopPurpose = trip.IsToTourOrigin ? Global.Settings.Purposes.NoneOrHome : trip.DestinationPurpose; nextTrip = trip.GetNextTrip(); if (intermediateStopPurpose != Global.Settings.Purposes.NoneOrHome) { ChoiceModelFactory.TotalTimesIntermediateStopGenerated[batchNumber]++; } if (trip.PersonDay.GetTotalStops() > 0) { ChoiceModelFactory.TotalTimesIntermediateStopGenerationModelRun[batchNumber]++; Global.ChoiceModelSession.Get <IntermediateStopGenerationModel>().Run(trip, intermediateStopPurpose); } } else { // -- in application mode -- // sets the trip's destination purpose, determines whether or not a stop is generated // first, if it is the first trip on a park and ride half tour, then make it a change mode stop // TODO: this doesn't allow stops between the destination and the transit stop - can improve later int intermediateStopPurpose; if (trip.Sequence == 1 && trip.Tour.Mode == Global.Settings.Modes.ParkAndRide) { intermediateStopPurpose = Global.Settings.Purposes.ChangeMode; ChoiceModelFactory.TotalTimesChangeModeStopGenerated[batchNumber]++; } else if (trip.PersonDay.GetTotalStops() == 0) { intermediateStopPurpose = Global.Settings.Purposes.NoneOrHome; } else { ChoiceModelFactory.TotalTimesIntermediateStopGenerationModelRun[batchNumber]++; intermediateStopPurpose = Global.ChoiceModelSession.Get <IntermediateStopGenerationModel>().Run(trip); } if (intermediateStopPurpose != Global.Settings.Purposes.NoneOrHome) { ChoiceModelFactory.TotalTimesIntermediateStopGenerated[batchNumber]++; var destinationPurposeForNextTrip = trip.DestinationPurpose; // creates the next trip in the half-tour // the next trip's destination is set to the current trip's destination nextTrip = halfTour.CreateNextTrip(trip, intermediateStopPurpose, destinationPurposeForNextTrip); halfTour.Trips.Add(nextTrip); trip.DestinationAddressType = Global.Settings.AddressTypes.None; trip.DestinationPurpose = intermediateStopPurpose; trip.IsToTourOrigin = false; } else { trip.IsToTourOrigin = true; } } return(nextTrip); }