예제 #1
0
        /// <summary>
        /// Calculates the V for a given trip
        ///
        /// Returns a 'random' V
        ///
        ///
        /// </summary>
        /// <param name="trip">The trip to calculate V for</param>
        /// <returns>The V for this trip</returns>
        public double CalculateV(ITrip trip)
        {
            int egressStation = (int)trip["AccessStation"];
            //LatestAccessStation(trip.TripChain, trip);
            var   auto    = this.TashaRuntime.AutoMode;
            var   station = this.TashaRuntime.ZoneSystem.Get(egressStation);
            float V       = this.CDriveEgress;

            V += this.AutoTime * auto.TravelTime(trip.DestinationZone, station, trip.TripStartTime).ToMinutes();
            V += this.WalkTime * this.TransitAccessData.WalkTime(station, trip.OriginalZone, trip.TripStartTime).ToMinutes();
            V += this.WaitTime * this.TransitAccessData.WaitTime(station, trip.OriginalZone, trip.TripStartTime).ToMinutes();
            V += this.AutoCost * auto.Cost(trip.DestinationZone, station, trip.TripStartTime);
            V += this.TransitTime * this.TransitAccessData.InVehicleTravelTime(station, trip.OriginalZone, trip.TripStartTime).ToMinutes();
            V += this.ParkingCost * this.TransitAccessData.Station(station).ParkingCost;
            if ((Common.GetTimePeriod(trip.ActivityStartTime) == Tasha.Common.TravelTimePeriod.Morning) ||
                (Common.GetTimePeriod(trip.ActivityStartTime) == Tasha.Common.TravelTimePeriod.Afternoon))
            {
                V += PeakTrip;
            }
            if (trip.TripChain.Person.Occupation == Occupation.Retail)
            {
                V += this.OccSalesTransit;
            }
            else if (trip.TripChain.Person.Occupation == Occupation.Office)
            {
                V += this.OccGeneralTransit;
            }
            return(V);
        }
