public List <Shift> Generate(IEngineerPool engineerPool, int shiftsPerPeriod)
        {
            // Populate the shift schedule without engineers
            var shifts = new List <Shift>(shiftsPerPeriod);

            for (int i = 0; i < shiftsPerPeriod; i++)
            {
                shifts.Add(new Shift(i));
            }

            // Find an engineer and then walk through the shifts to
            // find the next valid one
            Engineer candidate;

            while ((candidate = engineerPool.PullRandom()) != null)
            {
                for (int i = 0; i < shiftsPerPeriod; i++)
                {
                    if (shifts[i].Engineer == null)
                    {
                        var foundSuitableSlot = _ruleEvaluator.IsValid(i, candidate.Id, shifts);
                        if (foundSuitableSlot)
                        {
                            shifts[i].Engineer = candidate;
                            engineerPool.Remove(candidate);
                            break;
                        }
                    }
                }
            }

            return(shifts);
        }
        public List <Shift> Generate(IEngineerPool engineerPool, int shiftsPerPeriod)
        {
            EngineerModel candidate;
            var           shifts = new List <Shift>();

            // Walk throught the shift slots and find a valid engineer for this slot
            for (int i = 0; i < shiftsPerPeriod; i++)
            {
                bool foundSuitableCandiate = false;

                while (!foundSuitableCandiate && ((candidate = engineerPool.PullRandom()) != null))
                {
                    foundSuitableCandiate = _ruleEvaluator.IsValid(i, candidate.Id, shifts);
                    if (foundSuitableCandiate)
                    {
                        shifts.Add(new Shift(i)
                        {
                            Engineer = candidate
                        });
                        engineerPool.Remove(candidate);
                        engineerPool.ResetPullables();
                    }
                }
            }
            return(shifts);
        }