Example #1
0
 internal TravelEpisode(TimeWindow timeWindow, Episode from, Episode to)
     : base(timeWindow)
 {
     ActivityType = to.ActivityType;
     //-----
     From = from;
     To   = to;
 }
Example #2
0
 internal ActivityEpisode(TimeWindow window, Activity type, ITashaPerson owner)
     : base(window)
 {
     People           = null;
     ActivityType     = type;
     OriginalDuration = window.Duration;
     Owner            = owner;
 }
Example #3
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;
 }
Example #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;
 }
Example #5
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;
 }
Example #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;
 }
Example #7
0
 private static bool AddHouseholdPass(Episode ep, ref TimeWindow feasible)
 {
     // Check to find the time that everyone is available at
     foreach (var person in ep.People)
     {
         // if we are make sure we can go to the event
         var pdata = (person["SData"] as SchedulerPersonData);
         if (!pdata.Schedule.CheckEpisodeInsert(ep, ref feasible))
         {
             // if we can not fit it in reject it
             return(false);
         }
     }
     return(true);
 }
Example #8
0
 /// <summary>
 /// Creates a new Episode
 /// </summary>
 /// <param name="window">The window in time this episode occurs in</param>
 internal Episode(TimeWindow window)
 {
     Window = window;
     // originally we have no travel time
     TravelTime = Time.Zero;
 }
Example #9
0
 public override bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow)
 {
     throw new NotImplementedException();
 }
Example #10
0
 /// <summary>
 /// Checks to see if an episode can be inserted, and does if it can
 /// </summary>
 public abstract bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow);
Example #11
0
 public override bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow)
 {
     throw new NotImplementedException();
 }
Example #12
0
 /// <summary>
 /// Checks to see if an episode can be inserted, and does if it can
 /// </summary>
 public abstract bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow);
Example #13
0
 /// <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;
 }
Example #14
0
        private static bool GenerateIndividualMarketEpisodes(this ITashaHousehold household, Random random, GenerationAdjustment[] generationAdjustments)
        {
            int householdPD = household.HomeZone.PlanningDistrict;
            foreach (var person in household.Persons)
            {
                if (!person.Child)
                {
                    var empZone = person.EmploymentZone;
                    int workPD = empZone == null ? 0 : empZone.PlanningDistrict;
                    int freq_I = TimeTable.GetFrequency(person, Activity.Market, random, householdPD, workPD, generationAdjustments);
                    int outerAttempts = 0;
                    for (int j = 0; j < freq_I; ++j)
                    {
                        //Update the trip generation count

                        Time startTime;
                        Time duration;
                        bool success = false;
                        for (int attempt = 0; attempt < Scheduler.EpisodeSchedulingAttempts && !success; attempt++)
                        {
                            if (!TimeTable.GetStartTime(person, Activity.Market, random, out startTime))
                            {
                                continue;
                            }

                            if (!TimeTable.GetDuration(person, Activity.Market, startTime, random, out duration))
                            {
                                continue;
                            }

                            var endTime = startTime + duration;
                            if (endTime > Time.EndOfDay + TashaRuntime.EndOfDay + Time.OneQuantum)
                            {
                                success = false;
                                continue;
                            }

                            //instantiate a temporary individual market episode on the heap space and store pointer in p_marketEpisode

                            var window = new TimeWindow(startTime, startTime + duration);
                            Episode marketEpisode = new ActivityEpisode(0, window, Activity.Market, person);
                            Project workProject = person.GetWorkProject();
                            Schedule workProjSchedule = workProject.Schedule;
                            Project schoolProject = person.GetSchoolProject();
                            Schedule schoolProjSchedule = schoolProject.Schedule;

                            Time overlap = workProjSchedule.CheckOverlap(marketEpisode) + schoolProjSchedule.CheckOverlap(marketEpisode);

                            float percentOverlap = overlap / duration;

                            if (percentOverlap < Scheduler.PercentOverlapAllowed || attempt == Scheduler.EpisodeSchedulingAttempts - 1)
                            {
                                Project marketProject = person.GetMarketProject();
                                Schedule marketSchedule = marketProject.Schedule;

                                if (marketSchedule.Insert(marketEpisode, random))
                                {
                                    //inserted ok
                                    success = true;
                                }
                                else
                                {
                                    success = false;
                                    //didn't work
                                }
                            }
                            else // i.e. too much overlap with the work and school projects
                            {
                                // attempt will be auto incremented so we don't need to worry about this
                            }
                        }
                        if ((outerAttempts++) < Scheduler.EpisodeSchedulingAttempts && !success)
                        {
                            j = -1;
                            Project marketProject = person.GetMarketProject();
                            Schedule marketSchedule = marketProject.Schedule;
                            marketSchedule.Clear();
                        }
                    }
                }
            }
            return true;
        }
