Beispiel #1
0
 public TkSolution(
     TkTimeSet mutualVacancy,
     TkResourceRequestSolutionGroup group,
     TkResourceResponse[] responses)
 {
     MutualVacancy  = mutualVacancy;
     MutualSchedule = TkScheduler.TryScheduling(group.Tasks, mutualVacancy);
     Group          = group;
     Responses      = responses;
 }
Beispiel #2
0
        public IEnumerable <TkResourceResponse> Run()
        {
            var responses = new List <TkResourceResponse>();

            foreach (var actor in Request.Actors)
            {
                var busyProcesses = Request.Busy.Where(o => o.ParticipantId == actor.Key);

                var busy = GetBusy(
                    busyProcesses,
                    Request.ScheduleStartsAt,
                    Request.ScheduleEndsAt);

                var vacancy = GetVacancy(
                    Request.ScheduleStartsAt,
                    Request.ScheduleEndsAt,
                    busy,
                    Request.WorkWeekConfig);

                var totalTicksVacant = vacancy.Ticks();

                if (Request.TotalTicksRequired >= totalTicksVacant)
                {
                    continue;
                }

                var schedule = TkScheduler.TryScheduling(Request.Tasks, vacancy);
                if (schedule.IsNull)
                {
                    continue;
                }

                var response = new TkResourceResponse(actor, busy, vacancy, schedule);
                responses.Add(response);
            }

            return(responses);
        }