예제 #1
0
파일: TimeTable.cs 프로젝트: Cocotus/XTMF
        public static int GetFrequency(ITashaPerson person, Activity activity, Random random, int maxFrequency, Time startTime, Time endTime)
        {
            bool feasibleFreq = false;
            int freq = 0;
            while ( !feasibleFreq )
            {
                freq = Distribution.GetRandomFrequencyValue(
                    0, maxFrequency, random, Distribution.GetDistributionID( person, activity ) );
                if ( freq == 0 )
                {
                    break;
                }
                Time duration;
                if ( !Distribution.GetRandomStartTimeFrequency(
                Distribution.GetDistributionID( person, activity ), freq,
                Distribution.TimeOfDayToDistribution( startTime ), Distribution.TimeOfDayToDistribution( endTime ), random, out duration ) )
                {
                    //a bad thing happens here
                }
                else if ( duration != Time.Zero )
                {
                    feasibleFreq = true;
                }
            }

            return freq;
        }
예제 #2
0
파일: TimeTable.cs 프로젝트: Cocotus/XTMF
 public static int GetFrequency(ITashaPerson person, Activity activity, Random random, int maxFrequency)
 {
     int freq = 0;
     freq = Distribution.GetRandomFrequencyValue(
         0, maxFrequency, random, Distribution.GetDistributionID( person, activity ) );
     return freq;
 }
예제 #3
0
파일: TimeTable.cs 프로젝트: dianatle/XTMF
 public static int GetFrequency(ITashaPerson person, Activity activity, Random random, int maxFrequency, int householdPD, int workPD, GenerationAdjustment[] generationAdjustments)
 {
     int freq = 0;
     freq = Distribution.GetRandomFrequencyValue(
         0, maxFrequency, random, Distribution.GetDistributionID(person, activity), householdPD, workPD, generationAdjustments);
     return freq;
 }
예제 #4
0
 internal ActivityEpisode(long id, TimeWindow window, Activity type, ITashaPerson owner)
     : base(window, owner)
 {
     this.People = null;
     this.ActivityType = type;
     this.OriginalDuration = window.Duration;
     this.Owner = owner;
 }
예제 #5
0
파일: Household.cs 프로젝트: Cocotus/XTMF
 public Household(int id, ITashaPerson[] persons, IVehicle[] vehicles, float expansion, IZone zone)
 {
     //this.auxiliaryTripChains = new List<ITripChain>(7);
     HouseholdId = id;
     Persons = persons;
     Vehicles = vehicles;
     ExpansionFactor = expansion;
     HomeZone = zone;
 }
예제 #6
0
 internal TravelEpisode(int id, TimeWindow timeWindow, Episode from, Episode to, ITashaPerson owner)
     : base(timeWindow, owner)
 {
     //TODO: verify this line:
     this.ActivityType = to.ActivityType;
     //-----
     this.From = from;
     this.To = to;
 }
예제 #7
0
 public static IPersonIterationData MakePersonIterationData(ITashaPerson person)
 {
     PersonIterationData p;
     if ( Items.TryTake( out p ) )
     {
         p.PopulateData( person );
         return p;
     }
     return new PersonIterationData( person );
 }
예제 #8
0
 public void Generate(ITashaHousehold household, ITashaPerson person, List<IActivityEpisode> episodes, Random rand)
 {
     if ( person.StudentStatus == StudentStatus.FullTime )
     {
         this.School.Generate( household, person, episodes, rand );
         this.Work.Generate( household, person, episodes, rand );
     }
     else
     {
         this.Work.Generate( household, person, episodes, rand );
         this.School.Generate( household, person, episodes, rand );
     }
 }
예제 #9
0
파일: TimeTable.cs 프로젝트: Cocotus/XTMF
 public static int GetFrequency(ITashaPerson person, Activity activity, Random random)
 {
     int freq = 0;
     var distID = Distribution.GetDistributionID( person, activity );
     if ( distID < 0 )
     {
         throw new XTMFRuntimeException( "We were unable to get the distribution ID number for a person doing a '" + activity.ToString()
             + "' episode The person's householdID was " + person.Household.HouseholdId + ", personID was " + person.Id + ", was " + person.Age +
             " years old, with employment status '" + person.EmploymentStatus.ToString() + "' occupation '" + person.Occupation.ToString() + "' Student Status '"
             + person.StudentStatus.ToString() + "'.  Their work zone is '" + ( person.EmploymentZone != null ? person.EmploymentZone.ZoneNumber.ToString() : "None" )
             + "' and their school zone is '"
             + ( person.SchoolZone != null ? person.SchoolZone.ZoneNumber.ToString() : "None" ) + "'." );
     }
     freq = Distribution.GetRandomFrequencyValue(
         0, Distribution.NumberOfFrequencies - 1, random, distID );
     return freq;
 }
예제 #10
0
 private int LunchPass(ITashaPerson person, int[] eventCount, int[][] startTimeCount, ref Time workStartTime, ref Time workEndTime)
 {
     int lunchCount = 0;
     // Lunch pass
     foreach(var tripChain in person.TripChains)
     {
         foreach(var trip in tripChain.Trips)
         {
             if((trip.Purpose == Activity.Home) | (trip.Purpose == Activity.ReturnFromWork))
             {
                 Time activityStartTime = trip.OriginalZone == null || trip.DestinationZone == null ? trip.TripStartTime : trip.ActivityStartTime;
                 if(activityStartTime > workStartTime && activityStartTime < workEndTime)
                 {
                     var id = Distribution.GetDistributionID(person, Activity.ReturnFromWork);
                     if(id != -1)
                     {
                         eventCount[id]++;
                         AddStartTime(startTimeCount, id, trip);
                         lunchCount++;
                     }
                 }
             }
         }
     }
     return lunchCount;
 }
