public TunablePlan(EstimatedUrgentWorkflow workflow) : base(workflow) { roots = workflow.Tasks.OrderBy(t => t.DepthLevel).Select(t => t.Id).ToArray(); leaves = roots.Reverse().ToArray(); baseValues = Estimations.ToDictionary(e => e.First().Id, e => e.Count()); optionsIdxs = baseValues.ToDictionary(p => p.Key, p => 0); maxIndex = baseValues.Values.Max(); }
internal virtual IEnumerable <ActiveEstimatedTask> ChooseSequence(EstimatedUrgentWorkflow workflow, UrgentPlan plan) { var rootIds = workflow.Tasks.Where(t => !t.IsScheduled && t.IsReady).Select(r => r.Id); var effectiveEstimations = plan.Estimations.Where(e => rootIds.Contains(e.First().Id)).ToList(); var seq = effectiveEstimations.OrderBy(t => SecondaryComparisonLambda()(workflow, t)).First(); plan.Estimations.Remove(seq); return(seq); }
public EstimatedUrgentWorkflow(EstimatedUrgentWorkflow other) : this((EstimatedWorkflow)other) { if (other == null) { return; } MinExecutionTime = other.MinExecutionTime; MaxExecutionTime = other.MaxExecutionTime; }
protected double FullTaskTime(ActiveEstimatedTask task, EstimatedUrgentWorkflow workflow) { var parent = workflow.Tasks.Single(wt => wt.Id == task.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max( d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); var nodesWaitingTime = GetNodesAvailabilityTimeForUrgentTask(task, workflow); //t.First().Estimation.NodesTimings.Max(n => n.AvailabilityTime); var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime); return(waitingTime + task.Estimation.Result.Time); }
internal virtual ActiveEstimatedTask ChooseTask(EstimatedUrgentWorkflow workflow, UrgentPlan plan) { var seq = ChooseSequence(workflow, plan); var prevInstance = ExtractTask(seq, plan); var parent = workflow.Tasks.Single(t => t.Id == prevInstance.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); prevInstance.Estimation.LaunchTime = Math.Max(depsWaitingTime, GetNodesAvailabilityTimeForUrgentTask(prevInstance, workflow)); prevInstance.State = prevInstance.Estimation.LaunchTime > TaskScheduler.E || prevInstance.Estimation.NodesTimings.Any(w => w.GetAvailabilityTime(plan.IgnoreNonUrgentTasks) > TaskScheduler.E) ? TaskScheduler.TaskState.SCHEDULED : TaskScheduler.TaskState.LAUNCHED; var clonedInstance = new ActiveEstimatedTask(prevInstance) { IsUrgent = true }; foreach (var node in prevInstance.Estimation.NodesTimings) { node.AssignTask(clonedInstance); } plan.Plan.Add(clonedInstance); parent.ScheduledInstance = clonedInstance; return(clonedInstance); }
internal virtual UrgentPlan GeneratePlan(EstimatedUrgentWorkflow workflow, UrgentPlan plan) { var result = plan ?? CreateEmptyPlan(workflow); while (workflow.Tasks.Any(t => !t.IsScheduled && t.IsReady)) { Reorder(result); ChooseTask(workflow, result); } result.NodesTimings = result.Wrappers.ToList(); result.EstimatedExecutionTime = result.Plan.Any() ? result.Plan.Max(t => t.Estimation.LaunchTime + t.Estimation.Result.Time) : 0; Debug.Assert(workflow.Tasks.All(t => t.IsScheduled)); foreach (var t in workflow.ActiveTasks.Where(t => !t.IsUrgent && t.State == TaskScheduler.TaskState.LAUNCHED)) { if (result.Plan.Any(p => p.IsUrgent && p.State == TaskScheduler.TaskState.LAUNCHED && p.Estimation.Destination.IsLike(t.Estimation.Destination))) { result.Plan.Add(new ActiveEstimatedTask(t) { State = TaskScheduler.TaskState.ABORTED }); } } return(result); }
public override UrgentPlan MakePlan(EstimatedUrgentWorkflow workflow) { var plan = MakeInitialPlan(workflow) as TunablePlan; UrgentPlan subopt = null; do { //the following is just to avoid single meaningless execution of that block if (!plan.AtFirst(DoRoots)) { plan.Reset(); GeneratePlan(workflow, plan); } var shouldUpdate = false; var shouldMove = false; var trigger = false; if (subopt == null) { shouldUpdate = true; shouldMove = true; trigger = true; } if (!trigger && workflow.MinExecutionTime < TaskScheduler.E) //ASAP { return(new GreedyHeuristics().MakePlan(workflow)); } if (!trigger && workflow.MaxExecutionTime >= TaskScheduler.E && workflow.MaxExecutionTime - plan.EstimatedExecutionTime < TaskScheduler.E) //current time is above the higher bound { trigger = true; shouldUpdate = true; shouldMove = true; } if (!trigger && workflow.MinExecutionTime >= TaskScheduler.E) //should we count MinExTime at all? { if (plan.EstimatedExecutionTime - workflow.MinExecutionTime >= TaskScheduler.E) //is current plan above the lower bound? { if (!plan.HasAbortedTasks || subopt.HasAbortedTasks) //if current plan is the same or better in terms of terminating tasks { shouldUpdate = true; } shouldMove = true; } } if (shouldUpdate) { subopt = plan.Clone() as UrgentPlan; } if (!shouldMove) { break; } }while (plan.TrueForward(DoRoots)); return(subopt); }
public TunablePlan(EstimatedUrgentWorkflow workflow) : base(workflow) { roots = workflow.Tasks.OrderBy(t => t.DepthLevel).Select(t => t.Id).ToArray(); leaves = roots.Reverse().ToArray(); baseValues = Estimations.ToDictionary(e => e.First().Id, e => e.Count()); optionsIdxs = baseValues.ToDictionary(p => p.Key, p => 0); maxIndex = baseValues.Values.Max(); }
internal virtual UrgentPlan GeneratePlan(EstimatedUrgentWorkflow workflow, UrgentPlan plan) { var result = plan ?? CreateEmptyPlan(workflow); while (workflow.Tasks.Any(t => !t.IsScheduled && t.IsReady)) { Reorder(result); ChooseTask(workflow, result); } result.NodesTimings = result.Wrappers.ToList(); result.EstimatedExecutionTime = result.Plan.Any() ? result.Plan.Max(t => t.Estimation.LaunchTime + t.Estimation.Result.Time) : 0; Debug.Assert(workflow.Tasks.All(t => t.IsScheduled)); foreach (var t in workflow.ActiveTasks.Where(t => !t.IsUrgent && t.State == TaskScheduler.TaskState.LAUNCHED)) { if (result.Plan.Any(p => p.IsUrgent && p.State == TaskScheduler.TaskState.LAUNCHED && p.Estimation.Destination.IsLike(t.Estimation.Destination))) { result.Plan.Add(new ActiveEstimatedTask(t) { State = TaskScheduler.TaskState.ABORTED }); } } return result; }
protected virtual double GetNodesAvailabilityTimeForUrgentTask(ActiveEstimatedTask task, EstimatedUrgentWorkflow workflow) { return task.Estimation.NodesTimings.Max(n => { var lTask = n.LaunchedTask; var result = lTask != null && (lTask.IsUrgent || !task.IgnoreNonUrgent) ? lTask.Estimation.Result.Time : 0; var td = new LaunchDestination() { ResourceName = n.ResourceName, NodeNames = new[] { n.NodeName } }; result += workflow.ActiveTasks.Where(t => t.IsUrgent && t.State == TaskScheduler.TaskState.SCHEDULED && t.IsOlderThan(task) && t.Estimation.Destination.IsLike(td)).Sum(t => t.Estimation.Result.Time); return result; } ); }
public virtual UrgentPlan MakePlan(EstimatedUrgentWorkflow workflow) { return MakeInitialPlan(workflow); }
internal virtual ActiveEstimatedTask ChooseTask(EstimatedUrgentWorkflow workflow, UrgentPlan plan) { var seq = ChooseSequence(workflow, plan); var prevInstance = ExtractTask(seq, plan); var parent = workflow.Tasks.Single(t => t.Id == prevInstance.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); prevInstance.Estimation.LaunchTime = Math.Max(depsWaitingTime, GetNodesAvailabilityTimeForUrgentTask(prevInstance, workflow)); prevInstance.State = prevInstance.Estimation.LaunchTime > TaskScheduler.E || prevInstance.Estimation.NodesTimings.Any(w => w.GetAvailabilityTime(plan.IgnoreNonUrgentTasks) > TaskScheduler.E) ? TaskScheduler.TaskState.SCHEDULED : TaskScheduler.TaskState.LAUNCHED; var clonedInstance = new ActiveEstimatedTask(prevInstance) { IsUrgent = true }; foreach (var node in prevInstance.Estimation.NodesTimings) { node.AssignTask(clonedInstance); } plan.Plan.Add(clonedInstance); parent.ScheduledInstance = clonedInstance; return clonedInstance; }
public EstimatedUrgentWorkflow(EstimatedUrgentWorkflow other) : this((EstimatedWorkflow)other) { if (other == null) { return; } MinExecutionTime = other.MinExecutionTime; MaxExecutionTime = other.MaxExecutionTime; }
public override UrgentPlan MakePlan(EstimatedUrgentWorkflow workflow) { var plan = MakeInitialPlan(workflow) as TunablePlan; UrgentPlan subopt = null; do { //the following is just to avoid single meaningless execution of that block if (!plan.AtFirst(DoRoots)) { plan.Reset(); GeneratePlan(workflow, plan); } var shouldUpdate = false; var shouldMove = false; var trigger = false; if (subopt == null) { shouldUpdate = true; shouldMove = true; trigger = true; } if (!trigger && workflow.MinExecutionTime < TaskScheduler.E) //ASAP { return new GreedyHeuristics().MakePlan(workflow); } if (!trigger && workflow.MaxExecutionTime >= TaskScheduler.E && workflow.MaxExecutionTime - plan.EstimatedExecutionTime < TaskScheduler.E) //current time is above the higher bound { trigger = true; shouldUpdate = true; shouldMove = true; } if (!trigger && workflow.MinExecutionTime >= TaskScheduler.E) //should we count MinExTime at all? { if (plan.EstimatedExecutionTime - workflow.MinExecutionTime >= TaskScheduler.E) //is current plan above the lower bound? { if (!plan.HasAbortedTasks || subopt.HasAbortedTasks) //if current plan is the same or better in terms of terminating tasks { shouldUpdate = true; } shouldMove = true; } } if (shouldUpdate) { subopt = plan.Clone() as UrgentPlan; } if (!shouldMove) { break; } } while (plan.TrueForward(DoRoots)); return subopt; }
public override UrgentPlan MakePlan(EstimatedUrgentWorkflow workflow) { var plan = MakeInitialPlan(workflow) as TunablePlan; UrgentPlan subopt = null; do { if (!plan.AtFirst(DoRoots)) { plan.Reset(); GeneratePlan(workflow, plan); } var shouldUpdate = false; var shouldMove = false; var trigger = false; if (subopt == null) { trigger = true; shouldUpdate = true; shouldMove = true; } if (!trigger && workflow.MinExecutionTime < TaskScheduler.E) //ASAP { trigger = true; } if (!trigger && workflow.MinExecutionTime >= TaskScheduler.E) //should we count MinExTime at all? { if (workflow.MinExecutionTime - plan.EstimatedExecutionTime >= TaskScheduler.E) //the time grows, and as long as current time is beyond the lower bound, //we choose to increase it { trigger = true; shouldUpdate = true; shouldMove = true; } } if (!trigger && workflow.MaxExecutionTime >= TaskScheduler.E) //the time grows, and if the MaxExTime == 0 then we can safely stop without //further increasing it { if (workflow.MaxExecutionTime - plan.EstimatedExecutionTime >= TaskScheduler.E) //is it within bounds? { trigger = true; if (!plan.HasAbortedTasks || subopt.HasAbortedTasks) //if current plan is the same or better in terms of terminating tasks { shouldUpdate = true; } shouldMove = true; } } if (shouldUpdate) { subopt = plan.Clone() as UrgentPlan; } if (!shouldMove) { break; } } while (plan.TrueForward(DoRoots)); return subopt; }
public UrgentPlan(EstimatedUrgentWorkflow workflow) { wf = workflow; Reset(); }
internal virtual UrgentPlan CreateEmptyPlan(EstimatedUrgentWorkflow workflow) { return(new UrgentPlan(workflow)); }
internal override UrgentPlan CreateEmptyPlan(EstimatedUrgentWorkflow workflow) { return new TunablePlan(workflow); }
public virtual UrgentPlan MakeInitialPlan(EstimatedUrgentWorkflow workflow) { workflow.UpdateDependencies(); return(GeneratePlan(workflow, null)); }
internal override UrgentPlan CreateEmptyPlan(EstimatedUrgentWorkflow workflow) { return new FreeFirstPlan(workflow); }
protected virtual double GetNodesAvailabilityTimeForUrgentTask(ActiveEstimatedTask task, EstimatedUrgentWorkflow workflow) { return(task.Estimation.NodesTimings.Max(n => { var lTask = n.LaunchedTask; var result = lTask != null && (lTask.IsUrgent || !task.IgnoreNonUrgent) ? lTask.Estimation.Result.Time : 0; var td = new LaunchDestination() { ResourceName = n.ResourceName, NodeNames = new[] { n.NodeName } }; result += workflow.ActiveTasks.Where(t => t.IsUrgent && t.State == TaskScheduler.TaskState.SCHEDULED && t.IsOlderThan(task) && t.Estimation.Destination.IsLike(td)).Sum(t => t.Estimation.Result.Time); return result; } )); }
public virtual UrgentPlan MakeInitialPlan(EstimatedUrgentWorkflow workflow) { workflow.UpdateDependencies(); return GeneratePlan(workflow, null); }
public virtual UrgentPlan MakePlan(EstimatedUrgentWorkflow workflow) { return(MakeInitialPlan(workflow)); }
internal virtual IEnumerable<ActiveEstimatedTask> ChooseSequence(EstimatedUrgentWorkflow workflow, UrgentPlan plan) { var rootIds = workflow.Tasks.Where(t => !t.IsScheduled && t.IsReady).Select(r => r.Id); var effectiveEstimations = plan.Estimations.Where(e => rootIds.Contains(e.First().Id)).ToList(); var seq = effectiveEstimations.OrderBy(t => SecondaryComparisonLambda()(workflow, t)).First(); plan.Estimations.Remove(seq); return seq; }
public override UrgentPlan MakePlan(EstimatedUrgentWorkflow workflow) { var plan = MakeInitialPlan(workflow) as TunablePlan; UrgentPlan subopt = null; do { if (!plan.AtFirst(DoRoots)) { plan.Reset(); GeneratePlan(workflow, plan); } var shouldUpdate = false; var shouldMove = false; var trigger = false; if (subopt == null) { trigger = true; shouldUpdate = true; shouldMove = true; } if (!trigger && workflow.MinExecutionTime < TaskScheduler.E) //ASAP { trigger = true; } if (!trigger && workflow.MinExecutionTime >= TaskScheduler.E) //should we count MinExTime at all? { if (workflow.MinExecutionTime - plan.EstimatedExecutionTime >= TaskScheduler.E) //the time grows, and as long as current time is beyond the lower bound, //we choose to increase it { trigger = true; shouldUpdate = true; shouldMove = true; } } if (!trigger && workflow.MaxExecutionTime >= TaskScheduler.E) //the time grows, and if the MaxExTime == 0 then we can safely stop without //further increasing it { if (workflow.MaxExecutionTime - plan.EstimatedExecutionTime >= TaskScheduler.E) //is it within bounds? { trigger = true; if (!plan.HasAbortedTasks || subopt.HasAbortedTasks) //if current plan is the same or better in terms of terminating tasks { shouldUpdate = true; } shouldMove = true; } } if (shouldUpdate) { subopt = plan.Clone() as UrgentPlan; } if (!shouldMove) { break; } }while (plan.TrueForward(DoRoots)); return(subopt); }
internal virtual UrgentPlan CreateEmptyPlan(EstimatedUrgentWorkflow workflow) { return new UrgentPlan(workflow); }
internal override UrgentPlan CreateEmptyPlan(EstimatedUrgentWorkflow workflow) { return(new TunablePlan(workflow)); }
protected double FullTaskTime(ActiveEstimatedTask task, EstimatedUrgentWorkflow workflow) { var parent = workflow.Tasks.Single(wt => wt.Id == task.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max( d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); var nodesWaitingTime = GetNodesAvailabilityTimeForUrgentTask(task, workflow); //t.First().Estimation.NodesTimings.Max(n => n.AvailabilityTime); var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime); return waitingTime + task.Estimation.Result.Time; }
public FreeFirstPlan(EstimatedUrgentWorkflow workflow) : base(workflow) { }
public UrgentPlan(EstimatedUrgentWorkflow workflow) { wf = workflow; Reset(); }
public FreeFirstPlan(EstimatedUrgentWorkflow workflow) : base(workflow) { }