예제 #2
0
        /// <summary>
        /// Checking that the person has a licence and a vehical
        /// and that there exist a station st. the auto travel time and
        /// transit time is > 0
        /// </summary>
        /// <param name="trip">The trip to test feasibility on</param>
        /// <returns>if it was feasible</returns>
        public bool Feasible(ITrip trip)
        {
            if (trip.OriginalZone.Distance(trip.DestinationZone) < this.MinDistance)
            {
                return(false);
            }
            if (!trip.TripChain.Person.Licence || trip.TripChain.Person.Household.Vehicles.Length == 0)
            {
                return(false);
            }
            int egressStation;

            if ((egressStation = LatestAccessStation(trip.TripChain, trip)) == -1)
            {
                return(false);
            }
            var station = this.TashaRuntime.ZoneSystem.Get(egressStation);
            var auto    = this.TashaRuntime.AutoMode;

            //checking if there auto travel time is > 0 and the time in transit > 0 : meaning there exists
            //a route from origin to destination through subway station
            if (auto.TravelTime(trip.DestinationZone, station, trip.TripStartTime) > Time.Zero &&
                this.TransitAccessData.InVehicleTravelTime(station, trip.OriginalZone, trip.TripStartTime) > Time.Zero)
            {
                trip.Attach("AccessStation", egressStation);
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Calculates the U of the facilitated trip
        /// </summary>
        /// <param name="tripChain"></param>
        /// <param name="oldU"></param>
        /// <param name="newU"></param>
        public void CalculateU(ITripChain tripChain, out double oldU, out double newU)
        {
            ITrip       facilitatedTrip     = (ITrip)tripChain["FacilitateTrip"];
            ISharedMode facilitatedTripMode = (ISharedMode)tripChain["SharedMode"];
            ITrip       connectingTrip      = tripChain["ConnectingChain"] as ITrip;

            //the mode data for the facilitated trip
            ModeData facilitatedTripData = ModeData.Get(facilitatedTrip);
            int      indexOfPass         = TashaRuntime.GetIndexOfMode(facilitatedTripMode);
            double   UofAuxiliaryTrip    = CalculateUofAuxTrip(tripChain);

            facilitatedTripData.V[indexOfPass] = facilitatedTripMode.CalculateV(facilitatedTrip);

            newU = facilitatedTripData.U(indexOfPass)
                   + UofAuxiliaryTrip;
            if (facilitatedTrip.Mode == null)
            {
                // if there is no other way
                oldU = float.NegativeInfinity;
            }
            else
            {
                if (connectingTrip == null)
                {
                    oldU = facilitatedTripData.U(TashaRuntime.GetIndexOfMode(facilitatedTrip.Mode));
                }
                else
                {
                    ModeData connectingTripData = ModeData.Get(connectingTrip);
                    oldU = facilitatedTripData.U(TashaRuntime.GetIndexOfMode(facilitatedTrip.Mode))
                           + connectingTripData.U(TashaRuntime.GetIndexOfMode(connectingTrip.Mode));
                }
            }
        }
예제 #4
0
 internal void StoreStationRecords(BlockingCollection <StationRecord> stationRecordQueue,
                                   int hhldID, int personID, int tripID, ITrip trip, DATIterationInformation chainData)
 {
     // for each trip that we have stored
     if (_tripData.TryGetValue(trip, out var tripData))
     {
         var replicationData = tripData.Data;
         // store the access and egresses per access station
         foreach (var stn in from rec in replicationData
                  group rec by rec.StationIndex into g
                  select new
         {
             StationIndex = g.Key,
             TimesAccessed = g.Count(r => r.First),
             TimesEgressed = g.Count(r => !r.First)
         })
         {
             if (stn.TimesAccessed > 0)
             {
                 stationRecordQueue.Add(new StationRecord(hhldID, personID, tripID, stn.StationIndex, true, stn.TimesAccessed));
             }
             if (stn.TimesEgressed > 0)
             {
                 stationRecordQueue.Add(new StationRecord(hhldID, personID, tripID, stn.StationIndex, false, stn.TimesEgressed));
             }
         }
     }
 }
예제 #5
0
        /// <summary>
        /// The V for a trip whose mode is bike
        /// </summary>
        /// <param name="trip">The trip</param>
        /// <returns>The V for this trip</returns>
        public double CalculateV(ITrip trip)
        {
            float        v      = 0;
            var          oZone  = trip.OriginalZone;
            var          dZone  = trip.DestinationZone;
            var          time   = trip.ActivityStartTime;
            ITashaPerson person = trip.TripChain.Person;

            GetPersonVariables(person, out float timeFactor, out float constant);
            v += constant;
            v += UtilityAugmentation?.GetValueFromFlat(time, _zoneSystem.GetFlatIndex(oZone.ZoneNumber), _zoneSystem.GetFlatIndex(dZone.ZoneNumber)) ?? 0.0f;
            if (trip.OriginalZone == trip.DestinationZone)
            {
                v += IntrazonalConstant;
            }
            v += timeFactor * TravelTime(oZone, dZone, time).ToMinutes();
            if (person.Youth)
            {
                v += YouthFlag;
            }
            if (person.YoungAdult)
            {
                v += YoungAdultFlag;
            }
            return(v);
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        public double CalculateV(ITrip trip)
        {
            double v = 0;

            v += CSchoolBus;

            if (trip.TripChain.Person.Licence)
            {
                v += DriversLicence;
            }

            if (trip.TripChain.Person.Youth)
            {
                v += YouthPassenger;
                v += YouthWalk;
            }
            if (trip.TripChain.Person.YoungAdult)
            {
                v += YoungAdultPassenger;
                v += YoungAdultWalk;
            }

            if (trip.Purpose == Activity.School)
            {
                v += SchoolPurpose;
            }
            else if (trip.TripNumber > 1 && trip.TripChain.Trips[trip.TripChain.Trips.IndexOf(trip) - 1].Purpose == Activity.School)
            {
                v += SchoolPurpose;
            }
            v += Data.TravelTime(trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime).ToMinutes() * Distance;
            v += trip.TripChain.Person.Age * Age;
            return(v);
        }
        private void SaveTrip(ITrip trip, int householdNumber, int personNumber, int tripChainNumber, int tripNumber, int preferedNonVehicle)
        {
            var writer = Writer;

            writer.Write(householdNumber);
            writer.Write(',');
            writer.Write(personNumber);
            writer.Write(',');
            writer.Write(tripChainNumber);
            writer.Write(',');
            writer.Write(tripNumber);
            writer.Write(',');
            writer.Write(trip.OriginalZone.ZoneNumber);
            writer.Write(',');
            writer.Write(trip.DestinationZone.ZoneNumber);
            writer.Write(',');
            writer.Write(GetPurposeName(trip.Purpose));
            writer.Write(',');
            writer.Write(trip.TripStartTime);
            writer.Write(',');
            writer.Write(trip.ActivityStartTime);
            var modesChosen = trip.ModesChosen;

            for (int i = 0; i < AllModes.Length; i++)
            {
                writer.Write(',');
                writer.Write(modesChosen.Count(m => m == AllModes[i]));
            }
            writer.Write(',');
            writer.Write(preferedNonVehicle);
            writer.WriteLine();
        }
예제 #8
0
        private void SaveTrip(ITrip trip, int householdNumber, int personNumber, int tripNumber, int numberOfWorkTrips, int numberOfTripsInTour)
        {
            var writer = Writer;

            writer.Write(householdNumber);
            writer.Write(',');
            writer.Write(personNumber);
            writer.Write(',');
            writer.Write(tripNumber);
            writer.Write(',');
            writer.Write(trip.OriginalZone.ZoneNumber);
            writer.Write(',');
            writer.Write(trip.DestinationZone.ZoneNumber);
            writer.Write(',');
            writer.Write(GetPurposeName(trip.Purpose));
            writer.Write(',');
            writer.Write(trip.TripStartTime);
            writer.Write(',');
            writer.Write(trip.ActivityStartTime);
            writer.Write(',');
            writer.Write(GetTripDistance(trip));
            writer.Write(',');
            writer.Write(numberOfWorkTrips);
            writer.Write(',');
            writer.Write(numberOfTripsInTour);
            var modesChosen = trip.ModesChosen;

            for (int i = 0; i < AllModes.Length; i++)
            {
                writer.Write(',');
                writer.Write(modesChosen.Count(m => m == AllModes[i]));
            }
            writer.WriteLine();
        }
예제 #9
0
        /// <summary>
        /// Calculate the non random part of the utility for the trip
        /// For each mode
        /// </summary>
        /// <param name="trip">The trip to work on</param>
        public static bool CalculateVTrip(this ITrip trip)
        {
            ModeData data = ModeData.MakeModeData();

            //initializes mode set
            data.Store(trip);
            bool feasible      = false;
            var  modes         = TashaRuntime.NonSharedModes;
            int  numberOfModes = modes.Count;

            for (int i = 0; i < numberOfModes; i++)
            {
                // start processing the next mode number
                if (!(data.Feasible[i] = modes[i].Feasible(trip)))
                {
                    continue;
                }
                feasible  = true;
                data.V[i] = modes[i].CalculateV(trip);
            }
            // This will generate the error for all of the modes
            // including the shared modes
            data.GenerateError();
            return(feasible);
        }
예제 #10
0
        private void FinalizeAuxTrips(ITashaHousehold household)
        {
            var persons = household.Persons;
            var pLength = persons.Length;

            for (int i = 0; i < pLength; i++)
            {
                var aux       = persons[i].AuxTripChains;
                var auxLength = aux.Count;
                for (int j = 0; j < auxLength; j++)
                {
                    ITrip       connectingTripChain = aux[j]["ConnectingChain"] as ITrip;
                    Activity    purpose             = (Activity)aux[j]["Purpose"];
                    ITrip       facilitatedTrip     = aux[j]["FacilitateTrip"] as ITrip;
                    ISharedMode facilitatedTripMode = aux[j]["SharedMode"] as ISharedMode;
                    facilitatedTrip.Mode = facilitatedTripMode;
                    var trips          = aux[j].Trips;
                    var tripsLength    = trips.Count;
                    var associatedMode = facilitatedTripMode.AssociatedMode;
                    for (int t = 0; t < tripsLength; t++)
                    {
                        trips[t].Mode = associatedMode;
                    }
                }
            }
        }
예제 #11
0
        private int GetID(ITashaPerson person, ITrip trip)
        {
            var id = IsJointTrip(trip) ? (trip.TripChain.JointTripRep ? Distribution.GetDistributionID(person.Household, trip.Purpose) : -1)
                : Distribution.GetDistributionID(person, trip.Purpose);

            return(id);
        }
예제 #12
0
파일: Taxi.cs 프로젝트: lunaxi7/XTMF
        /// <summary>
        /// Calculates the V for this mode
        /// </summary>
        /// <param name="trip">The trip</param>
        /// <returns>The V</returns>
        public double CalculateV(ITrip trip)
        {
            double v = 0.0;

            if (UseIntrazonalRegression && trip.OriginalZone == trip.DestinationZone)
            {
                v += IntrazonalConstantWeight + trip.OriginalZone.InternalDistance * IntrazonalDistanceWeight;
            }
            else
            {
                v += CTaxi;
                v += Time * TravelTime(trip.OriginalZone, trip.DestinationZone, trip.TripStartTime).ToMinutes();
                v += FareCost * CalculateFare(trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime);
            }
            if (Common.GetTimePeriod(trip.ActivityStartTime) == TravelTimePeriod.Offpeak)
            {
                v += OffPeakTrip;
            }
            if (TransportTerminal.Contains(trip.OriginalZone.ZoneNumber) | TransportTerminal.Contains(trip.DestinationZone.ZoneNumber))
            {
                v += FromToTransportTerminal;
            }
            if (trip.Purpose == Activity.Market | trip.Purpose == Activity.JointMarket)
            {
                v += DpurpShopDrive;
            }
            else if (trip.Purpose == Activity.IndividualOther | trip.Purpose == Activity.JointOther)
            {
                v += DpurpOthDrive;
            }
            return(v);
        }
예제 #13
0
        /// <summary>
        /// Calculates the V value for the given trip
        /// </summary>
        /// <param name="trip">The trip to calculate for</param>
        /// <returns>The V for the trip</returns>
        public double CalculateV(ITrip trip)
        {
            double v = 0;
            IZone  o = trip.OriginalZone, d = trip.DestinationZone;

            if ((o == d) & UseIntrazonalRegression)
            {
                v += IntrazonalConstantWeight + o.InternalDistance * IntrazonalDistanceWeight;
            }
            else
            {
                v += Constant;
                v += AutoData.TravelTime(o, d, trip.ActivityStartTime).ToMinutes() * TravelTimeBeta;
                v += AutoData.TravelCost(o, d, trip.ActivityStartTime) * TravelCostBeta;
            }
            v += d.ParkingCost * Parking;
            if (trip.Purpose == Activity.Market | trip.Purpose == Activity.JointMarket)
            {
                v += DpurpShopDrive;
            }
            else if (trip.Purpose == Activity.IndividualOther | trip.Purpose == Activity.JointOther)
            {
                v += DpurpOthDrive;
            }
            return(v);
        }
예제 #14
0
        private float GetTripDistance(ITrip trip)
        {
            var origin = trip.OriginalZone.ZoneNumber;
            var dest   = trip.DestinationZone.ZoneNumber;

            return(ZoneDistances[origin, dest]);
        }
예제 #15
0
        public double CalculateV(ITrip trip)
        {
            float v;
            var   zoneSystem = this.Root.ZoneSystem;
            var   zones      = zoneSystem.ZoneArray;
            var   o          = zones.GetFlatIndex(trip.OriginalZone.ZoneNumber);
            var   d          = zones.GetFlatIndex(trip.DestinationZone.ZoneNumber);
            // get the distance in km
            var distance = zoneSystem.Distances.GetFlatData()[o][d] / 1000.0f;

            // if intrazonal
            if (o == d)
            {
                v = this.IntrazonalConstant;
            }
            else
            {
                v = this.Constant;
            }
            v += this.DistanceFactor * distance;
            var p = trip.TripChain.Person;

            if (p.Licence)
            {
                v += this.DriversLicenceFlag;
            }
            v += this.AgeFactor * (float)Math.Log(p.Age + 1);
            v += RegionConstants[trip.OriginalZone.RegionNumber, trip.DestinationZone.RegionNumber];
            v += GetPlanningDistrictConstant(trip.ActivityStartTime, trip.OriginalZone.PlanningDistrict, trip.DestinationZone.PlanningDistrict);
            return((double)v);
        }
예제 #16
0
        public bool Feasible(ITrip trip)
        {
            // you need to be going within the same region
            if (trip.OriginalZone.RegionNumber != trip.DestinationZone.RegionNumber)
            {
                return(false);
            }
            // if we are going to school, yes
            if (trip.Purpose == Activity.School)
            {
                return(true);
            }
            var tc    = trip.TripChain.Trips;
            var index = tc.IndexOf(trip);

            // check for return from school
            if (index > 0)
            {
                if (tc[index - 1].Purpose == Activity.School)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #17
0
        private bool GetTripsFirst(ITripChain tc, out ITrip trip1, out ITrip trip2)
        {
            var list = tc.Trips;
            int i    = 0;

            trip1 = null;
            trip2 = null;
            for (; i < list.Count; i++)
            {
                if (list[i].Mode == OurMode)
                {
                    trip1 = list[i++];
                    break;
                }
            }
            for (; i < list.Count; i++)
            {
                if (list[i].Mode == OurMode)
                {
                    trip2 = list[i++];
                    break;
                }
            }
            // if we get in here and find another trip, then we have more than 2 and is thus invalid
            for (; i < list.Count; i++)
            {
                if (list[i].Mode == OurMode)
                {
                    return(false);
                }
            }
            return(trip1 != null & trip2 != null);
        }
예제 #18
0
파일: Auto.cs 프로젝트: taha-islam/XTMF
        /// <summary>
        /// Calcualtes the V value for the given trip
        /// </summary>
        /// <param name="trip">The trip to calcualte for</param>
        /// <returns>The V for the trip</returns>
        public double CalculateV(ITrip trip)
        {
            double V = 0;
            IZone  o = trip.OriginalZone, d = trip.DestinationZone;

            if ((o == d) & UseIntrazonalRegression)
            {
                V += IntrazonalConstantWeight + o.InternalDistance * IntrazonalDistanceWeight;
            }
            else
            {
                V += this.Constant;
                V += AutoData.TravelTime(o, d, trip.ActivityStartTime).ToMinutes() * this.travelTime;
                V += AutoData.TravelCost(o, d, trip.ActivityStartTime) * this.travelCost;
            }
            V += d.ParkingCost * parking;
            if (trip.Purpose == Activity.Market | trip.Purpose == Activity.JointMarket)
            {
                V += this.dpurp_shop_drive;
            }
            else if (trip.Purpose == Activity.IndividualOther | trip.Purpose == Activity.JointOther)
            {
                V += this.dpurp_oth_drive;
            }
            return(V);
        }
예제 #19
0
        public void should_find_the_lenght_of_the_shortest_route_from_B_to_B()
        {
            ITrip shortest = engine.GetShortestRouteBetween('B', 'B');
            var   result   = shortest.GetDistance();

            Assert.AreEqual(9, result);
        }
예제 #20
0
        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 LoadCarryOnBaggage(ITrip trip)
        {
            var plane = trip.Airplane;

            foreach (var passenger in plane.Passengers)
            {
                var luggage = passenger.Bags;

                // 28-04-2018 18:00
                // Original implementation, which ended up in the skeleton.
                // All tests in Judge passed, regardless of which method was used.

                /*
                 * for (var bagIndex = 0; bagIndex < luggage.Count; bagIndex++)
                 * {
                 *      var luggageBag = luggage[bagIndex];
                 *
                 *      passenger.Bags.RemoveAt(bagIndex);
                 *
                 *      plane.LoadBag(luggageBag);
                 * }
                 */

                while (luggage.Any())
                {
                    var luggageBag = luggage[0];

                    passenger.Bags.RemoveAt(0);

                    plane.LoadBag(luggageBag);
                }
            }
        }
예제 #22
0
        private bool IsThereEnoughTime(ITrip driverOriginalTrip, ITrip passengerTrip, out Time toPassengerOrigin, out Time toPassengerDestination, out Time toDriverDestination)
        {
            // Check to see if the driver is able to get there
            Time earliestPassenger = passengerTrip.ActivityStartTime - MaxPassengerTimeThreshold;
            Time latestPassenger   = passengerTrip.ActivityStartTime + MaxPassengerTimeThreshold;
            // check to see if the driver is able to get to their destination
            var timeToPassenger = toPassengerOrigin = TravelTime(driverOriginalTrip.OriginalZone, passengerTrip.OriginalZone, driverOriginalTrip.TripStartTime);
            var driverArrivesAt = driverOriginalTrip.TripStartTime + timeToPassenger;
            var earliestDriver  = driverArrivesAt - MaxDriverTimeThreshold;
            var latestDriver    = driverArrivesAt + MaxDriverTimeThreshold;

            if (!Time.Intersection(earliestPassenger, latestPassenger, earliestDriver, latestDriver, out Time overlapStart, out Time overlapEnd))
            {
                toPassengerDestination = Time.Zero;
                toDriverDestination    = Time.Zero;
                return(false);
            }
            var  midLegTravelTime   = toPassengerDestination = TravelTime(passengerTrip.OriginalZone, passengerTrip.DestinationZone, latestDriver);
            Time finalLegTravelTime = toDriverDestination = Time.Zero;

            if (passengerTrip.DestinationZone != driverOriginalTrip.DestinationZone)
            {
                finalLegTravelTime = TravelTime(passengerTrip.DestinationZone, driverOriginalTrip.DestinationZone, latestDriver + midLegTravelTime);
            }
            var totalDriverTime = timeToPassenger + midLegTravelTime + finalLegTravelTime;

            if (overlapStart + totalDriverTime > driverOriginalTrip.ActivityStartTime + MaxDriverTimeThreshold)
            {
                return(false);
            }
            return(true);
        }
예제 #23
0
        /// <summary>
        /// Checking if the trip is feasible
        /// </summary>
        /// <param name="trip">the trip to test feasibility on</param>
        /// <returns>Is this trip feasible?</returns>
        public bool Feasible(ITrip trip)
        {
            //passenger mode does not handle joint trips
            if (trip.TripChain.JointTrip)
            {
                return(false);
            }

            //they already are assigned a vehicle dont try to find a driver for them.
            if (trip.Mode != null && !trip.Mode.NonPersonalVehicle)
            {
                return(false);
            }

            //attach to trip pass the configuration value to the GetDriver method
            trip.Attach("MaxDriverTimeThreshold", MaxDriverTimeThreshold);

            //trip.SharedModeDriver = ra.GetDriver(trip, this);

            var possible = this.ResourceAvailability.AssignPossibleDrivers(trip, this);

            if (possible)
            {
                return(true);
            }
            return(false);
        }
예제 #24
0
        /// <summary>
        /// The V for a trip whose mode is bike
        /// </summary>
        /// <param name="trip">The trip</param>
        /// <returns>The V for this trip</returns>
        public double CalculateV(ITrip trip)
        {
            float        v      = 0;
            ITashaPerson person = trip.TripChain.Person;

            GetPersonVariables(person, out float timeFactor, out float constant);
            v += constant;
            Time  startTime   = trip.ActivityStartTime;
            IZone origin      = trip.OriginalZone;
            IZone destination = trip.DestinationZone;
            var   o           = _zoneSystem.GetFlatIndex(origin.ZoneNumber);
            var   d           = _zoneSystem.GetFlatIndex(destination.ZoneNumber);

            if (o == d)
            {
                v += IntrazonalConstant;
            }
            v += timeFactor * TravelTime(o, d, startTime).ToMinutes();
            v += _zonalDestinationUtility[d];
            if (person.Youth)
            {
                v += YouthFlag;
            }
            if (person.YoungAdult)
            {
                v += YoungAdultFlag;
            }
            return(v + GetPlanningDistrictConstant(startTime, origin.PlanningDistrict, destination.PlanningDistrict));
        }
예제 #25
0
        public void GetTripActivities(ITrip trip, ITripChain chain, out char origin, out char destination)
        {
            destination = GetActivityChar(trip.Purpose);

            List <ITrip> trips = chain.Trips;

            for (int i = 0; i < trips.Count; i++)
            {
                if (trips[i] == trip)
                {
                    if (i == 0)
                    {
                        origin = GetActivityChar(Activity.Home);
                    }
                    else
                    {
                        origin = GetActivityChar(trips[i - 1].Purpose);
                    }

                    return;
                }
            }

            origin = '0';
        }
예제 #26
0
        /// <summary>
        /// Removes Duplicate Passenger trips (ie. two ppl facilitating one passenger
        /// </summary>
        /// <param name="OptimalSets"></param>
        /// <returns></returns>
        private void RemoveDuplicates(Dictionary <ITashaPerson, List <ITripChain> > OptimalSets)
        {
            List <ITripChain> duplicates = new List <ITripChain>();

            //finding duplicates
            foreach (var s in OptimalSets)
            {
                ITashaPerson      person     = s.Key;
                List <ITripChain> tripChains = s.Value;
                var tripChainsLength         = tripChains.Count;
                for (int i = 0; i < tripChainsLength; i++)
                {
                    Dictionary <ITripChain, double> conflictingUtilities = new
                                                                           Dictionary <ITripChain, double>();
                    //the faciliated trip
                    ITrip  facilitatedTrip = tripChains[i]["FacilitateTrip"] as ITrip;
                    double uOfAuxTrip      = this.CalculateUofAuxTrip(tripChains[i]);
                    conflictingUtilities.Add(tripChains[i], uOfAuxTrip);
                    //finding tripchain and U of duplicate passenger trips
                    foreach (var s2 in OptimalSets)
                    {
                        if (s.Key == s2.Key)
                        {
                            continue;
                        }
                        ITashaPerson      person2     = s2.Key;
                        List <ITripChain> tripChains2 = s2.Value;
                        var tripChain2Length          = tripChains2.Count;
                        for (int j = 0; j < tripChain2Length; j++)
                        {
                            ITrip facilitatedTrip2 = tripChains2[j]["FacilitateTrip"] as ITrip;

                            if (facilitatedTrip2 == facilitatedTrip)
                            {
                                conflictingUtilities.Add(tripChains2[j], this.CalculateUofAuxTrip(tripChains2[j]));
                            }
                        }
                    }
                    ITripChain best = FindHighestUtility(conflictingUtilities);
                    conflictingUtilities.Remove(best);
                    foreach (var element in conflictingUtilities)
                    {
                        duplicates.Add(element.Key);
                    }
                }
            }
            //removing duplicates
            foreach (var s in OptimalSets)
            {
                ITashaPerson      person     = s.Key;
                List <ITripChain> tripChains = s.Value;
                var duplicatesLength         = duplicates.Count;
                for (int i = 0; i < duplicatesLength; i++)
                {
                    // Remove the duplicate if it exists
                    tripChains.Remove(duplicates[i]);
                }
            }
        }
예제 #27
0
 private static bool AreTogether(ITrip f, ITrip s)
 {
     return((f.TripStartTime == s.TripStartTime)
            & (f.Purpose == s.Purpose)
            & (f.Purpose == Activity.IndividualOther | f.Purpose == Activity.Market | f.Purpose == Activity.Home)
            & (f.OriginalZone.ZoneNumber == s.OriginalZone.ZoneNumber)
            & (f.DestinationZone.ZoneNumber == s.DestinationZone.ZoneNumber));
 }
 public GraphicPermanentOffer(ITravelAgency agency, int photosLimit)
 {
     this.trip = agency.CreateTrip();
     for (int i = 1; i <= photosLimit; i++)
     {
         photos.Add(agency.CreatePhoto());
     }
 }
예제 #29
0
 public bool Feasible(ITrip trip)
 {
     if (trip.OriginalZone.PlanningDistrict == trip.DestinationZone.PlanningDistrict)
     {
         return(false);
     }
     return(trip.TripChain.Person.Licence);
 }
 public TextPermanentOffer(ITravelAgency agency, int reviewsLimit)
 {
     this.trip = agency.CreateTrip();
     for (int i = 1; i <= reviewsLimit; i++)
     {
         reviews.Add(agency.CreateReview());
     }
 }
예제 #31
0
 public double CalculateV(ITrip trip)
 {
     throw new NotImplementedException();
 }
예제 #32
0
 private Episode CreateEpisode(ITrip trip, ITrip nextTrip, ITashaPerson owner)
 {
     return new ActivityEpisode(0, new TimeWindow(trip.ActivityStartTime, nextTrip.ActivityStartTime), trip.Purpose, owner);
 }
예제 #33
0
파일: Walk.cs 프로젝트: Cocotus/XTMF
        /// <summary>
        /// Calculates V Value for a given trip
        /// </summary>
        /// <param name="trip">The trip to calculate for</param>
        /// <returns>The V for the trip</returns>
        public double CalculateV(ITrip trip)
        {
            double v = 0;
            ITashaPerson Person = trip.TripChain.Person;
            float constant, walkBeta;
            GetPersonVariables(Person, out constant, out walkBeta);
            v += constant;

            //if person has a license
            if ( Person.Licence )
            {
                v += this.DriversLicenseFlag;
            }

            IZone origin = trip.OriginalZone;
            IZone destination = trip.DestinationZone;
            Time startTime = trip.ActivityStartTime;
            v += TravelTime(origin, destination, startTime).ToMinutes() * walkBeta;

            //checking if child
            if ( Person.Youth )
            {
                v += YouthFlag;
            }
            else if ( Person.YoungAdult )
            {
                v += YoungAdultFlag;
            }
            else if ( Person.Child )
            {
                v += ChildFlag;
            }

            //if intrazonal trip
            if (origin == destination)
            {
                v += this.IntrazonalConstant;
            }

            //if no vehicles
            if ( Person.Household.Vehicles.Length == 0 )
            {
                v += NoVehicleFlag;
            }
            switch ( trip.Purpose )
            {
                case Activity.Market:
                case Activity.JointMarket:
                    v += this.MarketFlag;
                    break;

                case Activity.JointOther:
                case Activity.IndividualOther:
                    v += this.OtherFlag;
                    break;

                case Activity.School:
                    v += this.SchoolFlag;
                    break;
            }
            return v + GetPlanningDistrictConstant(startTime, origin.PlanningDistrict, destination.PlanningDistrict);
        }
예제 #34
0
 private void AddToSummary(ITrip trip, Dictionary<Activity, float> summaryDictionary, float occurance)
 {
     float value;
     var purpose = trip.Purpose;
     if(!summaryDictionary.TryGetValue(purpose, out value))
     {
         value = 0;
     }
     summaryDictionary[trip.Purpose] = value + occurance;
 }
예제 #35
0
 private void AddToMatrix(ITrip trip)
 {
     var length = this.AllModes.Count;
     var observedMode = trip[ObservedModeString] as ITashaMode;
     int index = -1;
     for ( int i = 0; i < length; i++ )
     {
         if ( this.AllModes[i] == observedMode )
         {
             index = i;
             break;
         }
     }
     if ( index >= 0 )
     {
         var ttPeriod = this.GetTimePeriod( trip );
         this.TripCountMatrixes[index][ttPeriod][trip.OriginalZone.ZoneNumber, trip.DestinationZone.ZoneNumber] += 1;
         this.TripAvgTimeMatrixes[index][ttPeriod][trip.OriginalZone.ZoneNumber, trip.DestinationZone.ZoneNumber] += trip.TravelTime.ToMinutes();
     }
 }
예제 #36
0
파일: Carpool.cs 프로젝트: dianatle/XTMF
 public double CalculateV(ITrip trip)
 {
     // compute the non human factors
     var zoneSystem = Root.ZoneSystem;
     var zoneArray = zoneSystem.ZoneArray;
     IZone originalZone = trip.OriginalZone;
     IZone destinationZone = trip.DestinationZone;
     var o = zoneArray.GetFlatIndex(originalZone.ZoneNumber);
     var d = zoneArray.GetFlatIndex(destinationZone.ZoneNumber);
     var p = trip.TripChain.Person;
     float timeFactor, constant, costFactor;
     GetPersonVariables(p, out timeFactor, out constant, out costFactor);
     float v = constant;
     var startTime = trip.TripStartTime;
     // if Intrazonal
     if(o == d)
     {
         v += IntrazonalConstant;
         v += IntrazonalTripDistanceFactor * zoneSystem.Distances.GetFlatData()[o][d] * 0.001f;
     }
     else
     {
         // if not intrazonal
         float aivtt, cost;
         Network.GetAllData(o, d, startTime, out aivtt, out cost);
         v += timeFactor * aivtt + costFactor * cost;
         if(originalZone.RegionNumber == destinationZone.RegionNumber)
         {
             v += IntraRegionalFlag;
         }
     }
     //Apply trip purpose factors
     switch(trip.Purpose)
     {
         case Activity.Market:
             v += MarketFlag;
             break;
         case Activity.IndividualOther:
             v += OtherFlag;
             break;
     }
     return (double)(v + GetPlanningDistrictConstant(trip.ActivityStartTime, originalZone.PlanningDistrict, destinationZone.PlanningDistrict));
 }
예제 #37
0
파일: Passenger.cs 프로젝트: Cocotus/XTMF
 private bool IsThereEnoughTime(ITrip driverOriginalTrip, ITrip passengerTrip, out Time dToPTime, out Time tToPD, out Time tToDD)
 {
     // Check to see if the driver is able to get there
     Time earliestPassenger = passengerTrip.ActivityStartTime - this.MaxPassengerTimeThreshold;
     Time latestPassenger = passengerTrip.ActivityStartTime + this.MaxPassengerTimeThreshold;
     Time originalDriverTime = driverOriginalTrip.ActivityStartTime - driverOriginalTrip.TripStartTime;
     // check to see if the driver is able to get to their destination
     var timeToPassenger = dToPTime = this.TravelTime( driverOriginalTrip.OriginalZone, passengerTrip.OriginalZone, driverOriginalTrip.TripStartTime );
     var driverArrivesAt = driverOriginalTrip.TripStartTime + timeToPassenger;
     var earliestDriver = driverArrivesAt - this.MaxDriverTimeThreshold;
     var latestDriver = driverArrivesAt + this.MaxDriverTimeThreshold;
     Time overlapStart, overlapEnd;
     if ( !Time.Intersection( earliestPassenger, latestPassenger, earliestDriver, latestDriver, out overlapStart, out overlapEnd ) )
     {
         tToPD = Time.Zero;
         tToDD = Time.Zero;
         return false;
     }
     var midLegTravelTime = tToPD = this.TravelTime( passengerTrip.OriginalZone, passengerTrip.DestinationZone, latestDriver );
     Time finalLegTravelTime = tToDD = Time.Zero;
     if ( passengerTrip.DestinationZone != driverOriginalTrip.DestinationZone )
     {
         finalLegTravelTime = this.TravelTime( passengerTrip.DestinationZone, driverOriginalTrip.DestinationZone, latestDriver + midLegTravelTime );
     }
     var totalDriverTime = timeToPassenger + midLegTravelTime + finalLegTravelTime;
     if ( overlapStart + totalDriverTime > driverOriginalTrip.ActivityStartTime + this.MaxDriverTimeThreshold )
     {
         return false;
     }
     return true;
 }
예제 #38
0
파일: Passenger.cs 프로젝트: Cocotus/XTMF
 public bool CalculateV(ITrip driverOriginalTrip, ITrip passengerTrip, out float v)
 {
     Time dToPTime;
     Time tToPD;
     Time tToDD;
     v = float.NegativeInfinity;
     if ( !IsThereEnoughTime( driverOriginalTrip, passengerTrip, out dToPTime, out tToPD, out tToDD ) )
     {
         return false;
     }
     // Since this is going to be valid, start building a real utility!
     v = this.cpass;
     // we are going to add in the time of the to passenger destination twice
     v += ( ( dToPTime + tToPD + tToDD ).ToMinutes() + tToPD.ToMinutes() ) * this.travelTime;
     // Add in the travel cost
     v += Cost( passengerTrip.OriginalZone, passengerTrip.DestinationZone, passengerTrip.ActivityStartTime ) * this.travelCost;
     if ( passengerTrip.Purpose == Activity.Market | passengerTrip.Purpose == Activity.JointMarket ) v += this.dpurp_shop_drive;
     if ( passengerTrip.Purpose == Activity.IndividualOther | passengerTrip.Purpose == Activity.JointOther ) v += this.dpurp_oth_drive;
     if ( passengerTrip.Purpose == Activity.School ) v += this.dpurp_sch_passenger;
     if ( passengerTrip.TripChain.Person.Female ) v += this.sex_f_passenger;
     if ( passengerTrip.TripChain.Person.Licence ) v += pass_w_license;
     if ( passengerTrip.OriginalZone == driverOriginalTrip.OriginalZone && passengerTrip.DestinationZone == driverOriginalTrip.DestinationZone )
     {
         v += this.croundtrip_facil;
     }
     else
     {
         if ( passengerTrip.OriginalZone == driverOriginalTrip.OriginalZone ) v += cconnecting_facil;
         if ( passengerTrip.DestinationZone == driverOriginalTrip.DestinationZone ) v += cconnecting_facil;
     }
     return true;
 }
예제 #39
0
 private bool IsJointTrip(ITrip trip)
 {
     return trip.TripChain.JointTripRep &&
         ((trip.Purpose == Activity.JointOther) | (trip.Purpose == Activity.JointMarket));
 }
예제 #40
0
 private int GetID(ITashaPerson person, ITrip trip)
 {
     var id = IsJointTrip(trip) ? (trip.TripChain.JointTripRep ? Distribution.GetDistributionID(person.Household, trip.Purpose) : -1)
         : Distribution.GetDistributionID(person, trip.Purpose);
     return id;
 }
예제 #41
0
 private bool AddStartTime(int[][] startTimeCount, int id, ITrip trip)
 {
     return AddStartTime(startTimeCount, id, (trip.OriginalZone == null || trip.DestinationZone == null ? trip.TripStartTime : trip.ActivityStartTime));
 }
예제 #42
0
 private void AddToMatrix(ITrip trip, float expFactor)
 {
     bool taken = false;
     var o = ZoneSystem.GetFlatIndex(trip.OriginalZone.ZoneNumber);
     var d = ZoneSystem.GetFlatIndex(trip.DestinationZone.ZoneNumber);
     var row = Data[o];
     writeLock.Enter(ref taken);
     Thread.MemoryBarrier();
     row[d] += expFactor;
     if(taken) writeLock.Exit(true);
 }
예제 #43
0
파일: GoAccess.cs 프로젝트: Cocotus/XTMF
        /// <summary>
        /// Is this trip feasible?
        /// </summary>
        /// <param name="trip">The trip</param>
        /// <returns>is it feasible</returns>
        public bool Feasible(ITrip trip)
        {
            //trip.Attach("go-access-station", -2);

            if ( !trip.TripChain.Person.Licence || trip.TripChain.Person.Household.Vehicles.Length == 0 )
                return false;

            if ( trip.OriginalZone.Distance( trip.DestinationZone ) < goData.MinDistance )
                return false;

            bool feasible = false;

            int[] accessStations = goData.GetClosestStations( trip.OriginalZone.ZoneNumber );
            int egressStationNum = goData.GetClosestStations( trip.DestinationZone.ZoneNumber )[0];

            //same closest stations, skip it
            if ( accessStations[0] == egressStationNum || egressStationNum == -1 ) return false;

            ITransitStation egressStation = goData.GetStation( egressStationNum );

            int[] feasibleStations = new int[accessStations.Length];

            int i = 0;

            foreach ( int access in accessStations )
            {
                float duration, frequencyAtStart;
                duration = goData.GetAutoTime( trip.OriginalZone.ZoneNumber, access );
                frequencyAtStart = goData.GetGoFrequency( access, egressStation.StationNumber, trip.ActivityStartTime.ToFloat() );
                ITransitStation accessStation = goData.GetStation( access );

                if (
                    ( ( duration > 0 )
                     & ( access != egressStationNum )
                     & ( frequencyAtStart > 0 )
                     & ( access != -1 )
                    )
                    && duration + trip.ActivityStartTime.ToFloat() > goData.StartTime
                    && duration + trip.ActivityStartTime.ToFloat() < goData.EndTime
                    )
                {
                    feasible = true;
                    feasibleStations[i++] = access;
                }
            }
            Array.Resize<int>( ref feasibleStations, i );
            trip.Attach( "feasible-go-stations", feasibleStations );
            return feasible;
        }
예제 #44
0
파일: Carpool.cs 프로젝트: dianatle/XTMF
 public bool Feasible(ITrip trip)
 {
     return true;
 }
예제 #45
0
 private int GetTimePeriod(ITrip trip)
 {
     var startTime = trip.ActivityStartTime;
     if ( startTime >= ThreeThirty && startTime <= SixThirty )
     {
         return 1;
     }
     else if ( startTime >= Six && startTime <= Nine )
     {
         return 0;
     }
     return 2;
 }
예제 #46
0
파일: Bicycle.cs 프로젝트: Cocotus/XTMF
 /// <summary>
 /// Checking Bike Feasibility
 /// </summary>
 /// <param name="trip">The Trip</param>
 /// <returns>is it Feasible?</returns>
 public bool Feasible(ITrip trip)
 {
     return Root.ZoneSystem.Distances[trip.OriginalZone.ZoneNumber, trip.DestinationZone.ZoneNumber] <= MaxTravelDistance;
 }
예제 #47
0
파일: Bicycle.cs 프로젝트: Cocotus/XTMF
 /// <summary>
 /// The V for a trip whose mode is bike
 /// </summary>
 /// <param name="trip">The trip</param>
 /// <returns>The V for this trip</returns>
 public double CalculateV(ITrip trip)
 {
     float v = 0;
     ITashaPerson Person = trip.TripChain.Person;
     float timeFactor, constant;
     GetPersonVariables(Person, out timeFactor, out constant);
     v += constant;
     if(trip.OriginalZone == trip.DestinationZone)
     {
         v += IntrazonalConstant;
     }
     v += timeFactor * TravelTime(trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime).ToMinutes();
     if(Person.Youth)
     {
         v += YouthFlag;
     }
     if(Person.YoungAdult)
     {
         v += YoungAdultFlag;
     }
     return v;
 }
예제 #48
0
 public double CalculateV(ITrip trip)
 {
     // compute the non human factors
     var zoneSystem = Root.ZoneSystem;
     var zoneArray = zoneSystem.ZoneArray;
     IZone originalZone = trip.OriginalZone;
     var o = zoneArray.GetFlatIndex(originalZone.ZoneNumber);
     IZone destinationZone = trip.DestinationZone;
     var d = zoneArray.GetFlatIndex(destinationZone.ZoneNumber);
     var p = trip.TripChain.Person;
     float timeFactor, constant, costFactor, walkBeta, waitBeta, boardingBeta;
     GetPersonVariables(p, out constant, out timeFactor, out walkBeta, out waitBeta, out boardingBeta, out costFactor);
     float v = constant;
     // if Intrazonal
     if(o == d)
     {
         v += IntrazonalConstant;
         v += IntrazonalTripDistanceFactor * zoneSystem.Distances.GetFlatData()[o][d] * 0.001f;
     }
     else
     {
         // if not intrazonal
         if(originalZone.RegionNumber != destinationZone.RegionNumber)
         {
             v += InterRegionalTrip;
         }
         float ivtt, walk, wait, boarding, cost;
         if(Network.GetAllData(o, d, trip.TripStartTime, out ivtt, out walk, out wait, out boarding, out cost))
         {
             if(ivtt <= 0)
             {
                 v += NoTIVTTPenalty;
             }
             v += ivtt * timeFactor
                 + walk * walkBeta
                 + wait * waitBeta
                 + boarding * boardingBeta
                 + cost * costFactor;
         }
         else
         {
             return float.NegativeInfinity;
         }
     }
     //Apply trip purpose factors
     switch(trip.Purpose)
     {
         case Activity.Market:
             v += MarketFlag + ZonalDensityForActivitiesArray[d];
             break;
         case Activity.IndividualOther:
             v += OtherFlag + ZonalDensityForActivitiesArray[d];
             break;
         case Activity.Home:
             v += ZonalDensityForHomeArray[d];
             break;
         default:
             v += ZonalDensityForActivitiesArray[d];
             break;
     }
     v += GetPlanningDistrictConstant(trip.TripStartTime, originalZone.PlanningDistrict, destinationZone.PlanningDistrict);
     return (double)v;
 }
예제 #49
0
 private void AddTripToDictionary(Dictionary<Activity, float[]> dictionary, float occurance, ITrip trip, int homeZone)
 {
     float[] value;
     var purpose = trip.Purpose;
     if(!dictionary.TryGetValue(purpose, out value))
     {
         dictionary.Add(trip.Purpose, (value = new float[Root.ZoneSystem.ZoneArray.GetFlatData().Length]));
     }
     value[homeZone] += occurance;
 }
예제 #50
0
        private int LatestAccessStation(ITripChain tripChain, ITrip trip)
        {
            int egressStation = -1;

            //looking for latest access
            foreach ( ITrip trip2 in tripChain.Trips )
            {
                if ( trip2 == trip ) break;

                if ( trip2.GetVariable( "subway-access-station" ) != null )
                {
                    egressStation = (int)trip2.GetVariable( "subway-access-station" );
                }
            }

            return egressStation;
        }
예제 #51
0
파일: Walk.cs 프로젝트: Cocotus/XTMF
 /// <summary>
 /// The Feasibility of Walking for a given Trip
 /// </summary>
 /// <param name="trip">The Trip to calculate feasibility on</param>
 /// <returns>true if the Trip is feasible for walking</returns>
 public bool Feasible(ITrip trip)
 {
     return this.Feasible( trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime );
 }
예제 #52
0
파일: Walking.cs 프로젝트: Cocotus/XTMF
        /// <summary>
        /// Calculates V Value for a given trip
        /// </summary>
        /// <param name="trip">The trip to calculate for</param>
        /// <returns>The V for the trip</returns>
        public double CalculateV(ITrip trip)
        {
            double V = 0;
            V += this.CWalk;

            ITashaPerson Person = trip.TripChain.Person;

            //if person has a license
            if ( Person.Licence )
            {
                V += this.DLicense;
            }

            V += TravelTime( trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime ).ToMinutes() * this.TravelTimeWeight;

            //if its Morning or Afternoon
            if ( ( Common.GetTimePeriod( trip.ActivityStartTime ) == Tasha.Common.TravelTimePeriod.Morning ) ||
                ( Common.GetTimePeriod( trip.ActivityStartTime ) == Tasha.Common.TravelTimePeriod.Afternoon ) )
            {
                V += PeakTrip;
            }

            //checking if child
            if ( Person.Youth )
            {
                V += Youth;
            }

            //checking if young adult
            if ( Person.YoungAdult )
            {
                V += YoungAdult;
            }

            //if intrazonal trip
            if ( trip.OriginalZone == trip.DestinationZone )
            {
                V += this.Intrazonal;
            }

            //if no vehicles
            if ( Person.Household.Vehicles.Length == 0 )
            {
                V += NoVehicle;
            }
            if ( trip.Purpose == Activity.Market | trip.Purpose == Activity.JointMarket )
            {
                V += this.dpurp_shop_drive;
            }
            else if ( trip.Purpose == Activity.IndividualOther | trip.Purpose == Activity.JointOther )
            {
                V += this.dpurp_oth_drive;
            }

            return V;
        }
예제 #53
0
        public void GetTripActivities(ITrip trip, ITripChain chain, out char origin, out char destination)
        {
            destination = GetActivityChar( trip.Purpose );

            List<ITrip> trips = chain.Trips;

            for ( int i = 0; i < trips.Count; i++ )
            {
                if ( trips[i] == trip )
                {
                    if ( i == 0 )
                    {
                        origin = GetActivityChar( Activity.Home );
                    }
                    else
                    {
                        origin = GetActivityChar( trips[i - 1].Purpose );
                    }

                    return;
                }
            }

            origin = '0';
        }
예제 #54
0
 /// <summary>
 /// Checking that the person has a licence and a vehical
 /// and that there exist a station st. the auto travel time and
 /// transit time is > 0
 /// </summary>
 /// <param name="trip">The trip to test feasibility on</param>
 /// <returns>if it was feasible</returns>
 public bool Feasible(ITrip trip)
 {
     if ( trip.OriginalZone.Distance( trip.DestinationZone ) < this.MinDistance ) return false;
     if ( !trip.TripChain.Person.Licence || trip.TripChain.Person.Household.Vehicles.Length == 0 )
     {
         return false;
     }
     int egressStation;
     if ( ( egressStation = LatestAccessStation( trip.TripChain, trip ) ) == -1 ) return false;
     var station = this.TashaRuntime.ZoneSystem.Get( egressStation );
     var auto = this.TashaRuntime.AutoMode;
     //checking if there auto travel time is > 0 and the time in transit > 0 : meaning there exists
     //a route from origin to destination through subway station
     if ( auto.TravelTime( trip.DestinationZone, station, trip.TripStartTime ) > Time.Zero
         && this.TransitAccessData.InVehicleTravelTime( station, trip.OriginalZone, trip.TripStartTime ) > Time.Zero )
     {
         trip.Attach( "AccessStation", egressStation );
         return true;
     }
     return false;
 }
 private void SaveTrip(ITrip trip, int householdNumber, int personNumber, int tripNumber)
 {
     var writer = Writer;
     writer.Write(householdNumber);
     writer.Write(',');
     writer.Write(personNumber);
     writer.Write(',');
     writer.Write(tripNumber);
     writer.Write(',');
     writer.Write(trip.OriginalZone.ZoneNumber);
     writer.Write(',');
     writer.Write(trip.DestinationZone.ZoneNumber);
     writer.Write(',');
     writer.Write(GetPurposeName(trip.Purpose));
     writer.Write(',');
     writer.Write(trip.Mode.ModeName);
     writer.Write(',');
     writer.Write(trip.TripStartTime);
     writer.Write(',');
     writer.Write(trip.ActivityStartTime);
     writer.Write(',');
     writer.WriteLine(GetTripDistance(trip));
 }
예제 #56
0
 /// <summary>
 /// Calculates the V for a given trip
 ///
 /// Returns a 'random' V
 ///
 ///
 /// </summary>
 /// <param name="trip">The trip to calculate V for</param>
 /// <returns>The V for this trip</returns>
 public double CalculateV(ITrip trip)
 {
     int egressStation = (int)trip["AccessStation"];
     //LatestAccessStation(trip.TripChain, trip);
     var auto = this.TashaRuntime.AutoMode;
     var station = this.TashaRuntime.ZoneSystem.Get( egressStation );
     float V = this.CDriveEgress;
     V += this.AutoTime * auto.TravelTime( trip.DestinationZone, station, trip.TripStartTime ).ToMinutes();
     V += this.WalkTime * this.TransitAccessData.WalkTime( station, trip.OriginalZone, trip.TripStartTime ).ToMinutes();
     V += this.WaitTime * this.TransitAccessData.WaitTime( station, trip.OriginalZone, trip.TripStartTime ).ToMinutes();
     V += this.AutoCost * auto.Cost( trip.DestinationZone, station, trip.TripStartTime );
     V += this.TransitTime * this.TransitAccessData.InVehicleTravelTime( station, trip.OriginalZone, trip.TripStartTime ).ToMinutes();
     V += this.ParkingCost * this.TransitAccessData.Station( station ).ParkingCost;
     if ( ( Common.GetTimePeriod( trip.ActivityStartTime ) == Tasha.Common.TravelTimePeriod.Morning ) ||
             ( Common.GetTimePeriod( trip.ActivityStartTime ) == Tasha.Common.TravelTimePeriod.Afternoon ) )
     {
         V += PeakTrip;
     }
     if ( trip.TripChain.Person.Occupation == Occupation.Retail )
     {
         V += this.OccSalesTransit;
     }
     else if ( trip.TripChain.Person.Occupation == Occupation.Office )
     {
         V += this.OccGeneralTransit;
     }
     return V;
 }
예제 #57
0
 public bool Feasible(ITrip trip)
 {
     throw new NotImplementedException();
 }
 private double EvaluateTrip(ITrip trip)
 {
     int correct = 0;
     var observedMode = trip[ObservedMode];
     foreach(var choice in trip.ModesChosen)
     {
         if(choice == observedMode)
         {
             correct++;
         }
     }
     return correct;
 }
예제 #59
0
 private void IncreaseID(ref bool invalidPerson, int[] eventCount, int[][] startTimeCount, ITrip trip, int id)
 {
     if(id == -1) return;
     eventCount[id]++;
     if(!AddStartTime(startTimeCount, id, trip))
     {
         invalidPerson = true;
     }
 }
예제 #60
0
파일: GoAccess.cs 프로젝트: Cocotus/XTMF
        /// <summary>
        /// Calculates the V for a given trip
        /// </summary>
        /// <param name="trip"></param>
        /// <returns></returns>
        public double CalculateV(ITrip trip)
        {
            int[] accessStations = (int[])trip.GetVariable( "feasible-go-stations" );
            int egressStation = goData.GetClosestStations( trip.DestinationZone.ZoneNumber )[0];

            double[] V = new double[accessStations.Length];

            for ( int i = 0; i < accessStations.Length; i++ )
            {
                V[i] = this.CDriveAccess;
                V[i] += AutoTime * goData.GetAutoTime( trip.OriginalZone.ZoneNumber, accessStations[i] );
                V[i] += AutoCost * goData.GetAutoCost( trip.OriginalZone.ZoneNumber, accessStations[i] );
                V[i] += TransitRailTime * goData.GetLineHaulTime( accessStations[i], egressStation );
                V[i] += TransitTime * goData.GetTransitEgressTime( egressStation, trip.DestinationZone.ZoneNumber );
                V[i] += WalkTime * goData.GetEgressWalkTime( trip.DestinationZone.ZoneNumber, egressStation );
                V[i] += WaitTime * goData.GetEgressWaitTime( trip.DestinationZone.ZoneNumber, egressStation );
                V[i] += FareCost * ( goData.GetGoFair( accessStations[i], egressStation )
                                                + goData.GetTransitFair( trip.DestinationZone.ZoneNumber, egressStation ) );

                if ( ( Common.GetTimePeriod( trip.ActivityStartTime ) == Tasha.Common.TravelTimePeriod.Morning ) ||
            ( Common.GetTimePeriod( trip.ActivityStartTime ) == Tasha.Common.TravelTimePeriod.Afternoon ) )
                {
                    V[i] += PeakTrip;
                }

                if ( trip.TripChain.Person.Occupation == Occupation.Retail )
                {
                    V[i] += this.OccSalesTransit;
                }

                if ( trip.TripChain.Person.Occupation == Occupation.Office )
                {
                    V[i] += this.OccGeneralTransit;
                }
            }

            V.Sort( x => x, (y, z) => y < z );

            //int choice = Common.RandChoiceCDF(V, int.Parse(this.Configuration.Get("Seed")));
            int choice = 0;
            //attaching the station chosen
            trip.Attach( "go-access-station", accessStations[choice] );

            return V[choice];
        }