コード例 #1
0
ファイル: TravelEpisode.cs プロジェクト: lunaxi7/XTMF
 internal TravelEpisode(TimeWindow timeWindow, Episode from, Episode to)
     : base(timeWindow)
 {
     ActivityType = to.ActivityType;
     //-----
     From = from;
     To   = to;
 }
コード例 #2
0
ファイル: ActivityEpisode.cs プロジェクト: lunaxi7/XTMF
 internal ActivityEpisode(TimeWindow window, Activity type, ITashaPerson owner)
     : base(window)
 {
     People           = null;
     ActivityType     = type;
     OriginalDuration = window.Duration;
     Owner            = owner;
 }
コード例 #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;
 }
コード例 #4
0
ファイル: ActivityEpisode.cs プロジェクト: Cocotus/XTMF
 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
 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;
 }
コード例 #6
0
ファイル: TravelEpisode.cs プロジェクト: Cocotus/XTMF
 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
ファイル: SchedulerPerson.cs プロジェクト: taha-islam/XTMF
 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);
 }
コード例 #8
0
ファイル: Episode.cs プロジェクト: lunaxi7/XTMF
 /// <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;
 }
コード例 #9
0
ファイル: PersonSchedule.cs プロジェクト: dianatle/XTMF
 public override bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
ファイル: Schedule.cs プロジェクト: lunaxi7/XTMF
 /// <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);
コード例 #11
0
 public override bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
ファイル: Schedule.cs プロジェクト: Cocotus/XTMF
 /// <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);
コード例 #13
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;
 }
コード例 #14
0
ファイル: SchedulerHousehold.cs プロジェクト: dianatle/XTMF
        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;
        }
コード例 #15
0
ファイル: SchedulerHousehold.cs プロジェクト: lunaxi7/XTMF
        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);
        }
コード例 #16
0
ファイル: SchedulerPerson.cs プロジェクト: dianatle/XTMF
 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;
 }
コード例 #17
0
ファイル: Episode.cs プロジェクト: Cocotus/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;
 }