Example #15
0
        private static bool GenerateIndividualMarketEpisodes(this ITashaHousehold household, Random random, GenerationAdjustment[] generationAdjustments)
        {
            int householdPD = household.HomeZone.PlanningDistrict;

            foreach (var person in household.Persons)
            {
                if (!person.Child)
                {
                    var empZone       = person.EmploymentZone;
                    int workPD        = empZone == null ? 0 : empZone.PlanningDistrict;
                    int freqI         = TimeTable.GetFrequency(person, Activity.Market, random, householdPD, workPD, generationAdjustments);
                    int outerAttempts = 0;
                    for (int j = 0; j < freqI; ++j)
                    {
                        bool success = false;
                        for (int attempt = 0; attempt < Scheduler.EpisodeSchedulingAttempts && !success; attempt++)
                        {
                            if (!TimeTable.GetStartTime(person, Activity.Market, random, out Time startTime))
                            {
                                continue;
                            }

                            if (!TimeTable.GetDuration(person, Activity.Market, startTime, random, out Time duration))
                            {
                                continue;
                            }

                            var endTime = startTime + duration;
                            if (endTime > Time.EndOfDay + TashaRuntime.EndOfDay + Time.OneQuantum)
                            {
                                continue;
                            }

                            //instantiate a temporary individual market episode on the heap space and store pointer in p_marketEpisode

                            var      window             = new TimeWindow(startTime, startTime + duration);
                            Episode  marketEpisode      = new ActivityEpisode(window, Activity.Market, person);
                            Project  workProject        = person.GetWorkProject();
                            Schedule workProjSchedule   = workProject.Schedule;
                            Project  schoolProject      = person.GetSchoolProject();
                            Schedule schoolProjSchedule = schoolProject.Schedule;

                            Time overlap = workProjSchedule.CheckOverlap(marketEpisode) + schoolProjSchedule.CheckOverlap(marketEpisode);

                            float percentOverlap = overlap / duration;

                            if (percentOverlap < Scheduler.PercentOverlapAllowed || attempt == Scheduler.EpisodeSchedulingAttempts - 1)
                            {
                                Project  marketProject  = person.GetMarketProject();
                                Schedule marketSchedule = marketProject.Schedule;

                                if (marketSchedule.Insert(marketEpisode, random))
                                {
                                    //inserted ok
                                    success = true;
                                }
                            }
                        }
                        if ((outerAttempts++) < Scheduler.EpisodeSchedulingAttempts && !success)
                        {
                            j = -1;
                            Project  marketProject  = person.GetMarketProject();
                            Schedule marketSchedule = marketProject.Schedule;
                            marketSchedule.Clear();
                        }
                    }
                }
            }
            return(true);
        }
Example #16
0
 private static bool AddHouseholdPass(Episode ep, ref TimeWindow feasible)
 {
     // Check to find the time that everyone is available at
     foreach ( var person in ep.People )
     {
         // if we are make sure we can go to the event
         var pdata = ( person["SData"] as SchedulerPersonData );
         if ( !pdata.Schedule.CheckEpisodeInsert( ep, ref feasible ) )
         {
             // if we can not fit it in reject it
             return false;
         }
     }
     return true;
 }
Example #17
0
 /// <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;
 }