예제 #11
0
        private void AssignEpisodes(ITashaPerson person, ref Time workStartTime, ref Time workEndTime, Random random)
        {
            person.InitializePersonalProjects();
            var PersonData = person["SData"] as SchedulerPersonData;

            foreach(var TripChain in person.TripChains)
            {
                for(int j = 0; j < (TripChain.Trips.Count - 1); j++)
                {
                    var ThisTrip = TripChain.Trips[j];
                    var NextTrip = TripChain.Trips[j + 1];
                    ThisTrip.Mode = ThisTrip[ObservedMode] as ITashaMode;
                    NextTrip.Mode = NextTrip[ObservedMode] as ITashaMode;
                    var startTime = ThisTrip.OriginalZone == null || ThisTrip.DestinationZone == null ? ThisTrip.TripStartTime : ThisTrip.ActivityStartTime;
                    var endTime = NextTrip.TripStartTime;
                    var duration = endTime - startTime;
                    if(duration < Time.Zero)
                    {
                        endTime = Time.EndOfDay;
                    }
                    if(endTime < startTime)
                    {
                        startTime = ThisTrip.TripStartTime;
                    }

                    if(ThisTrip.Purpose == Activity.PrimaryWork || ThisTrip.Purpose == Activity.SecondaryWork || ThisTrip.Purpose == Activity.WorkBasedBusiness)
                    {
                        var NewEpisode = new ActivityEpisode(0, new TimeWindow(startTime, endTime), ThisTrip.Purpose, person);
                        NewEpisode.Zone = ThisTrip.DestinationZone;
                        if(ThisTrip.Purpose == Activity.PrimaryWork || ThisTrip.Purpose == Activity.WorkBasedBusiness)
                        {
                            if(workStartTime == Time.Zero || NewEpisode.StartTime < workStartTime)
                            {
                                workStartTime = NewEpisode.StartTime;
                            }
                            if(workEndTime == Time.Zero || NewEpisode.EndTime > workEndTime)
                            {
                                workEndTime = NewEpisode.EndTime;
                            }
                        }
                        PersonData.WorkSchedule.Schedule.Insert(NewEpisode, random);
                    }
                    if(ThisTrip.Purpose == Activity.School)
                    {
                        var NewEpisode = new ActivityEpisode(0, new TimeWindow(startTime, endTime), ThisTrip.Purpose, person);
                        NewEpisode.Zone = ThisTrip.DestinationZone;
                        PersonData.SchoolSchedule.Schedule.Insert(NewEpisode, random);
                    }
                }
            }
        }
예제 #12
0
 internal PersonalProject(Schedule schedule, ITashaPerson person)
     : base(schedule)
 {
     this.Person = person;
 }
예제 #13
0
 private SchedulerTripChain(ITashaPerson person)
 {
     this.Person = person;
     this.Trips  = new List <ITrip>(3);
 }
예제 #14
0
파일: Household.cs 프로젝트: Cocotus/XTMF
        public ITripChain GetJointTourTripChain(int tourID, ITashaPerson person)
        {
            foreach (var tripchain in person.TripChains)
            {
                if (tripchain.JointTripID == tourID)
                    return tripchain;
            }

            return null;
        }
예제 #15
0
 private Episode CreateEpisode(ITrip trip, ITrip nextTrip, ITashaPerson owner)
 {
     return new ActivityEpisode(0, new TimeWindow(trip.ActivityStartTime, nextTrip.ActivityStartTime), trip.Purpose, owner);
 }
예제 #16
0
 internal override void AddPerson(ITashaPerson person)
 {
     throw new NotImplementedException();
 }
예제 #17
0
 public Time TravelTime(ITashaPerson person, IZone origin, IZone destination, Time tashaTime)
 {
     return(Time.Zero);
 }
예제 #18
0
 private void StoreTripRecord(int hhldID, ITashaPerson person, float expFactor, int tripID, Activity previousActivity, ITrip trip)
 {
     _tripRecordQueue.Add(new TripRecord(hhldID, person.Id, tripID,
                                         trip.OriginalZone.ZoneNumber, GetActivityChar(previousActivity),
                                         trip.DestinationZone.ZoneNumber, GetActivityChar(trip.Purpose), expFactor));
 }
예제 #19
0
 public PersonChain(ITashaPerson person, ITripChain chain)
 {
     Person = person;
     Chain  = chain;
 }
예제 #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e">The episode to find a zone for</param>
 /// <param name="person">The person to look at (their household)</param>
 /// <returns></returns>
 public IZone GetLocationHomeBased(IEpisode e, ITashaPerson person, Random random)
 {
     return(GetLocationHomeBased(e.ActivityType, person.Household.HomeZone, random));
 }
        /// <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);
            }
        }
예제 #22
0
        private PurePassengerTripChain CreateDriverTripChain(Time Start, Time End, IZone HomeZone, ITashaPerson driver)
        {
            var mode            = PassengerMode.AssociatedMode;
            var driverTrip      = PurePassengerTrip.MakeDriverTrip(HomeZone, mode, Start, End);
            var driverTripChain = new PurePassengerTripChain();

            driverTrip.TripChain = driverTripChain;
            driverTripChain.Trips.Add(driverTrip);
            driverTripChain.Person = driver;
            return(driverTripChain);
        }
예제 #23
0
파일: TimeTable.cs 프로젝트: Cocotus/XTMF
        /// <summary>
        /// Gets a duration from the given startTime based on a person and activity and startTime.
        /// The duration will be less than the length of the day minus the startTime
        /// </summary>
        /// <param name="person"></param>
        /// <param name="activity"></param>
        /// <param name="startTime"></param>
        /// <returns></returns>
        internal static bool GetDuration(ITashaPerson person, Activity activity, Time startTime, Random random, out Time duration)
        {
            int length = Scheduler.StartTimeQuanta - 1 - Distribution.TimeOfDayToDistribution( startTime );

            return Distribution.GetRandomStartDurationTimeFrequency( Distribution.GetDistributionID( person, activity ), startTime, 0, length, random, out duration );
        }
예제 #24
0
 /// <summary>
 /// Creates a person's iteration data for the specified household iteration
 /// </summary>
 /// <param name="person">the person</param>
 /// <param name="hIteration">the household iteration</param>
 private PersonIterationData(ITashaPerson person)
     : this()
 {
     this.TripChains = new List <ITripChain>();
     PopulateData(person);
 }
예제 #25
0
파일: TimeTable.cs 프로젝트: Cocotus/XTMF
 internal static bool GetStartTime(ITashaPerson person, Activity activity, int frequency, Random random, out Time startTime)
 {
     return Distribution.GetRandomStartTimeFrequency( Distribution.GetDistributionID( person, activity ),
                             frequency, 0, Scheduler.StartTimeQuanta - 1, random, out startTime );
 }
