Example #1
0
        private static double GetTime(EstimatedWorkflow workflow, ActiveEstimatedTask t)
        {
            var parent           = workflow.Tasks.Single(wt => wt.Id == t.Id);
            var depsWaitingTime  = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time);
            var nodesWaitingTime = t.Estimation.NodesTimings.Max(n => n.GetAvailabilityTime());
            var waitingTime      = Math.Max(depsWaitingTime, nodesWaitingTime);

            return(waitingTime + t.Estimation.Result.Time);
        }
Example #2
0
 public ActiveEstimatedTask ChooseTask(EstimatedWorkflow workflow, List <IEnumerable <ActiveEstimatedTask> > tasks)
 {
     return(tasks.OrderByDescending(t =>
     {
         var parent = workflow.Tasks.Single(wt => wt.Id == t.First().Id);
         var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time);
         var nodesWaitingTime = t.First().Estimation.NodesTimings.Max(n => n.GetAvailabilityTime());
         var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime);
         return waitingTime + t.First().Estimation.Result.Time;
     }).First().First());
 }
Example #3
0
        public EstimatedWorkflow(EstimatedWorkflow other)
            : this()
        {
            if (other == null)
            {
                return;
            }

            this.Name     = other.Name;
            this.Optimize = Optimize;
        }
Example #4
0
        public ActiveEstimatedTask ChooseTask(EstimatedWorkflow workflow, List <IEnumerable <ActiveEstimatedTask> > tasks)
        {
            /*var seq = tasks[0];
             * int idx;
             * idx = (int)taskPosition % seq.Count();
             * taskPosition++;
             * return seq.ElementAt(idx);
             * return tasks[0].First();*/
            var a = tasks[r.Next(tasks.Count)].ToArray();

            return(a[r.Next(a.Length)]);
        }
        private IEnumerable<Tuple<string, IEnumerable<ActiveEstimatedTask>, IEnumerable<EstimatedTask>, IEnumerable<TasksDepenendency>>> ConstructWorkflows(EstimatedWorkflow wf)
        {
            var activeTasks = wf.ActiveTasks.GroupBy(t => t.WFid).ToDictionary(group => group.Key, group => group.ToList());
            var tasks = wf.Tasks.GroupBy(t => t.WFid).ToDictionary(group => group.Key, group => group.ToList());

            var allIds = new Dictionary<string, HashSet<ulong>>();

            var activeTasksIds = activeTasks.ToDictionary(pair => pair.Key,
                pair => new HashSet<ulong>(pair.Value.Select(t => t.Id)));
            foreach (var pair in activeTasksIds)
            {
                if (!allIds.ContainsKey(pair.Key))
                {
                    allIds.Add(pair.Key, new HashSet<ulong>());
                }
                foreach (var v in pair.Value)
                {
                    allIds[pair.Key].Add(v);
                }

            }

            var tasksIds = tasks.ToDictionary(pair => pair.Key,
                pair => new HashSet<ulong>(pair.Value.Select(t => t.Id)));
            foreach (var pair in tasksIds)
            {
                if (!allIds.ContainsKey(pair.Key))
                {
                    allIds.Add(pair.Key, new HashSet<ulong>());
                }
                foreach (var v in pair.Value)
                {
                    allIds[pair.Key].Add(v);
                }
            }

            var result = allIds.Select(
                pair =>
                    new Tuple
                        <string, IEnumerable<ActiveEstimatedTask>, IEnumerable<EstimatedTask>,
                            IEnumerable<TasksDepenendency>>(
                        pair.Key,
                        activeTasks.ContainsKey(pair.Key)?activeTasks[pair.Key]:new List<ActiveEstimatedTask>(),
                        tasks.ContainsKey(pair.Key)?tasks[pair.Key]:new List<EstimatedTask>(),
                        wf.Dependencies.Where(d => pair.Value.Contains(d.ConsumerId))
                        ));
            return result;
        }
Example #6
0
 private static double GetTime(EstimatedWorkflow workflow, ActiveEstimatedTask t)
 {
     var parent = workflow.Tasks.Single(wt => wt.Id == t.Id);
     var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time);
     var nodesWaitingTime = t.Estimation.NodesTimings.Max(n => n.GetAvailabilityTime());
     var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime);
     return waitingTime + t.Estimation.Result.Time;
 }
Example #7
0
 public ActiveEstimatedTask ChooseTask(EstimatedWorkflow workflow, List<IEnumerable<ActiveEstimatedTask>> tasks)
 {
     return tasks.OrderByDescending(t =>
         GetTime(workflow, t.ElementAt(1)) - GetTime(workflow, t.ElementAt(0))).First().First();
 }
Example #8
0
 public ActiveEstimatedTask ChooseTask(EstimatedWorkflow workflow, List<IEnumerable<ActiveEstimatedTask>> tasks)
 {
     /*var seq = tasks[0];
     int idx;
     idx = (int)taskPosition % seq.Count();
     taskPosition++;
     return seq.ElementAt(idx);
     return tasks[0].First();*/
     var a = tasks[r.Next(tasks.Count)].ToArray();
     return a[r.Next(a.Length)];
 }
Example #9
0
        public EstimatedWorkflow(EstimatedWorkflow other)
            : this()
        {
            if (other == null)
            {
                return;
            }

            this.Name = other.Name;
            this.Optimize = Optimize;
        }
Example #10
0
 public EstimatedUrgentWorkflow(EstimatedWorkflow other)
     : base(other)
 {
 }
Example #11
0
 public ActiveEstimatedTask ChooseTask(EstimatedWorkflow workflow, List<IEnumerable<ActiveEstimatedTask>> tasks)
 {
     return tasks.OrderBy(t =>
     {
         var parent = workflow.Tasks.Single(wt => wt.Id == t.First().Id);
         var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time);
         var nodesWaitingTime = t.First().Estimation.NodesTimings.Max(n => n.GetAvailabilityTime());
         var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime);
         return waitingTime + t.First().Estimation.Result.Time;
     }).First().First();
 }
Example #12
0
 public ActiveEstimatedTask ChooseTask(EstimatedWorkflow workflow, List <IEnumerable <ActiveEstimatedTask> > tasks)
 {
     return(tasks.OrderByDescending(t =>
                                    GetTime(workflow, t.ElementAt(1)) - GetTime(workflow, t.ElementAt(0))).First().First());
 }
Example #13
0
 public EstimatedUrgentWorkflow(EstimatedWorkflow other)
     : base(other)
 {
 }