コード例 #1
0
        private ITripChain CreatePickUpTrip(ITrip trip, ISharedMode mode, out bool success)
        {
            ITripChain auxTripChain = new AuxiliaryTripChain();

            //go to trip
            ITrip goToTrip = AuxiliaryTrip.MakeAuxiliaryTrip(trip.OriginalZone, trip.TripChain.Person.Household.HomeZone, mode.AssociatedMode, trip.ActivityStartTime);

            //End Time of return trip
            Time travelTimeToHome = mode.TravelTime(trip.OriginalZone, trip.TripChain.Person.Household.HomeZone, trip.TripStartTime);
            Time tripEndTime      = trip.ActivityStartTime + travelTimeToHome;

            //return home trip
            ITrip returnHomeTrip = AuxiliaryTrip.MakeAuxiliaryTrip(trip.TripChain.Person.Household.HomeZone, trip.OriginalZone, mode, tripEndTime);

            //travel times generated
            success = returnHomeTrip.TravelTime > Time.Zero && goToTrip.TravelTime > Time.Zero;

            auxTripChain.Trips.Add(goToTrip);
            auxTripChain.Trips.Add(returnHomeTrip);

            return(auxTripChain);
        }
コード例 #2
0
        private ITripChain CreatePickUpTrip(ITrip trip, ISharedMode mode, out bool success)
        {
            ITripChain auxTripChain = new AuxiliaryTripChain();

            //go to trip
            ITrip goToTrip = AuxiliaryTrip.MakeAuxiliaryTrip( trip.OriginalZone, trip.TripChain.Person.Household.HomeZone, mode.AssociatedMode, trip.ActivityStartTime );

            //End Time of return trip
            Time travelTimeToHome = mode.TravelTime( trip.OriginalZone, trip.TripChain.Person.Household.HomeZone, trip.TripStartTime );
            Time tripEndTime = trip.ActivityStartTime + travelTimeToHome;

            //return home trip
            ITrip returnHomeTrip = AuxiliaryTrip.MakeAuxiliaryTrip( trip.TripChain.Person.Household.HomeZone, trip.OriginalZone, mode, tripEndTime );

            //travel times generated
            success = returnHomeTrip.TravelTime > Time.Zero && goToTrip.TravelTime > Time.Zero;

            auxTripChain.Trips.Add( goToTrip );
            auxTripChain.Trips.Add( returnHomeTrip );

            return auxTripChain;
        }
コード例 #3
0
        /// <summary>
        /// Adds the auxiliary trip chain to the person if its Utility is greater than not including it
        /// </summary>
        /// <param name="driver">the driver</param>
        /// <param name="passenger">the passenger</param>
        /// <param name="trip1">aux trip 1</param>
        /// <param name="trip2">aux trip 2</param>
        /// <param name="facilitateTrip">the trip being facilitated</param>
        /// <param name="mode">the shared mode to assign</param>
        /// <param name="dropoff">is this a dropoff or pickup aux trip chain?</param>
        /// <param name="connectingTrip">what is the chain this aux trip chain connects to if any?</param>
        private void AddAuxTripChain(ITashaPerson driver, ITashaPerson passenger, ITrip trip1, ITrip trip2, ITrip facilitateTrip, ISharedMode mode, bool dropoff, ITrip connectingTrip)
        {
            ITripChain auxTripChain = new AuxiliaryTripChain();

            auxTripChain.Attach("SharedMode", mode);
            auxTripChain.Attach("FacilitateTrip", facilitateTrip);
            trip1.TripChain = auxTripChain;
            trip2.TripChain = auxTripChain;
            auxTripChain.Trips.Add(trip1);
            auxTripChain.Trips.Add(trip2);
            auxTripChain.Person = driver;
            facilitateTrip.Attach("isDriver", false);
            if (dropoff)
            {
                trip1.Passengers.Add(passenger);
                trip1.Attach("isDriver", true);
            }
            else
            {
                trip2.Passengers.Add(passenger);
                trip2.Attach("isDriver", true);
            }
            if (connectingTrip != null)
            {
                auxTripChain.Attach("ConnectingChain", connectingTrip);
            }
            if (dropoff)
            {
                if (connectingTrip == null)
                {
                    auxTripChain.Attach("Purpose", Activity.DropoffAndReturn);
                    trip1.Purpose = Activity.FacilitatePassenger;
                    trip2.Purpose = Activity.Home;
                }
                else if (connectingTrip != null)
                {
                    auxTripChain.Attach("Purpose", Activity.Dropoff);
                    auxTripChain.Attach("OriginalPurpose", connectingTrip.Purpose);
                    trip1.Purpose = Activity.FacilitatePassenger;
                    trip2.Purpose = connectingTrip.Purpose;

                    //transfering feasible transit stations and such
                    foreach (var key in connectingTrip.Keys)
                    {
                        trip1.Attach(key, connectingTrip[key]);
                    }
                }
            }
            else
            {
                if (connectingTrip == null)
                {
                    auxTripChain.Attach("Purpose", Activity.PickupAndReturn);
                    trip1.Purpose = Activity.FacilitatePassenger;
                    trip2.Purpose = Activity.Home;
                }
                else if (connectingTrip != null)
                {
                    ///TODO: Look into this again
                    auxTripChain.Attach("Purpose", Activity.Pickup);
                    auxTripChain.Attach("OriginalPurpose", connectingTrip.Purpose);
                    trip1.Purpose = Activity.FacilitatePassenger;
                    trip2.Purpose = Activity.Home;

                    //transfering feasible transit stations and such
                    foreach (var key in connectingTrip.Keys)
                    {
                        trip2.Attach(key, connectingTrip[key]);
                    }
                }
            }
            double oldU, newU;

            CalculateU(auxTripChain, out oldU, out newU);
            if (double.IsNegativeInfinity(oldU) | (newU > oldU))
            {
                driver.AuxTripChains.Add(auxTripChain);
                auxTripChain.Attach("FacilitateTripMode", mode);
            }
        }