예제 #26
0
        private bool BuildUtility(IZone firstOrigin, IZone secondOrigin, Pair <IZone[], float[]> accessData, IZone firstDestination, IZone secondDestination,
                                  ITashaPerson person, Time firstTime, Time secondTime, out float dependentUtility)
        {
            var   zones = accessData.First;
            var   utils = accessData.Second;
            var   totalUtil = 0.0f;
            float ivttBeta, costBeta, walkBeta, waitBeta, boardingBeta, constant;

            GetPersonVariables(person, out constant, out ivttBeta, out walkBeta, out waitBeta, out boardingBeta, out costBeta);
            if (VectorHelper.IsHardwareAccelerated)
            {
                totalUtil = VectorHelper.Sum(utils, 0, utils.Length);
            }
            else
            {
                for (int i = 0; i < utils.Length; i++)
                {
                    totalUtil += utils[i];
                }
            }
            if (totalUtil <= 0)
            {
                dependentUtility = float.NaN;
                return(false);
            }
            dependentUtility = GetPlanningDistrictConstant(firstTime, firstOrigin.PlanningDistrict, firstDestination.PlanningDistrict)
                               + GetPlanningDistrictConstant(secondTime, secondOrigin.PlanningDistrict, secondDestination.PlanningDistrict);
            totalUtil = 1 / totalUtil;
            // we still need to do this in order to reduce time for computing the selected access station
            if (VectorHelper.IsHardwareAccelerated)
            {
                VectorHelper.Multiply(utils, 0, utils, 0, totalUtil, utils.Length);
            }
            else
            {
                for (int i = 0; i < utils.Length; i++)
                {
                    utils[i] *= totalUtil;
                }
            }
            var zoneSystem = Root.ZoneSystem.ZoneArray;
            var fo         = zoneSystem.GetFlatIndex(firstOrigin.ZoneNumber);
            var so         = zoneSystem.GetFlatIndex(secondOrigin.ZoneNumber);
            var fd         = zoneSystem.GetFlatIndex(firstDestination.ZoneNumber);
            var sd         = zoneSystem.GetFlatIndex(secondDestination.ZoneNumber);

            totalUtil = 0;
            var fastTransit        = TransitNetwork as ITripComponentCompleteData;
            var fastAuto           = AutoNetwork as INetworkCompleteData;
            var stationIndexLookup = StationIndexLookup;

            if (stationIndexLookup == null)
            {
                stationIndexLookup = CreateStationIndexLookup(zoneSystem, zones);
            }
            if (fastTransit == null | fastAuto == null)
            {
                for (int i = 0; i < utils.Length; i++)
                {
                    var stationIndex = StationIndexLookup[i];
                    var probability  = utils[i];
                    if (probability > 0)
                    {
                        var   local = 0.0f;
                        float tivtt, twalk, twait, boarding, cost;
                        TransitNetwork.GetAllData(stationIndex, fd, firstTime, out tivtt, out twalk, out twait, out boarding, out cost);
                        local += tivtt * ivttBeta + twalk * walkBeta + twait * waitBeta + cost * costBeta + boarding * boardingBeta;
                        TransitNetwork.GetAllData(stationIndex, so, secondTime, out tivtt, out twalk, out twait, out boarding, out cost);
                        local += tivtt * ivttBeta + twalk * walkBeta + twait * waitBeta + cost * costBeta + boarding * boardingBeta;
                        AutoNetwork.GetAllData(fo, stationIndex, firstTime, out tivtt, out cost);
                        local += tivtt * ivttBeta + costBeta * cost;
                        AutoNetwork.GetAllData(stationIndex, sd, secondTime, out tivtt, out cost);
                        local     += tivtt * ivttBeta + costBeta * cost;
                        totalUtil += local * probability;
                    }
                }
            }
            else
            {
                int numberOfZones = zoneSystem.GetFlatData().Length;
                // fo, and so are constant across stations, so we can pull that part of the computation out
                fo = fo * numberOfZones;
                so = so * numberOfZones;
                float[] firstAutoMatrix     = fastAuto.GetTimePeriodData(firstTime);
                float[] firstTransitMatrix  = fastTransit.GetTimePeriodData(firstTime);
                float[] secondAutoMatrix    = fastAuto.GetTimePeriodData(secondTime);
                float[] secondTransitMatrix = fastTransit.GetTimePeriodData(secondTime);
                if (firstTransitMatrix == null || secondTransitMatrix == null)
                {
                    dependentUtility = float.NaN;
                    return(false);
                }
                for (int i = 0; i < utils.Length; i++)
                {
                    var stationIndex          = stationIndexLookup[i];
                    int origin1ToStation      = (fo + stationIndex) << 1;
                    int stationToDestination1 = ((stationIndex * numberOfZones) + fd) * 5;
                    int origin2ToStation      = (so + stationIndex) * 5;
                    int stationToDestination2 = ((stationIndex * numberOfZones) + sd) << 1;
                    if (utils[i] > 0)
                    {
                        // transit utility
                        var tivtt    = firstTransitMatrix[stationToDestination1] + secondTransitMatrix[origin2ToStation];
                        var twait    = firstTransitMatrix[stationToDestination1 + 1] + secondTransitMatrix[origin2ToStation + 1];
                        var twalk    = firstTransitMatrix[stationToDestination1 + 2] + secondTransitMatrix[origin2ToStation + 2];
                        var tcost    = firstTransitMatrix[stationToDestination1 + 3] + secondTransitMatrix[origin2ToStation + 3];
                        var boarding = firstTransitMatrix[stationToDestination1 + 4] + secondTransitMatrix[origin2ToStation + 4];
                        var aivtt    = firstAutoMatrix[origin1ToStation] + secondAutoMatrix[stationToDestination2];
                        var acost    = firstAutoMatrix[origin1ToStation + 1] + secondAutoMatrix[stationToDestination2 + 1];
                        var utility  = (tivtt + aivtt) * ivttBeta + twalk * walkBeta + twait * waitBeta + (acost + tcost) * costBeta + boarding * boardingBeta;
                        totalUtil += utility * utils[i];
                    }
                }
            }
            dependentUtility += totalUtil;
            return(true);
        }
