コード例 #1
0
            public DayPattern(IPersonDayWrapper personDay)
            {
                Tours = new int[Global.Settings.Purposes.TotalPurposes];

                WorkTours             = Tours[Global.Settings.Purposes.Work] = personDay.WorkTours;
                SchoolTours           = Tours[Global.Settings.Purposes.School] = personDay.SchoolTours;
                EscortTours           = Tours[Global.Settings.Purposes.Escort] = personDay.EscortTours;
                PersonalBusinessTours = Tours[Global.Settings.Purposes.PersonalBusiness] = personDay.PersonalBusinessTours;
                ShoppingTours         = Tours[Global.Settings.Purposes.Shopping] = personDay.ShoppingTours;
                MealTours             = Tours[Global.Settings.Purposes.Meal] = personDay.MealTours;
                SocialTours           = Tours[Global.Settings.Purposes.Social] = personDay.SocialTours;

                TotalTours = personDay.GetTotalTours();

                Stops = new int[Global.Settings.Purposes.TotalPurposes];

                WorkStops             = Stops[Global.Settings.Purposes.Work] = personDay.WorkStops;
                SchoolStops           = Stops[Global.Settings.Purposes.School] = personDay.SchoolStops;
                EscortStops           = Stops[Global.Settings.Purposes.Escort] = personDay.EscortStops;
                PersonalBusinessStops = Stops[Global.Settings.Purposes.PersonalBusiness] = personDay.PersonalBusinessStops;
                ShoppingStops         = Stops[Global.Settings.Purposes.Shopping] = personDay.ShoppingStops;
                MealStops             = Stops[Global.Settings.Purposes.Meal] = personDay.MealStops;
                SocialStops           = Stops[Global.Settings.Purposes.Social] = personDay.SocialStops;

                TotalStops = personDay.GetTotalStops();

                _hashCode = ComputeHashCode();
            }
コード例 #2
0
        public static void SetEscortPercentages(IPersonDayWrapper personDay, out double escortPercentage, out double nonEscortPercentage, bool excludeWorkAndSchool = false)
        {
            if (personDay == null || personDay.HomeBasedTours == 0)
            {
                escortPercentage    = 0;
                nonEscortPercentage = 0;
            }
            else
            {
                var totalTours     = excludeWorkAndSchool ? personDay.GetTotalToursExcludingWorkAndSchool() : personDay.GetTotalTours();
                var totalStops     = excludeWorkAndSchool ? personDay.GetTotalStopsExcludingWorkAndSchool() : personDay.GetTotalStops();
                var escortStopFlag = (personDay.EscortStops > 0).ToFlag();

                escortPercentage    = escortStopFlag / Math.Max(totalTours, 1.0);
                nonEscortPercentage = (totalStops - escortStopFlag) / Math.Max(totalTours, 1.0);
            }
        }