コード例 #4
0
        /// <summary>
        /// Adds the auxiliary trip chain to the person if its Utility is greater than not including it
        /// </summary>
        /// <param name="driver">the driver</param>
        /// <param name="passenger">the passenger</param>
        /// <param name="trip1">aux trip 1</param>
        /// <param name="trip2">aux trip 2</param>
        /// <param name="facilitateTrip">the trip being facilitated</param>
        /// <param name="mode">the shared mode to assign</param>
        /// <param name="dropoff">is this a dropoff or pickup aux trip chain?</param>
        /// <param name="connectingTrip">what is the chain this aux trip chain connects to if any?</param>
        private void AddAuxTripChain(ITashaPerson driver, ITashaPerson passenger, ITrip trip1, ITrip trip2, ITrip facilitateTrip, ISharedMode mode, bool dropoff, ITrip connectingTrip)
        {
            ITripChain auxTripChain = new AuxiliaryTripChain();
            auxTripChain.Attach( "SharedMode", mode );
            auxTripChain.Attach( "FacilitateTrip", facilitateTrip );
            trip1.TripChain = auxTripChain;
            trip2.TripChain = auxTripChain;
            auxTripChain.Trips.Add( trip1 );
            auxTripChain.Trips.Add( trip2 );
            auxTripChain.Person = driver;
            facilitateTrip.Attach( "isDriver", false );
            if ( dropoff )
            {
                trip1.Passengers.Add( passenger );
                trip1.Attach( "isDriver", true );
            }
            else
            {
                trip2.Passengers.Add( passenger );
                trip2.Attach( "isDriver", true );
            }
            if ( connectingTrip != null )
            {
                auxTripChain.Attach( "ConnectingChain", connectingTrip );
            }
            if ( dropoff )
            {
                if ( connectingTrip == null )
                {
                    auxTripChain.Attach( "Purpose", Activity.DropoffAndReturn );
                    trip1.Purpose = Activity.FacilitatePassenger;
                    trip2.Purpose = Activity.Home;
                }
                else if ( connectingTrip != null )
                {
                    auxTripChain.Attach( "Purpose", Activity.Dropoff );
                    auxTripChain.Attach( "OriginalPurpose", connectingTrip.Purpose );
                    trip1.Purpose = Activity.FacilitatePassenger;
                    trip2.Purpose = connectingTrip.Purpose;

                    //transfering feasible transit stations and such
                    foreach ( var key in connectingTrip.Keys )
                    {
                        trip1.Attach( key, connectingTrip[key] );
                    }
                }
            }
            else
            {
                if ( connectingTrip == null )
                {
                    auxTripChain.Attach( "Purpose", Activity.PickupAndReturn );
                    trip1.Purpose = Activity.FacilitatePassenger;
                    trip2.Purpose = Activity.Home;
                }
                else if ( connectingTrip != null )
                {
                    ///TODO: Look into this again
                    auxTripChain.Attach( "Purpose", Activity.Pickup );
                    auxTripChain.Attach( "OriginalPurpose", connectingTrip.Purpose );
                    trip1.Purpose = Activity.FacilitatePassenger;
                    trip2.Purpose = Activity.Home;

                    //transfering feasible transit stations and such
                    foreach ( var key in connectingTrip.Keys )
                    {
                        trip2.Attach( key, connectingTrip[key] );
                    }
                }
            }
            double oldU, newU;
            CalculateU( auxTripChain, out oldU, out newU );
            if ( double.IsNegativeInfinity( oldU ) | ( newU > oldU ) )
            {
                driver.AuxTripChains.Add( auxTripChain );
                auxTripChain.Attach( "FacilitateTripMode", mode );
            }
        }