예제 #27
0
        public static void AssignJointTours(ITashaHousehold household)
        {
            Dictionary <int, List <ITripChain> > JointTours = household.JointTours;
            ITashaMode rideShare      = null;
            int        rideShareIndex = -1;
            var        allModes       = TashaRuntime.AllModes;
            var        numberOfModes  = allModes.Count;

            for (int i = 0; i < numberOfModes; i++)
            {
                if ((allModes[i] is ISharedMode) && allModes[i].ModeName == "RideShare")
                {
                    rideShare      = allModes[i];
                    rideShareIndex = i;
                }
            }
            //no rideshare mode?
            if (rideShare == null)
            {
                return;
            }
            //go through each joint tour and assign identical modes for each tripchain in a tour if possible
            foreach (var element in JointTours)
            {
                List <ITripChain>  tripChains = element.Value;
                IList <ITashaMode> nonVehicleModesChosen;
                double             nonVehicleU;
                //does a non vehicle tour exist
                bool nonVehicleTour = BestNonVehicleModeSetForTour(tripChains, out nonVehicleModesChosen, out nonVehicleU);
                //the potential driver in this tour
                ITashaPerson potentialDriver = null;
                //finding potential driver who already has the car
                foreach (var tripChain in tripChains)
                {
                    if (tripChain.requiresVehicle.Contains(rideShare.RequiresVehicle))
                    {
                        potentialDriver = tripChain.Person;
                        break;
                    }
                }
                //if no one has the car check if one is available
                if (potentialDriver == null)
                {
                    if (household.NumberOfVehicleAvailable(
                            new TashaTimeSpan(tripChains[0].StartTime, tripChains[0].EndTime), rideShare.RequiresVehicle, false) > 0)
                    {
                        foreach (var tc in tripChains)
                        {
                            if (rideShare.RequiresVehicle.CanUse(tc.Person))
                            {
                                potentialDriver = tc.Person;
                                break;
                            }
                        }
                    }
                }
                //No potential driver and no nonVehicle tour means that ppl in this tour have to take different modes which shouldnt happen
                if ((potentialDriver == null) & (!nonVehicleTour))
                {
                    continue;
                }
                double oldU = Double.MinValue;
                if (nonVehicleTour)
                {
                    oldU = nonVehicleU;
                }
                //no driver, go to next tour
                if (potentialDriver == null)
                {
                    continue;
                }
                double newU    = 0.0;
                bool   success = true;

                /*
                 * Now we assign the rideshare mode and if the total U of everyone using rideshare is less than that
                 * of a non personal vehicle mode, everyone uses rideshare
                 *
                 */
                foreach (var tripChain in tripChains)
                {
                    foreach (var trip in tripChain.Trips)
                    {
                        ModeData md = (ModeData)trip.GetVariable("MD");
                        trip.Mode = rideShare;
                        trip.CalculateVTrip();
                        newU += md.U(rideShareIndex);
                    }
                    if (!tripChain.Feasible())
                    {
                        success = false;
                        break;
                    }
                }
                //reset modes
                if ((!success || newU <= oldU) & (nonVehicleTour))
                {
                    SetModes(tripChains, nonVehicleModesChosen);
                    //go to next joint trip
                    continue;
                }
            }
        }
예제 #28
0
        private void GetPersonVariables(ITashaPerson person, out float constant, out float time, out float walk, out float wait, out float boarding, out float cost)
        {
            if (person.EmploymentStatus == TTSEmploymentStatus.FullTime)
            {
                switch (person.Occupation)
                {
                case Occupation.Professional:
                    cost     = ProfessionalCost;
                    constant = ProfessionalConstant;
                    time     = ProfessionalTimeFactor;
                    walk     = ProfessionalTransitWalk;
                    wait     = ProfessionalTransitWait;
                    boarding = ProfessionalTransitBoarding;
                    return;

                case Occupation.Office:
                    cost     = GeneralCost;
                    constant = GeneralConstant;
                    time     = GeneralTimeFactor;
                    walk     = GeneralTransitWalk;
                    wait     = GeneralTransitWait;
                    boarding = GeneralTransitBoarding;
                    return;

                case Occupation.Retail:
                    cost     = SalesCost;
                    constant = SalesConstant;
                    time     = SalesTimeFactor;
                    walk     = SalesTransitWalk;
                    wait     = SalesTransitWait;
                    boarding = SalesTransitBoarding;
                    return;

                case Occupation.Manufacturing:
                    cost     = ManufacturingCost;
                    constant = ManufacturingConstant;
                    time     = ManufacturingTimeFactor;
                    walk     = ManufacturingTransitWalk;
                    wait     = ManufacturingTransitWait;
                    boarding = ManufacturingTransitBoarding;
                    return;
                }
            }
            switch (person.StudentStatus)
            {
            case StudentStatus.FullTime:
            case StudentStatus.PartTime:
                cost     = StudentCost;
                constant = StudentConstant;
                time     = StudentTimeFactor;
                walk     = StudentTransitWalk;
                wait     = StudentTransitWait;
                boarding = StudentTransitBoarding;
                return;
            }
            if (person.EmploymentStatus == TTSEmploymentStatus.PartTime)
            {
                switch (person.Occupation)
                {
                case Occupation.Professional:
                    cost     = ProfessionalCost;
                    constant = ProfessionalConstant;
                    time     = ProfessionalTimeFactor;
                    walk     = ProfessionalTransitWalk;
                    wait     = ProfessionalTransitWait;
                    boarding = ProfessionalTransitBoarding;
                    return;

                case Occupation.Office:
                    cost     = GeneralCost;
                    constant = GeneralConstant;
                    time     = GeneralTimeFactor;
                    walk     = GeneralTransitWalk;
                    wait     = GeneralTransitWait;
                    boarding = GeneralTransitBoarding;
                    return;

                case Occupation.Retail:
                    cost     = SalesCost;
                    constant = SalesConstant;
                    time     = SalesTimeFactor;
                    walk     = SalesTransitWalk;
                    wait     = SalesTransitWait;
                    boarding = SalesTransitBoarding;
                    return;

                case Occupation.Manufacturing:
                    cost     = ManufacturingCost;
                    constant = ManufacturingConstant;
                    time     = ManufacturingTimeFactor;
                    walk     = ManufacturingTransitWalk;
                    wait     = ManufacturingTransitWait;
                    boarding = ManufacturingTransitBoarding;
                    return;
                }
            }
            cost     = NonWorkerStudentCost;
            constant = NonWorkerStudentConstant;
            time     = NonWorkerStudentTimeFactor;
            walk     = NonWorkerStudentTransitWalk;
            wait     = NonWorkerStudentTransitWait;
            boarding = NonWorkerStudentTransitBoarding;
        }
예제 #29
0
 public IZone GetLocationHomeBased(IEpisode episode, ITashaPerson person, Random random)
 {
     throw new NotImplementedException("This method is no longer supported for V4.0+");
 }
예제 #30
0
 internal PersonalProject(Schedule schedule, ITashaPerson person)
     : base(schedule)
 {
     Person = person;
 }
예제 #31
0
 internal override void AddPerson(ITashaPerson person)
 {
     throw new NotImplementedException();
 }
