public bool MinConsecutiveShiftsNotExceeded(Employee employee, EmployeeEvaluationAggregate aggregate)
        {
            var feasible = true;

            foreach (var consecutiveShiftCount in aggregate.ConsecutiveShiftLengths)
            {
                if (ConsecutiveShiftIsNotContinuationOfPreviousOrNextSchedulePeriod(consecutiveShiftCount))
                {
                    if (consecutiveShiftCount.Length < employee.Contract.MinConsecutiveShifts)
                    {
                        feasible = false;
                        _messages.Add($"{employee.Id} works {consecutiveShiftCount.Length} number of days in a row instead of the minimum required {employee.Contract.MinConsecutiveShifts}");
                    }
                }
            }

            return(feasible);

            bool ConsecutiveShiftIsNotContinuationOfPreviousOrNextSchedulePeriod(ConsecutiveShiftLength consecutiveShiftLength)
            {
                if (consecutiveShiftLength.DayStart == 0)
                {
                    return(false);
                }
                if (consecutiveShiftLength.DayStart + consecutiveShiftLength.Length == _schedulingBenchmarkModel.Duration)
                {
                    return(false);
                }

                return(true);
            }
        }
Exemple #2
0
        private List <EmployeeEvaluationAggregate> Feasible()
        {
            var aggregates = new ConcurrentBag <EmployeeEvaluationAggregate>();

            Parallel.ForEach(_schedulingBenchmarkModel.Employees, employee =>
            {
                var shiftCounts             = GetShiftCounts(employee);
                var totalWorkedMinutes      = GetTotalWorkedMinutes(employee);
                var consecutiveShiftLengths = GetConsecutiveShiftLengths(employee);
                var dayOffLengths           = GetDayOffLengths(employee);
                var workedWeekendsCount     = GetWorkedWeekendsCount(employee);
                var dayOffsWithAssignments  = GetDayOffsWithAssignments(employee);
                var restTimes = GetRestTimes(employee);

                var aggregate = new EmployeeEvaluationAggregate(
                    employee.Id,
                    shiftCounts,
                    totalWorkedMinutes,
                    consecutiveShiftLengths,
                    dayOffLengths,
                    workedWeekendsCount,
                    dayOffsWithAssignments,
                    restTimes);

                aggregates.Add(aggregate);
            });

            return(aggregates.ToList());
        }
        public bool MaxTotalMinutesNotExceeded(Employee employee, EmployeeEvaluationAggregate aggregate)
        {
            var feasible = true;

            if (aggregate.TotalWorkedMinutes > employee.Contract.MaxTotalWorkTime)
            {
                feasible = false;
                _messages.Add($"{employee.Id} works {aggregate.TotalWorkedMinutes} minutes instead of the maximum allowed {employee.Contract.MaxTotalWorkTime}");
            }

            return(feasible);
        }
        public bool DayOffsRespected(Employee employee, EmployeeEvaluationAggregate aggregate)
        {
            var feasible = true;

            foreach (var dayOff in aggregate.DayOffsWithAssignments)
            {
                feasible = false;
                _messages.Add($"{employee.Id} has assignment on day {dayOff} instead of having a day off");
            }

            return(feasible);
        }
        public bool MaxNumberOfWeekendsNotExceeded(Employee employee, EmployeeEvaluationAggregate aggregate)
        {
            var feasible = true;

            if (aggregate.WorkedWeekendsCount > employee.Contract.MaxWorkingWeekendCount)
            {
                feasible = false;
                _messages.Add($"{employee.Id} works on {aggregate.WorkedWeekendsCount} weekends instead of the maximum allowed {employee.Contract.MaxWorkingWeekendCount}");
            }

            return(feasible);
        }
        public bool MaxNumberOfShiftsNotExceeded(Employee employee, EmployeeEvaluationAggregate aggregate)
        {
            var feasible = true;

            foreach (var maxShift in employee.Contract.MaxShifts)
            {
                if (aggregate.ShiftCounts.TryGetValue(maxShift.Key, out var shiftCount) && shiftCount > maxShift.Value)
                {
                    feasible = false;
                    _messages.Add($"{employee.Id} has {shiftCount} assigned shifts of type {maxShift.Key} instead of the maximum allowed {maxShift.Value}");
                }
            }

            return(feasible);
        }
        public bool MinRestTimeRespected(Employee employee, EmployeeEvaluationAggregate aggregate)
        {
            var feasible = true;

            foreach (var restTime in aggregate.RestTimes)
            {
                if (restTime < employee.Contract.MinRestTime)
                {
                    feasible = false;
                    _messages.Add($"{employee.Id} rests only {restTime} minutes");
                }
            }

            return(feasible);
        }
        public bool MinConsecutiveDaysOffNotExceeded(Employee employee, EmployeeEvaluationAggregate aggregate)
        {
            var feasible = true;

            foreach (var consecutiveDayOffCount in aggregate.DayOffLengths)
            {
                if (consecutiveDayOffCount < employee.Contract.MinConsecutiveDayOffs)
                {
                    feasible = false;
                    _messages.Add($"{employee.Id} has {consecutiveDayOffCount} consecutive days off instead of the minimum required {employee.Contract.MinConsecutiveDayOffs}");
                }
            }

            return(feasible);
        }
        public bool MaxConsecutiveShiftsNotExceeded(Employee employee, EmployeeEvaluationAggregate aggregate)
        {
            var feasible = true;

            foreach (var consecutiveShiftCount in aggregate.ConsecutiveShiftLengths)
            {
                if (consecutiveShiftCount.Length > employee.Contract.MaxConsecutiveShifts)
                {
                    feasible = false;
                    _messages.Add($"{employee.Id} works {consecutiveShiftCount.Length} number of days in a row instead of the maximum allowed {employee.Contract.MaxConsecutiveShifts}");
                }
            }

            return(feasible);
        }