예제 #32
0
        private bool PrimaryWorkStartTime(ITashaPerson person, int personIndex, ISchedule[] schedule, IActivityEpisode episode, Random rand)
        {
            var personSchedule            = schedule[personIndex];
            var episodeList               = personSchedule.GenerateScheduledEpisodeList();
            var episodeDuration           = episode.Duration;
            List <TimeWindow> timeWindows = new List <TimeWindow>();

            //If there are no episodes in the schedule, then we can place it anywhere
            if (episodeList.Length == 0 || episodeList[0] == null)
            {
                timeWindows.Add(new TimeWindow()
                {
                    StartTime = this.StartOfDay, EndTime = this.EndOfDay
                });
                return(GiveStartTimeForPrimaryWork(timeWindows, episode));
            }
            else
            {
                //Check before the first episode
                {
                    //Check after the last episode
                    var firstStartTime = episodeList[0].StartTime;
                    if (firstStartTime - this.StartOfDay >= episodeDuration)
                    {
                        timeWindows.Add(new TimeWindow()
                        {
                            StartTime = this.StartOfDay, EndTime = firstStartTime
                        });
                    }
                }
                //Check between each episode
                for (int i = 0; i < episodeList.Length - 1; i++)
                {
                    var e = episodeList[i + 1];
                    if (e == null)
                    {
                        break;
                    }
                    var endTime   = episodeList[i].EndTime;
                    var startTime = episodeList[i + 1].StartTime;
                    if (endTime - startTime >= episodeDuration)
                    {
                        timeWindows.Add(new TimeWindow()
                        {
                            StartTime = startTime, EndTime = endTime
                        });
                    }
                }
                if (episodeList.Length > 1)
                {
                    //Check after the last episode
                    var lastEpisodeEndTime = episodeList[episodeList.Length - 1].EndTime;
                    if (this.EndOfDay - lastEpisodeEndTime >= episodeDuration)
                    {
                        timeWindows.Add(new TimeWindow()
                        {
                            StartTime = lastEpisodeEndTime, EndTime = this.EndOfDay
                        });
                    }
                }
            }
            return(GiveStartTimeForPrimaryWork(timeWindows, episode));
        }
예제 #33
0
파일: Schedule.cs 프로젝트: Cocotus/XTMF
        public ConflictReport InsertCase(ITashaPerson owner, Episode ep, bool travelTime)
        {
            ConflictReport report;
            report.Type = ScheduleConflictType.NoConflict;
            report.Position = this.EpisodeCount;

            for ( int i = 0; i < this.EpisodeCount; i++ )
            {
                if ( this.Episodes[i].EndTime + this.Episodes[i].TravelTime < ep.StartTime ) continue;
                Time epEnd = ep.EndTime;
                Time ithEnd = this.Episodes[i].EndTime;
                if ( travelTime )
                {
                    ep.TravelTime = ( this.EpisodeCount - 1 > i ) ?
                        Scheduler.TravelTime( owner, ep.Zone, this.Episodes[i + 1].Zone, ep.EndTime ) : Time.Zero;
                    epEnd += ep.TravelTime;
                    ithEnd += this.Episodes[i].TravelTime;
                }
                report.Position = i;
                // Check for Complete overlap of the ith position
                if ( this.Episodes[i].StartTime >= ep.StartTime && ( epEnd >= ithEnd || ep.EndTime >= this.Episodes[i].EndTime ) )
                {
                    report.Type = ScheduleConflictType.CompleteOverlap;
                }
                else if ( this.EpisodeCount - 1 > i && this.Episodes[i + 1].StartTime >= ep.StartTime && epEnd >= this.Episodes[i + 1].EndTime )
                {
                    report.Type = ScheduleConflictType.CompleteOverlap;
                }
                else if ( this.Episodes[i].StartTime < ep.StartTime && ep.EndTime < this.Episodes[i].EndTime )
                {
                    report.Type = ScheduleConflictType.Split;
                }
                else if ( this.Episodes[i].StartTime >= ep.StartTime && ep.EndTime < this.Episodes[i].EndTime )
                {
                    report.Type = ScheduleConflictType.Prior;
                }
                else if ( this.Episodes[i].StartTime < ep.StartTime && ep.EndTime >= this.Episodes[i].EndTime )
                {
                    report.Type = ScheduleConflictType.Posterior;
                }
                break;
            }
            return report; // There is no conflict
        }
예제 #34
0
 public PersonSchedule(ITashaPerson owner)
 {
     Owner         = owner;
     FirstTripTime = Time.Zero;
 }
예제 #35
0
        private void GetPersonVariables(ITashaPerson person, out float time, out float constant)
        {
            if (person.EmploymentStatus == TTSEmploymentStatus.FullTime)
            {
                switch (person.Occupation)
                {
                case Occupation.Professional:
                    constant = ProfessionalConstant;
                    time     = ProfessionalTimeFactor;
                    return;

                case Occupation.Office:
                    constant = GeneralConstant;
                    time     = GeneralTimeFactor;
                    return;

                case Occupation.Retail:
                    constant = SalesConstant;
                    time     = SalesTimeFactor;
                    return;

                case Occupation.Manufacturing:
                    constant = ManufacturingConstant;
                    time     = ManufacturingTimeFactor;
                    return;
                }
            }
            switch (person.StudentStatus)
            {
            case StudentStatus.FullTime:
            case StudentStatus.PartTime:
                constant = StudentConstant;
                time     = StudentTimeFactor;
                return;
            }
            if (person.EmploymentStatus == TTSEmploymentStatus.PartTime)
            {
                switch (person.Occupation)
                {
                case Occupation.Professional:
                    constant = ProfessionalConstant;
                    time     = ProfessionalTimeFactor;
                    return;

                case Occupation.Office:
                    constant = GeneralConstant;
                    time     = GeneralTimeFactor;
                    return;

                case Occupation.Retail:
                    constant = SalesConstant;
                    time     = SalesTimeFactor;
                    return;

                case Occupation.Manufacturing:
                    constant = ManufacturingConstant;
                    time     = ManufacturingTimeFactor;
                    return;
                }
            }
            constant = NonWorkerStudentConstant;
            time     = NonWorkerStudentTimeFactor;
        }
예제 #36
0
파일: Episode.cs 프로젝트: taha-islam/XTMF
 /// <summary>
 /// Checks to see if a person is the owner of an episode
 /// </summary>
 public bool IsOwner(ITashaPerson person)
 {
     return(person == this.Owner);
 }
예제 #37
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;
 }
예제 #38
0
파일: Episode.cs 프로젝트: taha-islam/XTMF
 /// <summary>
 /// Checks to see if this person is on the trip
 /// </summary>
 /// <param name="person">The person we are testing for</param>
 /// <returns>True, if the person is found</returns>
 public abstract bool IsPersonIncluded(ITashaPerson person);
예제 #39
0
파일: Carpool.cs 프로젝트: dianatle/XTMF
 private void GetPersonVariables(ITashaPerson person, out float time, out float constant, out float cost)
 {
     if(person.EmploymentStatus == TTSEmploymentStatus.FullTime)
     {
         switch(person.Occupation)
         {
             case Occupation.Professional:
                 cost = ProfessionalCost;
                 constant = ProfessionalConstant;
                 time = ProfessionalTimeFactor;
                 return;
             case Occupation.Office:
                 cost = GeneralCost;
                 constant = GeneralConstant;
                 time = GeneralTimeFactor;
                 return;
             case Occupation.Retail:
                 cost = SalesCost;
                 constant = SalesConstant;
                 time = SalesTimeFactor;
                 return;
             case Occupation.Manufacturing:
                 cost = ManufacturingCost;
                 constant = ManufacturingConstant;
                 time = ManufacturingTimeFactor;
                 return;
         }
     }
     switch(person.StudentStatus)
     {
         case StudentStatus.FullTime:
         case StudentStatus.PartTime:
             cost = StudentCost;
             constant = StudentConstant;
             time = StudentTimeFactor;
             return;
     }
     if(person.EmploymentStatus == TTSEmploymentStatus.PartTime)
     {
         switch(person.Occupation)
         {
             case Occupation.Professional:
                 cost = ProfessionalCost;
                 constant = ProfessionalConstant;
                 time = ProfessionalTimeFactor;
                 return;
             case Occupation.Office:
                 cost = GeneralCost;
                 constant = GeneralConstant;
                 time = GeneralTimeFactor;
                 return;
             case Occupation.Retail:
                 cost = SalesCost;
                 constant = SalesConstant;
                 time = SalesTimeFactor;
                 return;
             case Occupation.Manufacturing:
                 cost = ManufacturingCost;
                 constant = ManufacturingConstant;
                 time = ManufacturingTimeFactor;
                 return;
         }
     }
     cost = NonWorkerStudentCost;
     constant = NonWorkerStudentConstant;
     time = NonWorkerStudentTimeFactor;
     return;
 }
예제 #40
0
파일: Episode.cs 프로젝트: taha-islam/XTMF
 /// <summary>
 /// Includes a person in the episode
 /// </summary>
 /// <param name="person">The person to include</param>
 internal abstract void AddPerson(ITashaPerson person);
예제 #41
0
파일: TimeTable.cs 프로젝트: Cocotus/XTMF
 /// <summary>
 /// Gets a duration that is not greater than the given max Duration
 /// </summary>
 /// <param name="person"></param>
 /// <param name="activity"></param>
 /// <param name="startTime"></param>
 /// <param name="maxDuration"></param>
 /// <returns></returns>
 internal static bool GetDuration(ITashaPerson person, Activity activity, Time startTime, Time maxDuration, Random random, out Time returnStartTime)
 {
     return Distribution.GetRandomStartDurationTimeFrequency( Distribution.GetDistributionID( person, activity ), startTime, 0, Distribution.DurationToDistribution( maxDuration ), random, out returnStartTime );
 }
예제 #42
0
파일: Episode.cs 프로젝트: taha-islam/XTMF
 /// <summary>
 /// Creates a new Episode
 /// </summary>
 /// <param name="id">The id for the event</param>
 /// <param name="window">The window in time this episode occurs in</param>
 internal Episode(TimeWindow window, ITashaPerson owner)
 {
     this.Window = window;
     // originally we have no travel time
     this.TravelTime = Time.Zero;
 }
예제 #43
0
파일: TimeTable.cs 프로젝트: Cocotus/XTMF
 /// <summary>
 /// Gets a startTime between the given startTime and endTime
 /// </summary>
 /// <param name="person"></param>
 /// <param name="activity"></param>
 /// <param name="frequency"></param>
 /// <param name="startTime"></param>
 /// <param name="endTime"></param>
 /// <returns></returns>
 internal static bool GetStartTime(ITashaPerson person, Activity activity, int frequency, Time startTime, Time endTime, Random random, out Time returnTime)
 {
     return Distribution.GetRandomStartTimeFrequency( Distribution.GetDistributionID( person, activity ),
                            frequency, Distribution.TimeOfDayToDistribution( startTime ), Distribution.TimeOfDayToDistribution( endTime ), random, out returnTime );
 }
예제 #44
0
 internal static void PrimaryWorkStartTimeAndDuration(ITashaPerson person, out Time startTime, out Time duration)
 {
     throw new NotImplementedException();
 }
예제 #45
0
        /// <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));
        }
예제 #46
0
 public override bool IsPersonIncluded(ITashaPerson person)
 {
     if ( this.From != null )
     {
         return this.From.IsOwner( person );
     }
     else if ( this.To != null )
     {
         return this.To.IsOwner( person );
     }
     return false;
 }
예제 #47
0
파일: Walk.cs 프로젝트: Cocotus/XTMF
 private void GetPersonVariables(ITashaPerson person, out float constant, out float walk)
 {
     if(person.EmploymentStatus == TTSEmploymentStatus.FullTime)
     {
         switch(person.Occupation)
         {
             case Occupation.Professional:
                 constant = ProfessionalConstant;
                 walk = ProfessionalWalk;
                 return;
             case Occupation.Office:
                 constant = GeneralConstant;
                 walk = GeneralWalk;
                 return;
             case Occupation.Retail:
                 constant = SalesConstant;
                 walk = SalesWalk;
                 return;
             case Occupation.Manufacturing:
                 constant = ManufacturingConstant;
                 walk = ManufacturingWalk;
                 return;
         }
     }
     switch(person.StudentStatus)
     {
         case StudentStatus.FullTime:
         case StudentStatus.PartTime:
             constant = StudentConstant;
             walk = StudentWalk;
             return;
     }
     if(person.EmploymentStatus == TTSEmploymentStatus.PartTime)
     {
         switch(person.Occupation)
         {
             case Occupation.Professional:
                 constant = ProfessionalConstant;
                 walk = ProfessionalWalk;
                 return;
             case Occupation.Office:
                 constant = GeneralConstant;
                 walk = GeneralWalk;
                 return;
             case Occupation.Retail:
                 constant = SalesConstant;
                 walk = SalesWalk;
                 return;
             case Occupation.Manufacturing:
                 constant = ManufacturingConstant;
                 walk = ManufacturingWalk;
                 return;
         }
     }
     constant = NonWorkerStudentConstant;
     walk = NonWorkerStudentWalk;
     return;
 }
예제 #48
0
        internal static Time GetWorkSchoolStartTime(ITashaPerson person)
        {
            Time workSchoolStartTime = Time.Zero;
            Project workProject = person.GetWorkProject();
            Schedule workSchedule = workProject.Schedule;
            Time workStartTime = workSchedule.GetFirstEpisodeStartTime();
            Project schoolProject = person.GetSchoolProject();
            Schedule schoolSchedule = schoolProject.Schedule;
            Time schoolStartTime = schoolSchedule.GetFirstEpisodeStartTime();

            if ( workStartTime != Time.Zero && schoolStartTime == Time.Zero )
            {
                workSchoolStartTime = workStartTime;
            }
            else if ( workStartTime == Time.Zero && schoolStartTime != Time.Zero )
            {
                workSchoolStartTime = schoolStartTime;
            }
            else if ( workStartTime != Time.Zero && schoolStartTime != Time.Zero )
            {
                workSchoolStartTime = schoolStartTime < workStartTime ? schoolStartTime : workStartTime;
            }
            else
            {
                workSchoolStartTime = Time.Zero;
            }

            return workSchoolStartTime;
        }
예제 #49
0
 public PersonSchedule(ITashaPerson owner)
 {
     Owner = owner;
     FirstTripTime = Time.Zero;
 }
예제 #50
0
 public bool AssignStartTime(ITashaPerson person, int personIndex, ISchedule[] schedule, IActivityEpisode episode, Random rand)
 {
     throw new NotImplementedException("This method should never be called, either the work or school project should be invoked.");
 }
예제 #51
0
 public IZone GetLocationWorkBased(IZone primaryWorkZone, ITashaPerson person, Random random)
 {
     throw new NotImplementedException("This method is no longer supported for V4.0+");
 }
예제 #52
0
 internal static void SetMarketProject(this ITashaPerson person, PersonalProject market)
 {
     (person["SData"] as SchedulerPersonData).MarketSchedule = market;
 }
예제 #53
0
 /// <summary>
 /// Tests to see if a person can use a vehicle of this type
 /// </summary>
 /// <param name="person">The person to test for</param>
 /// <returns>If they can use it or not</returns>
 public bool CanUse(ITashaPerson person)
 {
     return(person.Licence && person.Household.Vehicles.Count(n => n.VehicleType.Equals(this)) > 0);
 }
예제 #54
0
 internal static void SetOtherProject(this ITashaPerson person, PersonalProject other)
 {
     (person["SData"] as SchedulerPersonData).OtherSchedule = other;
 }
예제 #55
0
파일: Zone.cs 프로젝트: taha-islam/XTMF
 public IZone GetWorkBasedLocation(Activity activity, ITashaPerson person)
 {
     throw new NotImplementedException();
 }
예제 #56
0
        /// <summary>
        /// Returns the distribution ID that this person belongs to
        /// </summary>
        /// <param name="person"></param>
        /// <param name="activity"></param>
        /// <returns></returns>
        internal static int GetDistributionID(ITashaPerson person, Activity activity)
        {
            int baseOffset;
            int ageOffset;
            int occupationOffset;
            int age = person.Age;

            switch (activity)
            {
            case Activity.School:
                baseOffset = 84;
                //Now Calculate the occupation offset
                switch (person.StudentStatus)
                {
                case StudentStatus.FullTime:
                    occupationOffset = 0;
                    break;

                case StudentStatus.PartTime:
                    occupationOffset = 1;
                    break;

                default:
                    return(-1);
                }
                if (age < 11)
                {
                    return(-1);
                }
                //Calculate the ageOffset
                if (age <= 15)
                {
                    ageOffset = 0;
                }
                else if (age <= 18)
                {
                    ageOffset = 1;
                }
                else if (age <= 25)
                {
                    ageOffset = 2;
                }
                else if (age <= 30)
                {
                    ageOffset = 3;
                }
                else
                {
                    ageOffset = 4;
                }
                return(baseOffset + (ageOffset * 2) + occupationOffset);

            case Activity.WorkBasedBusiness:
                // We store the values from the person to improve performance
                baseOffset = 40;
                Occupation occupation = person.Occupation;
                if (person.EmploymentStatus != TTSEmploymentStatus.FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.PartTime)
                {
                    return(-1);
                }
                //Calculate the ageOffset
                if (age < 11)
                {
                    return(-1);
                }
                if (age <= 18)
                {
                    ageOffset = 0;
                }
                else if (age <= 25)
                {
                    ageOffset = 1;
                }
                else if (age <= 64)
                {
                    ageOffset = 2;
                }
                else
                {
                    ageOffset = 3;
                }

                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }
                else
                {
                    return(-1);
                }

                return(baseOffset + (ageOffset * 8) + occupationOffset * 2
                       + (person.EmploymentStatus == TTSEmploymentStatus.FullTime ? 0 : 1));

            case Activity.PrimaryWork:
                // We store the values from the person to improve performance
                if (person.EmploymentZone == null)
                {
                    return(-1);
                }
                occupation = person.Occupation;
                if (person.EmploymentStatus != TTSEmploymentStatus.FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.PartTime)
                {
                    return(-1);
                }
                //Calculate the ageOffset
                if (age < 11)
                {
                    return(-1);
                }
                if (age <= 18)
                {
                    ageOffset = 0;
                }
                else if (age <= 25)
                {
                    ageOffset = 1;
                }
                else if (age <= 64)
                {
                    ageOffset = 2;
                }
                else
                {
                    ageOffset = 3;
                }
                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }
                else
                {
                    return(-1);
                }

                return((ageOffset * 8) + occupationOffset * 2
                       + (person.EmploymentStatus == TTSEmploymentStatus.FullTime ? 0 : 1));

            case Activity.SecondaryWork:
                // We store the values from the person to improve performance
                baseOffset = 32;
                occupation = person.Occupation;
                if (person.EmploymentZone == null)
                {
                    return(-1);
                }
                if (person.EmploymentStatus != TTSEmploymentStatus.FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.PartTime)
                {
                    return(-1);
                }
                if (person.Age < 11)
                {
                    return(-1);
                }
                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }
                else
                {
                    return(-1);
                }

                // Ok, here we do the math, there are 8 distros per age group [only 1 age group]
                // Each one is broken into 4 occupation types
                // Each of them are broken into first, full-time then part-time
                return
                    (baseOffset + occupationOffset * 2
                     + (person.EmploymentStatus == TTSEmploymentStatus.FullTime ? 0 : 1));

            case Activity.WorkAtHomeBusiness:
                // We store the values from the person to improve performance
                baseOffset       = 72;
                occupationOffset = 0;
                occupation       = person.Occupation;
                age = person.Age;
                if (person.EmploymentStatus != TTSEmploymentStatus.WorkAtHome_FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.WorkAtHome_PartTime)
                {
                    return(-1);
                }
                //Calculate the ageOffset
                if (age < 19)
                {
                    return(-1);
                }
                if (age <= 25)
                {
                    ageOffset = 0;
                }
                else if (age <= 64)
                {
                    ageOffset = 1;
                }
                else
                {
                    ageOffset = 2;
                }

                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }

                // Ok, here we do the math, there are 8 distros per age group
                // Each one is broken into 4 occupation types
                // Each of them are broken into first, full-time then part-time
                return(baseOffset + (ageOffset * 4) + occupationOffset);

            case Activity.ReturnFromWork:
                // We store the values from the person to improve performance
                baseOffset       = 94;
                occupationOffset = 0;
                occupation       = person.Occupation;
                if (person.EmploymentStatus != TTSEmploymentStatus.FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.PartTime)
                {
                    return(-1);
                }
                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }

                // Ok, here we do the math, there are 8 distros per age group [only 1 age group]
                // Each one is broken into 4 occupation types
                // Each of them are broken into first, full-time then part-time
                return
                    (baseOffset + occupationOffset * 2 + (person.EmploymentStatus == TTSEmploymentStatus.FullTime ? 0 : 1));

            case Activity.IndividualOther:
                baseOffset = 102;
                //||[0,6] ||==7
                PersonWorkSchoolProjectStatus workProjestStatus = SchedulerPerson.GetWorkSchoolProjectStatus(person);
                age = person.Age;

                //Calculate the ageOffset
                if (age < 11)
                {
                    return(-1);
                }
                if (age < 16)
                {
                    ageOffset = 0;
                }
                else if (age < 25)
                {
                    ageOffset = 1;
                }
                else if (age < 65)
                {
                    ageOffset = 2;
                }
                else
                {
                    ageOffset = 3;
                }
                //
                return
                    (baseOffset + (ageOffset * 14) + (person.Female ? 7 : 0) + (int)workProjestStatus);

            case Activity.Market:
                baseOffset = 182;
                //||[0,6] ||==7
                workProjestStatus = SchedulerPerson.GetWorkSchoolProjectStatus(person);
                age = person.Age;

                //Calculate the ageOffset
                if (age < 11)
                {
                    return(-1);
                }
                if (age < 16)
                {
                    ageOffset = 0;
                }
                else if (age < 25)
                {
                    ageOffset = 1;
                }
                else if (age < 65)
                {
                    ageOffset = 2;
                }
                else
                {
                    ageOffset = 3;
                }
                // Ok, here we do the math, there are 8 distros per age group
                // Each one is broken into 4 occupation types
                // Each of them are broken into first, full-time then part-time
                return
                    (baseOffset + (ageOffset * 14) + (person.Female ? 7 : 0) + (int)workProjestStatus);

            default:
                return(-1);
            }
        }
예제 #57
0
        /// <summary>
        /// Funky function directly from Tasha original
        /// </summary>
        /// <param name="person"></param>
        /// <returns></returns>
        internal static PersonWorkSchoolProjectStatus GetWorkSchoolProjectStatus(ITashaPerson person)
        {
            //TashaTime workSchoolStartTime = (person["SData"] as SchedulerPersonData).;
            Time workSchoolStartTime = SchedulerPerson.GetWorkSchoolStartTime( person );
            Time workSchoolEndTime = SchedulerPerson.GetWorkSchoolEndTime( person );

            PersonWorkSchoolProjectStatus workSchoolProjectStatus = PersonWorkSchoolProjectStatus.NoWorkOrSchool;

            if ( workSchoolStartTime <= Time.StartOfDay )
            {
                workSchoolProjectStatus = PersonWorkSchoolProjectStatus.NoWorkOrSchool;
            }
            else if ( ( workSchoolEndTime - workSchoolStartTime ) >= Scheduler.FullTimeActivity )
            {
                if ( workSchoolEndTime <= new Time() { Hours = 14 } ) workSchoolProjectStatus = PersonWorkSchoolProjectStatus.FullTimeNoEveningWorkOrSchool;
                else if ( workSchoolStartTime >= new Time() { Hours = 9 } ) workSchoolProjectStatus = PersonWorkSchoolProjectStatus.FullTimeEveningWorkOrSchool;
                else workSchoolProjectStatus = PersonWorkSchoolProjectStatus.FullTimeDayAndEveningWorkOrSchool;
            }
            else if ( workSchoolEndTime - workSchoolStartTime < Scheduler.FullTimeActivity )
            {
                if ( workSchoolEndTime <= new Time() { Hours = 9 } ) workSchoolProjectStatus = PersonWorkSchoolProjectStatus.PartTimeDay;
                else if ( workSchoolEndTime <= new Time() { Hours = 14 } ) workSchoolProjectStatus = PersonWorkSchoolProjectStatus.PartTimeEvening;
                else workSchoolProjectStatus = PersonWorkSchoolProjectStatus.Other;
            }

            return workSchoolProjectStatus;
        }
예제 #58
0
 internal static PersonalProject GetMarketProject(this ITashaPerson person)
 {
     return((person["SData"] as SchedulerPersonData).MarketSchedule);
 }
예제 #59
0
 private static void BuildPersonChain(ITashaPerson person, IZone home, int householdIterations, Time minimumAtHomeTime)
 {
     if ( person.TripChains == null )
     {
         throw new XTMFRuntimeException( "A Person's trip chains must be initialized during construction." );
     }
     var pdata = person["SData"] as SchedulerPersonData;
     pdata.Schedule.GenerateTrips( person.Household, householdIterations, minimumAtHomeTime );
 }
예제 #60
0
 internal static PersonalProject GetWorkProject(this ITashaPerson person)
 {
     return((person["SData"] as SchedulerPersonData).WorkSchedule);
 }