11 Scheduling Plans of Tasks
Internship report. Supervisors: Amal El Fallah Seghrouchni, Safia-Kedad Sidhoum
Davide Andrea Guastella
Abstract —We present a heuristic algorithm for solving theproblem of scheduling plans of tasks. The plans are orderedvectors of tasks, and tasks are basic operations carried out byresources. Plans are tied by temporal, precedence and resourceconstraints that makes the scheduling problem hard to solve inpolynomial time.The proposed heuristic, that has a polynomial worst-case timecomplexity, searches for a feasible schedule that maximize thenumber of plans scheduled, along a fixed time window, withrespect to temporal, precedence and resource constraints.
I. I
NTRODUCTION
Scheduling is a decision-making process that is used ona regular basis in many manufacturing and services indus-tries [1]. It deals with the allocation of resources to tasks overgiven time periods and its goal is to optimize one or moreobjectives.From a theoretical point of view, a scheduling problem is aconstrained combinatorial optimization problem where a set oftask must be ordered in such a way that all these are arranged,according to one or more constraints, to constitute a schedulethat minimize or maximize a given objective function.One of the most popular scheduling problem is the resource-constrained project scheduling problem (RCPSP) [2]: theobjective of resource-constrained scheduling consists in de-veloping a schedule such that a set of tasks is completed asearly as possible considering both the precedence relationshipsand the restricted availabilities of resources.The scheduling problem we are facing can be thought asa particular case of the RCPSP problem: in our case we arefacing the problem of scheduling plans of tasks subject to bothprecedence, resource and temporal constraints. Also, ratherthan scheduling tasks as in the RCPSP, our problem aims atselecting a maximum number of plans.II. C
ASE STUDIES
Nowadays, airborne platforms such as
Remote Piloted AirVehicles (RPAS) are employed in different scenario includingconflicts, surveillance and rescue [3]. In these scenario, air-borne platforms operate in highly dynamic environments witha low predictability. In this context, onboard instruments (i.e.sensors) allow the platform, hence the mission manager, tocollect knowledge from the field. Sensors carried by RPASare now able to perform a large panel of functions such asimage acquisition, spectrum analysis, and object tracking [4].All these sensors play a major role in operation and theiroptimization has become essential.Because of the criticality of the context and the mission’sobjectives, it is important to develop a method that orchestratesthe operations conducted by the sensors, such that the mission is accomplished correctly and by satisfying all the constraints.Moreover, due to both critical contexts and dynamic envi-ronment, it is important to orchestrate the operations of thesensors within a relatively short time.As further case study, consider the in-flight airplanesafety [5]. In this context there is a need for detecting andresolving data errors which could come from faulty sensormeasurements, inaccurate data processing, or poor informationtransmission, that can lead to catastrophic accidents as inthe case of the Air France 447’s accident. Our schedulingtechnique can be employed as a fault recovery technique:for example, once the fault has been detected by the on-board sensors, a system scheduler could discards the remainingflight plans, and schedules a set of emergency plans into thecurrent flight schedule. These emergency plans are strictly timeconstrained, and their orchestration necessarily needs to leadto a schedule which can guarantee the safety of passengers.III. D
EFINITIONS
Definition 1 (Plan of Tasks) . A plan of tasks Π k is a partialordering of tasks J ki to address a specific goal. Each plan Π k is characterized by a priority value α k . The structure ofthe plan is depicted by an activity-on-node (AON) networkwhere the nodes and the arcs represent the tasks and theprecedence relations respectively [6]. The precedence relationsare described by the notation ≺ . For example, given two plans Π k and Π j , Π k ≺ Π j indicates that the plan Π k must bescheduled before Π j .A plan is defined by the following notation: Π k = ( J k , ..., J kn k ) where k is an arbitrary index for the plan, n k is the numberof tasks in the plan Π k and J ki , with ≤ i ≤ n k is the i -thtask of the plan Π k . The set of tasks is topologically sorted(see 3).A plan Π k could not be scheduled if at least one task J ki ∈ Π k could not be scheduled due to unsatisfied constraints.A plan Π k is characterized by a set of resources R k ⊆ R . Definition 2. A graph G = ( V, E ) consists of a set of vertices V , and a set of edges E ⊆ V × V . In a directed graph the edgesare directed from one vertex to another. A directed acyclicgraph (or DAG) is a directed graph with no directed cycles: adirected cycle is a path that starts from any vertex u and endsin u . Definition 3 (Topological Sort) . A topological sort of adirected acyclic graph (DAG) G = ( V, E ) is a linear orderingof all its vertices such that if the graph G contains an edge a r X i v : . [ c s . A I] F e b ( u, v ) then u appears before v in the ordering [7, 8]. If thegraph contains a cycle, then no linear ordering is possible.For example, in Figure 1 a directed acyclic graph is showed,for which a topological sorting can be found, since it hasno cycles. Figure 2 shows a possible topological sorting forthe graph in Figure 1, where the different colors depict thedifferent frontiers in the corresponding DFS graph. Definition 4 (Frontier) . A frontier f for a graph G = ( V, E ) isa set of nodes f ⊆ V such that the maximum distance betweeneach node u ∈ f and the root node in the corresponding DFSgraph is the same. Fig. 1: A Directed Acyclic Graph.
Fig. 2: A possible topological sorting for the DAG in Figure 1.
Definition 5 (Task) . A task J ki is an atomic operation thata subset of resources must execute. Each task J ki belongsuniquely to one plan Π k . Tasks are characterized by thefollowing elements: • a processing time p ki ∈ N , p ki ≥ ; • a release date r ki ∈ N ; • a due date d ki ∈ N ; • a time lag δ kij ∈ N , if J ki ≺ J kj ; • a set of resources R ki = { ρ , ..., ρ n } , R ki ⊆ R k , whichthe task J ki is assigned to.The tasks within a plan can be dependent by a precedencegraph that provides the precedence constraints between thetasks. As for the plans, the precedence relations between tasksare described by the notation ≺ . For example, given two tasks J k and J k belonging to the same plan Π k , J k ≺ J k indicatesthat the task J k precedes the execution of the task J k . Definition 6 (Time lag) . A time lag δ kij is a fixed amount oftime which separates the finishing and starting times of a pairof tasks J ki and J kj respectively. By default, it is .In this paper, we assume that there is no preemption in thetask execution. Therefore, the execution of the tasks can not be interrupted once started. Moreover, we assume that each taskcould consume more than one resource during its execution. Definition 7 (Resource) . A resource ρ is any hardware orsoftware tool that tasks can use to handle information. Aresource ρ has a limited availability value B ρ . Resourcesare typically distinct in renewable and nonrenewable [6]:renewable resources have a fixed value of availability in eachtime period, while nonrenewable resources have a fixed valueof availability along the entire project’s time horizon. In the ad-dressed scheduling problem, we deal with renewable resourceswith a fixed availability value of B ρ = 1 , ∀ ρ ∈ R , in eachtime period. In particular, resources with a fixed availabilityvalue of B ρ = 1 are also called unary or disjunctive resources. Definition 8 (Resource availability) . The availability B ρ ∈ N of a resource ρ represents the maximum value of availabilityof the resource ρ in each time period.The abstract amount of usage of the resource ρ by the task J ki , in each time period, is represented by b kiρ = { , } .In this work we are concerned with solving the problem ofscheduling plans of tasks by using a heuristic that maximizesthe number of plans scheduled in a fixed time window, takinginto account precedence, time, and resource constraints.IV. P ROBLEM STATEMENT
A. Constraints1) Temporal constraints:
When a plan Π k is scheduled, foreach task J ki ∈ Π k both the starting time s ki and the comple-tion time C ki = s ki + p ki must be inside the temporal window [ W s , W e ] and also inside the temporal window [ r ki , d ki ] , where ( r ki ≥ W s ) ∧ ( d ki ≤ W e ) , ∀ J ki ∈ Π k . The value of s ki for a task J ki ∈ P i k is calculated as themaximum value between W s , the release date r ki of the task J ki augmented by the time lag δ kij , and the maximum completiontime C kj for each predecessor J kj ∈ Π k . Formally, s ki = max ( W s , r ki , max j ∈ pred ki ( C kj + δ kij )) , (1)where pred ki is the set of predecessors of the task J ki .Given a set P of plans, the plan Π k ∈ P satisfies thetemporal constraints if ∃ s ki ∀ J ki ∈ Π k : ( s ki ≥ r ki ) ∧ ( s ki + p ki ≤ d ki ) .
2) Precedence constraints:
In order to maintain the prece-dence constraints between plans, a set P of plans to be sched-uled is topologically ordered, since the precedence betweenplans can be represented as an acyclic directed graph (DAG),as showed in Figure 1. In our context, a graph G is a tuple ( V, E ) where V is a set of vertices and v k ∈ V representsa plan Π k ∈ P , and an arc ( u, v ) represents a precedenceconstraint between the plans that are represented by nodes u and v respectively.
3) Resource constraints:
The scheduling problem we ad-dress assumes that each task J ki ∈ Π k which has a feasiblestarting time s ki , can be executed by a subset R ki ⊆ R k ofresources if in the time period [ s ki , C ki ] the utilization of eachresource ρ ∈ R ki does not exceed its availability B ρ . B. Classification and mathematical formulation
A typical formal way to describe the scheduling problemsis by using the three-field classification [ α, β, γ ] introduced byGraham et al. [9], where • α specifies the machine environment, • β specifies the characteristics of the activities, • γ and describes the objective function(s).An extension of the Graham’s classification has been pro-posed in order to provide a more accurate way to formallydescribe the scheduling problems [10]. According to theextended notation, the plans of tasks scheduling problem canbe stated as P S , , | prec Π ; prec J ; [ W s , W e ]; [ r ki , d ki ]; δ kij | max k (cid:88) k α k x k where P Sm, , ∈ α indicates a resource environment fora project scheduling problem with m resources, a maximumavailability of unit per time for each resource, and aresource utilization, by each task, of at most unit per timeperiod. prec Π ; prec J ; [ W s , W e ]; [ r ki , d ki ]; δ kij ∈ β depictsthe characteristics of both plans and tasks: prec Π indicatesa precedence constraints between plans; prec J indicates aprecedence constraints between tasks; [ W s , W e ] and [ r ki , d ki ] indicates, for each task J ki ∈ Π k , the time constraints dis-cussed in IV-A1; δ kij indicates that each task J ki can have atime lag between its starting time s ki and the completion time C kj of its predecessor.The mathematical formulations for the RCPSP can beconveniently employed to model the objective function withrespect to the temporal, precedence and resource con-straints [11]. The proposed formulation is based on timediscretization for describing the usage of the resources andthe processing of the tasks over time. In our context the timehorizon, divided into unitary time periods, is a fixed timewindow [ W s , W e ] , where the maximum number of plans hasto be scheduled. Given a plan Π k ∈ P and a task J ki ∈ Π k ,and a time instant t ∈ [ r ki , d ki ] , let y kit be a boolean variable thatindicates whether the task J ki starts exactly at time t . Also, let x k be a boolean variable that indicates whether a plan Π k ∈ P is executed. Thus, a plan Π k ∈ P is executed if n k (cid:88) i =1 d ki (cid:88) t = r ki y kit = n k ⇒ x k = 1 , where n k is the number of tasks in Π k . If a task J ki has afeasible starting time s ki equals to t , then y kit = 1 for a timeinstant t ∈ [ r ki , d ki ] . Thus, if the sum n k (cid:88) i =1 d ki (cid:88) t = r ki y kit is equal to n k , then Π k is executed. Therefore, the variable x k is equal to . By using this notation, the objective function tomaximize can be formulated as: max k K (cid:88) k =1 α k x k such that, n k (cid:88) i =1 d ki (cid:88) t = r ki y kit = n k ⇒ x k = 1 ∀ Π k ∈ P (2) ( t + δ kij ≥ r ki ) ∧ ( t + δ kij + p ki ≤ d ki ) ⇒ y kit = 1 ∀ t ∈ [ W s , W e ] , ∀ J ki ∈ Π k (3) (cid:88) t t · ( y kit − y kjt ) ≥ p ki + δ kij if J ki ≺ J kj , ∀ J ki , J kj ∈ Π k , i (cid:54) = j (4) n k (cid:88) i =1 b kiρ · t + p ki (cid:88) τ = t y kiτ ≤ B k ∀ ρ ∈ R , ∀ t ∈ [ W s , W e ] (5)Constraint (2) imposes that for each plan Π k ∈ P all thetasks J ki ∈ Π k have a starting time assigned. Constraint (3)imposes that each task J ki has a starting time and a completiontime within the time window [ r ki , d ki ] . Constraints (4) and (5)impose respectively the precedence and resource constraints.V. P ROPOSED METHOD
In this section is discussed a greedy heuristic for theproblem of scheduling plans of tasks.
Definition 9 (Schedule) . A schedule S is a vector ( s ki ) , i = 1 , ..., n k , k = 1 , ..., K such that s ki ∈ S is a startingtime for the task J ki . A schedule represents a solution for thescheduling problem if it satisfies the scheduling constraints.Given a temporal window W = [ W s , W e ] , the goal ofthe proposed heuristic is to create a feasible schedule thatcontains the maximum number of plans of tasks, inside thetemporal window [ W s , W e ] , regarding their weight, such thateach scheduled plan Π k satisfies the precedence, temporaland resource constraints discussed in IV. The set P of plansgiven as input to the algorithm is preventively sorted in orderto maintain their precedence relations, and also to evaluate,at each iteration of the algorithm, the plan with the highestpriority value. The feasibility of the plans is evaluated in aschedule S w until no plans remains to schedule, or there is noplan that can be scheduled due to a violation of the constraints.Each plan Π k ∈ P could have precedence relations betweenits tasks. The topological sorting of the tasks ensures thatthe execution of the tasks is done with respect to the theirprecedence relations. Example 1 shows an example of feasibleschedule where a precedence relation occurs between the tasksof a plan. Example 1.
Figure 3 shows a Gantt diagram for a feasibleschedule for a set of plans P = { Π , Π } , which parametersare listed in Table I. A precedence constraint occurs betweenthe tasks J and J , both belonging to the plan Π . r ki d ki p ki δ kij R ki J ki ≺ J kj J { } J { } J ≺ J J { } TABLE I: The parameters of the tasks of the plans Π and Π in the Example 1. R e s o u r c e s Time W s W e J J J Fig. 3: A feasible schedule for the set P of two plans. Aprecedence constraint occurs between J and J .The task J has been scheduled after the end of theexecution of the task J , since there is a precedence constraintbetween J and J . For this reason, the task J has not beenscheduled at .For a given DAG, more than one topological sort couldexist. Under this assumption, different topological sorting fora plans’ precedence graph could lead to different schedules.For this reason, the plans belonging to the same frontier aresorted by their priority value, since for these plans the orderin which they are scheduled is irrelevant according to theprecedence constraints. Moreover, different plans may havethe same priority value: in this case, the plans must be sortedaccording to a different criterion described in the following.Given a feasible schedule S w and a subset P α k ⊆ P ofplans having the same priority value α k , in order to maximizethe resource utilization for each tasks J ki ∈ Π k ∈ P α k wecalculate an idle time between each task J ki ∈ Π k and itspredecessor, in the same resource. Definition 10 (Idle time) . Let S be a feasible schedulecontaining two plans Π k , Π p , p (cid:54) = k . Let J ki ∈ Π k and J pj ∈ Π p be two tasks scheduled on the same resource ρ ∈ R ,where s ki > C pj . If there is at least one plan Π q schedulable in S such that ∃ J ql ∈ Π q executed by the same resource ρ ∈ R such that ( C pj ≤ s ql < s ki ) ∧ ( C pj < C ql ≤ s ki ) , the time window [ C pj , s ki ] is said to be an idle time .In Figure 4 is showed an idle time between two tasks. J p J k C p s kj i J qll s ql C ql t j i Fig. 4: The time window [ C pj , s ki ] is an idle time because J ql ∈ Π q can be scheduled in this interval. r ki d ki p ki δ kij R ki J ki ≺ J kj J { } J { } J { } J { } J { } J ≺ J J { } TABLE II: The parameters of the tasks of a set P of plans.Let S be a feasible schedule, and P α k a set of plans havingeach one priority α k . The plans of P α k are scheduled inorder to minimize the presence of idle times. This is doneby choosing iteratively the plans who minimize the followingquantity: (cid:88) i s ki − C Γ ki ( ρ i ) , ∀ J ki ∈ Π k ∈ P α k where C Γ ki ( ρ i ) is the completion time of the task Γ ki ( ρ i ) , thatis, the predecessor of task J ki in the same resource ρ i executingthe task J ki .Example 2 shows how the idle time is used by the proposedheuristic to determine the order according to which two planshave to be scheduled. Example 2.
Let P = { Π , Π , Π , Π } be a set of plans toschedule, which information are listed in Table II, and let S w be a feasible schedule where Π and Π have been scheduled(Figure 5a). Let P l = { Π , Π } be a set of two plans suchthat Π and Π have priority values α = l and α = l respectively. As showed in Figure 5b-5c, both plans Π and Π generate two feasible schedules.The difference between the starting time s and its pre-decessor (in this case W s since there is no predecessor of J ) is equal to 2. Within P l , the plan Π has a task J that can be scheduled at s = 3 < s , where all theconstraints are satisfied, and both J and J demand the sameresource. Moreover, scheduling the plan Π before Π leadsto a schedule where no idle times are generated. Therefore,plan Π is scheduled before plan Π .The scheduling algorithm operates in a similar way as theserial scheduling scheme proposed in [11]. In our context, weassume that each resource has a maximum availability of 1in each time period. In this case, each resource can executeone task at a time. The idea of the proposed heuristic is toschedule all the plans as soon as possible by respecting theresource, precedence and temporal constraints. The insertionof the plans into a schedule is done by handling an event list EL . An event is a -tuple ( t ( e ) , S ( e ) , C ( e ) , ( b ρ ( e )) ρ ∈R ) : • t ( e ) denotes the time instant of the event; • S ( e ) is the set of tasks starting exactly at time t ( e ) ; R e s o u r c e s Time W s W e J J J (a) R e s o u r c e s Time W s W e J J J J (b) R e s o u r c e s Time W s W e J J J J J (c) Fig. 5: Scheduling plans with the same priority value intoa schedule with two plans schedule (Figure 5a). Schedulingplan Π before plan Π (Figure 5b) leads to a schedule withan idle time of 2, since in the interval [2 , the task J ofthe feasible plan Π can be scheduled. Scheduling plan Π before Π (Figure 5c) leads to a schedule with an idle timeof 0. Therefore, Π is scheduled before Π . • C ( e ) is the set of tasks completing exactly at time t ( e ) ; • b ρ ( e ) represents the usage of resource ρ during interval [ t ( e ) , t ( next e )[ , where next e is the first event following e in EL .When a feasible task J ki is scheduled and inserted into S ( e ) for a an event e ∈ EL , the usage of the resource b ρ ( e ) isset to . The resource constraints for the scheduling problemwe address assumes that no task can be scheduled at t ( e ) if b ρ ( e ) = 1 . A. Description of the heuristic
The proposed heuristic (Algorithm 1) (
BuildSchedule )takes in input a set P of plans and a set R of resources,and it gives as output a feasible schedule S l , that is, a vectorof starting times s ki for each scheduled task J ki ∈ Π k suchthat the constraints discussed in the previous section are met.At the beginning, the algorithm initializes the used datastructures. At line 1 and 2 respectively, two set P s and P f are initialized: they will be used to store respectively thesuccessfully scheduled plans and the discarded (unscheduled)plans. Then, two empty schedules S l and S w are initialized.They will contain respectively the last feasible schedule foundand the current working schedule. The working schedule is aschedule used for testing the feasibility of the plans during thesearch. Finally, an event list EL is initialized at line 5. The firststep of the algorithm is to sort the set P of plans accordingto both precedence relations and priority values (line 6). Thisis done by Algorithm 2, that returns a sorted list P u of plans.Then, a loop over P u starts until there is a plan left to schedule(line 7). At line 8, the highest priority plan Π k is taken fromthe sorted set P u of plans. Then, at line 10 the algorithmchecks if there exists more than one plan in P u with the samepriority value α k of Π k . If the value of α k is unique amongthe values of priority of the plans in P u , the algorithm tries toschedule the plan (line 11), otherwise a set P α k ⊂ P of plansis calculated, containing all the plans that have priority value α k . All the plans in P α k are then scheduled by Algorithm 5.Thus, the plans successfully scheduled are added into P s (line 20), and the plans not scheduled are removed from theworking schedule (line 22). Finally, the last feasible schedule S l is updated (line 24).Algorithm 1 takes at most O ( K n ) time, where K = |P| is the number of plans to schedule.All the data structures used for storing plans, P , P u , P s and P f , are implemented as self-balancing binary search treesto ensure insertion, removal and get operations in logarithmictime [7]. At line 5 the event list EL is initialized. As the datastructures used for storing plans, the event list is implementedas self-balancing binary search tree. At line 6 the plans aresorted by the Algorithm 2.The while loop 7-26 iterates until the set of plans P u is notempty. In the worst case, if the plans belongs all to the samefrontier, the inner loop takes at most O ( K n ) time.The Get operations at line 8 takes logarithmic time withrespect to the number of elements in P u .At line 9 the algorithm get the number of plans in P u thathave priority value α k . We use an auxiliary data structure tostore this information and get the value in O (1) .The Add and
Remove operations at line 13 and 15 re-spectively require both O (log K ) time. Getting the plans withpriority α k (line 18) requires constant time, since a hash mapis used to store the plans with the same priority value: the keyof a record is a value of priority α k , and the value is a list ofplans having each one α k as priority value. The
Add operation at line 20 requires O ( K log K ) time.The Remove operations at line 21 and 22 require both O ( K log K ) time. Algorithm 1
BuildSchedule
Require:
A set of plans P Ensure:
A feasible schedule S l , a set P s of scheduled plans,a set P f of unscheduled plans P s ← {} { Scheduled plans } P f ← {} { Discarded plans } S l ← () { Feasible schedule } S w ← () { Working schedule } EL ← {} P u ← SortPlans( P ) while P u (cid:54) = ∅ do Π k ← Get( P u ) N α k ← number of plans in P u with priority α k if N α k = 1 then success ← SchedulePlan( Π k , S w , EL ) if success then Add( Π k , P s ) else Remove( Π k , S w ) end if else P α k ← plans of P with priority α k U ←
SchedulePlanSet( P α k , S w , EL ) Add( P α k \ U , P s ) Remove( P α k , P u ) Remove( U , S w ) end if S l ← S w P f = P \ P s end while Algorithm 2 (
SortP lans ) sort a set P of plans in decreasingorder of priority so that the precedence constraints betweenplans are also respected. At line 1 a topological sort algorithmis executed for the plan set. A set of couples (Π i , F i ) isreturned, where Π i is the i -th plan in the topological sorting,and F i is the subset of plans of the frontier f i which the plan Π i belongs to. Then, let F be the set of subsets F i of plansfor each frontier f i (line 2), a loop over each set F i is done(line 4-7), where each F i is sorted according to the priorityvalue the plans in the frontier f i (line 5), and then added tothe set P u of sorted plans (line 6).Algorithm 2 takes at most O ( K log K + n k ) , where K = |P| is the number of the plans to be sorted. At line 1, the set ofplans is topologically sorted. The topological sort requires atmost O ( K + n k ) where n k is the number of predecessors inthe precedence’s graph of the plan Π k .At line 2 the set of frontiers discovered by the topologicalsort is assembled: this set is implemented as an hash tablewhere the key of a record is a priority value α k , and the valueis a list of plans having each one α k as priority value.The loop 4-7 iterates over each frontier in the precedence’sgraph, and sort the plans belonging to that frontier accordingto their priority value. At line 5, plans belonging to a specific frontier f are sorted by using the timsort algorithm [12]. Thefor loop requires at most O ( K log K ) time if all the plansbelong to the same frontier. Algorithm 2
SortPlans
Require:
A set of plans P Ensure:
A sorted set of plans P u P t ← T opologicalSort ( P ) compute F i for i = 1 , ..., f P u = ∅ for i = 1 , ..., f do sort F i according to α Add ( F i , P u ) end for return P u Algorithm 3 (
ScheduleP lan ) schedules a single plan Π k into a schedule S w using an event list EL . It iterates overall the tasks J ki ∈ Π k and for each task, the precedenceconstraints are checked, and then the task is scheduled into theschedule S w . If at least one task could not be scheduled, thealgorithm immediately breaks the loop, and false is returned,since the plan could not be scheduled such that all theconstraints are satisfied.Algorithm 3 takes O ( n ) time, where n = (cid:80) k n k , ∀ Π k ∈ P is the total number of tasks already scheduled in S w . Insidethe loop the Algorithm 4 is executed O ( n k ) time. Algorithm 3
SchedulePlan
Require:
A plan Π k , a schedule S w , an event list EL Ensure: true if Π k has been scheduled in S w , f alse other-wise. for all task J ki ∈ Π k do success ← scheduleTask( J ki , S w , EL ) if not success then mark Π k as unschedulable return f alse end if end for return true Algorithm 4 (
ScheduleT ask ) do the actual task insertioninto a schedule. It starts by calculating the earliest possiblestarting time given by (1) if we do not consider the resourceavailability. At line 2 the algorithm searches for an event e in EL such that t ( e ) = s ki . If such event does not exist, a newevent e is created at t ( e ) = s ki . At line 4, the algorithm startsa loop to search for the earliest feasible start and end events e and f for the task J ki . The loop iterates until f is not the lastevent or the remaining duration µ , initially set to p ki , it is notnull. If the condition of the while loop is satisfied, g is assignedthe event following f (line 5), and the algorithm proceeds bychecking the resource availability and the constraints test for J ki in t ( e ) (line 6). If both the tests succeed, µ is decreasedby t ( g ) − t ( f ) and g is assigned to f . If the tests fail, then e isnot a valid insertion position, and then e is set to g while µ isreset to p ki . After the loop, a final check for the constraints isdone (line 13). If the final check fails, then all the tasks of the plan Π k are removed from each event e in the event list EL (line 14), the plan Π k is marked as unschedulable (line 15)and f alse is returned.Once the constraints are verified for e at line 13, thealgorithm proceed with the insertion of the task J ki into theworking schedule (line 18), and into the event e (line 19).Then, at line 21, the event e is added into the event list EL if it is not already in. The steps (23-31) update the event list.The last step consists in updating the resources usage by thescheduled tasks (line 32).Algorithm 4 has a time complexity of O ( n ) , where n = (cid:80) k n k . Searching for a feasible starting time s ki (line 1) re-quires at most O ( n − time if task J ki has n − predecessors.Searching for the event e such that t ( e ) = s ki (line 2) requiresat most O (log |EL| ) since a balanced tree data structure isused for the event list.In the worst case, for a set P of plans with cardinality |P| = K , the maximum number of events in EL is n if wesuppose that all the tasks are scheduled consecutively with aminimal lag between each task, that is |S ( e ) | = 1 ∧ |C ( e ) | = 0 ∨|S ( e ) | = 0 ∧ |C ( e ) | = 1 , ∀ e ∈ EL . The while loop (lines 4-12) iterates over the event list EL .Since there are less than n events, the while loop takes O ( n ) time.Searching for the event following f in EL (line 5) takes atmost O (log |EL| ) time. Checking if the temporal constraintsare satisfied at t ( e ) (line 6) takes O (1) time. The remainingoperations inside the loop require constant time.Removing all the tasks J ki ∈ Π k from each event e ∈ EL (line 14) takes O ( n k log |EL| ) .Adding the task J ki to the schedule S w (line 18) requires atmost O (log n ) since an efficient balanced tree data structureis used for the schedules. Adding the task J ki to the set S e (line 19) requires constant time.Adding the event e to the event list EL (line 21) requires O (log |EL| ) time.The event list update takes O (log |EL| ) if the event g hasto be inserted in EL (lines 26,29), otherwise the insertion of J ki into C ( f ) (line 24) requires O (1) time.Algorithm 5 ( ScheduleP lanSet ) schedules a set P α k ofplans such that each plan Π k ∈ P α k has a priority value α k .The idea of the algorithm is to find, at each iteration, the planwho minimizes the sum of the size of the idle time windowsgenerated by its tasks. The algorithm starts by creating a copy V of the plan set P α k (line 1). The while loop (lines 3-25) iterates until there is no plan left in V to schedule. Ateach iteration, two variables minIdleT ime and bestP lan areused to keep the next candidate plan to schedule. The loopat (6-19) iterates over the plans in V and searches for thecandidate plan to schedule. Each plan Π k is scheduled intoa temporary schedule S temp (line 9). At each iteration, thealgorithm chooses the plan Π k ∈ P α k that minimizes the sumof the time differences between t ( e ) and t ( pred e ) (line 11),for each event e such that J ki ∈ S ( e ) , ∀ J ki ∈ Π k . Algorithm 4
ScheduleTask
Require:
A task J ki , a schedule S w , an event list EL Ensure: true if J ki has been scheduled in S w , f alse other-wise. s ki = max ( W s , r ki , max j ∈ pred ki ( C kj + δ kij )) e ← GetEvent( s ki , EL ) µ ← p ki ; f ← e while ( f is not the last event of EL ) ∧ ( µ > do g ← next f if ( b ρ ( f ) = 0 , ∀ ρ ∈ R ki ) ∧ ( CheckConstraints ( t ( e ) , J ki )) then µ ← max (0 , µ − t ( g ) + t ( f )) f ← g else µ ← p ki ; e ← g ; f ← g end if end while if not CheckConstraints ( t ( e ) , J ki ) then remove all tasks J ki ∈ Π k from e , ∀ e ∈ EL mark Π k as unschedulable return false end if Add( J ki , S w ) Add( J ki , S ( e )) if e / ∈ EL then EL ← EL ∪ e end if if t ( e ) + p ki = t ( f ) then Add( J ki , C ( f )) else if t ( e ) + p ki > t ( f ) then insert g = ( t ( e ) + p ki , ∅ , { t } , ( b ρ ( f )) ∀ ρ ∈R ki ) in EL f ← g else insert g = ( t ( e ) + p ki , ∅ , { t } , ( b ρ ( pred f )) ∀ ρ ∈R ki ) in EL f ← g end if b ρ ( g ) = 1 ∀ ρ ∈ R ki , ∀ g between e and pred f in EL return true Algorithm 5 takes at most O ( K n ) time. The main loop(lines 3-25) is repeated until there is some plan left to schedule,and it is repeated at most O ( K ) time. The inner loop (lines 6-19) schedule each plan Π k ∈ P α k and keeps the plan whichminimize the idle times between each task and its predecessor.The inner loop takes O ( Kn ) time.Algorithm 6 ( CheckConstraints ) checks if a starting time t ( e ) satisfies the temporal constraints, discussed in IV-A1, for atask J ki . If the temporal constraints are satisfied, the algorithmreturns true .Algorithm 6 requires constant time.In Table III are resumed the functions employed by theproposed method, together with a short description and theirtime complexity. Example 3.
In this example we show how different plansare scheduled according to the proposed heuristic. We start
Algorithm 5
SchedulePlanSet
Require:
A set P α k ⊂ P of plans, a schedule S w , an eventlist EL Ensure:
A set U of unscheduled plans V ← P α k U ← ∅ while V (cid:54) = ∅ do minIdleT ime ← + ∞ bestP lan ← ∅ for all Π k ∈ P α k do S temp ← S w EL temp ← EL success ← scheduleP lan (Π k , S temp , EL temp ) if success then it = (cid:80) i ( t ( e ) − t ( pred e )) , ∀ J ki ∈ S ( e ) if it ≤ minIdleT ime then minIdleT ime ← it bestP lan ← Π k end if else Remove (Π k , V ) end if end for success ← scheduleP lan ( bestP lan, S w , EL ) if not success then Add ( bestP lan, U ) end if Remove ( bestP lan, V ) end while return U Algorithm 6
CheckConstraints
Require:
A task J ki , a starting time t ( e ) for J ki Ensure: true if J ki satisfies the temporal constraints, f alse otherwise. if (cid:0) t ( e ) ∈ [ r ki , d ki ] (cid:1) ∧ ( t ( e ) ∈ [ W s , W e ]) ∧ (cid:0) t ( e ) + p ki ∈ [ W s , W e ] (cid:1) then return true end if return false from a feasible schedule containing two plans Π and Π ,and we try to schedule in order the plans Π , Π and Π .In Table IV are listed the parameters of the plans of tasks P = { Π , Π , Π , Π , Π } .Let Π be the next plan to be scheduled, which has only onetask J . The earliest starting time s is set to the release time r = 1 . The event e ∈ EL has a time instant t ( e ) = r = 1 ,thus e is the first event in which J can be scheduled. Theresource constraints in e are satisfied for J , so it can bescheduled at t ( e ) = 2 . The resource usages b ( e ) and b ( e ) are finally updated.Table V shows the resulting Gantt diagram and the eventlist EL after the insertion of the plan Π .Following, plan Π is the next plan to be scheduled. Theearliest starting time s for J is s = t ( e ) = W s . At e the Function name and description Timecomplexity
BuildSchedule ( P ) Entry point algorithm. It is responsiblefor assembling a feasible schedule for a set P of plans. O ( K n ) ScheduleP lan (Π k , S w , EL ) Schedule the plan Π k into the schedule S w . O ( n ) ScheduleP lanSet ( P α k , S w , EL ) Schedule a set of plans P α k that have the same priorityvalue into the schedule S w . O ( K n ) ScheduleT ask ( J ki , S w , EL ) Schedule the task J ki into the schedule S w . O ( n ) SortP lans ( P ) Sort a set of plans P according to their precedencerelations by using T opologicalSort algorithm. Then, theplans that belong to the same frontier in the topologicalsorting are sorted by their priority value. O ( K log K + n k ) T opologicalSort ( P ) Sort a set of plans P according to their precedencerelations by using a topological sorting algorithm. Itreturns a sorted copy of the plan set given as input. O ( K + n k ) GetEvent ( s ki , EL ) Get the event e ∈ EL such that t ( e ) = s ki . If such eventdoes not exists, a new event e is created at t ( e ) = s ki . O (log |EL| ) Get ( P ) Get the highest priority plan from P . O (log K ) TABLE III: Descriptions of the functions used by the schedul-ing algorithm. r ki d ki p ki δ kij R ki J ki ≺ J kj J { } J ≺ J J { } J { } J ≺ J J { } J { } J { } J ≺ J J { } J { } J ≺ J J { , } TABLE IV: The parameters of the tasks of the plans inExample 3.temporal and resource constraints for J are satisfied, so itis scheduled at s = t ( e ) = 2 , and then the resource usages b ( e ) is updated. Following, an insertion point is searched forthe task J . The earliest starting time for J is s = t ( e ) = 6 ,since there is a time lag between J and its predecessor J .The event e is a good insertion point for the task J , sincehere the precedence, resource and temporal constraints aremet. J is finally scheduled at s = t ( e ) = 6 . The resourceusage b ( e ) is updated. Since a feasible insertion point hasbeen found for both J and J , the plan Π is scheduledcorrectly and the schedule generated is considered as feasibleschedule.Table VI shows the resulting Gantt diagram and the eventlist EL after the insertion of the plan Π .Finally, plan Π is the last plan to be scheduled. The earlieststarting time for J is s = 5 . At t ( e ) = 5 the temporal andresource constraints for J are not satisfied ( b ( e ) = 1 ). Thenext event e is a good insertion point for the task J , sincehere the resource constraint and also the temporal constraintsare met. The task J is finally scheduled at s = t ( e ) .Following, an insertion point is searched for the task J , whichconsumes both the resources and . The earliest starting time e t ( e ) S ( e ) C ( e ) b ( e ) b ( e ) b ( e ) e { J , J } ∅ e { J } ∅ e ∅ { J } e { J } { J , J } e { J } ∅ e ∅ { J , J } R e s o u r c e s Time W s W e J J J J J TABLE V: Insertion of the plan Π into a feasible schedule. e t ( e ) S ( e ) C ( e ) b ( e ) b ( e ) b ( e ) e { J , J , J } ∅ e { J } { J } e ∅ { J } e { J , J } { J , J } e { J } { J } e ∅ { J , J } R e s o u r c e s Time W s W e J J J J J J J TABLE VI: Insertion of the plan Π into a feasible schedule.for J is s = 5 . The resources constraints are not satisfiedin the events e , e and e . The event e is the first feasibleinsertion point for the task J , since at t ( e ) the precedenceand temporal constraints are met. Also, in e both resources and are available ( b ( e ) = 0 and b ( e ) = 0 ). The task J is finally scheduled at s = t ( e ) , and the usages of resources and , respectively b ( e ) and b ( e ) , are updated. Since afeasible insertion point has been found for both J and J ,the plan Π is scheduled correctly and the schedule generatedis considered as feasible schedule.Table VII shows the resulting Gantt diagram and the eventlist EL after the insertion of the plan Π .VI. C OMPUTATIONAL RESULTS
In this section we present the computational results for theproposed heuristic. All the experiments were run on an entry-level machine (Intel i5-4210U, 6GB RAM, Linux OS). Thealgorithms were entirely written in Java (version ).We run different experiments of our algorithm by using abenchmark that depicts a realist scenario of a mission carriedout by a Remote Piloted Air Vehicle (RPAS), which set ofplans, listed in Table VIII, has to be scheduled. The validityof the mission is constrained between and seconds.Therefore, the time window [ W s , W e ] is fixed to [0 , .We first evaluated the proposed heuristic on the benchmarklisted in Table VIII. Then, we evaluated the performanceof the proposed heuristic on different benchmarks obtainedby modifying the set of plans listed in Table VIII. Thesemodified benchmarks are opportunely set up in such a waythat the constraints are more or less relaxed. Thus, we studied eight different scenarios, which results are listed in Table IX.Following are listed the differences between each scenario: • Scenario 1 : set of plans listed in Table VIII; • Scenario 2 : in this scenario all the plans have thesame temporal window [ r k , d k ] fixed to [0 , , andthe plans are all tied by precedence relations, so that ∀ i, j, j > i, Π i ≺ Π j ; • Scenario 3 : in this scenario we modified the release timeof each plan in such way to have the maximum numberof events; • Scenario 4 : in this scenario we duplicated all the planswith priority and ; • Scenario 5 : in this scenario we duplicated all the planswith priority and ; • Scenario 6 : in this scenario we used the same benchmarkas the scenario 1, but we used a time window [ W s , W e ] fixed to [0 , ; • Scenario 7 : in this scenario we used the same benchmarkas the scenario 1, but we used a time window [ W s , W e ] fixed to [0 , ; • Scenario 8 : in this scenario we used the same benchmarkas the scenario 1, but each plan has a duplicate.Table IX presents the execution times for each scenario.Each execution time is calculated as the mean of the executiontimes of ten runs of the algorithm on the same benchmark.The obtained computational results of the algorithm gaveus a first proof of concept concerning the complexity of thescheduling problem we address. Moreover, the results are yetsatisfactory in the context of scheduling plans for RPAS. Asthe problem of scheduling plans of tasks is difficult due to its e t ( e ) S ( e ) C ( e ) b ( e ) b ( e ) b ( e ) e { J , J , J } ∅ e { J } { J } e ∅ { J } e { J , J , J } { J , J } e { J } { J } e { J } { J , J , J } e ∅ { J } R e s o u r c e s Time W s W e \ J J J J J J J J J J TABLE VII: Insertion of the plan Π into a feasible schedule. Π k n k α k R k [ r k , d k ] p k p k p k p k δ kij Π k ≺ Π j J ki ≺ J kj Π { , } [0 , J ≺ J Π { , } [0 , { } [0 , { } [0 , { } [0 , { } [0 , { , , , } [80 , J ≺ J Π { , , , } [40 , J ≺ J Π { , , , } [40 , J ≺ J Π { , , } [50 ,
80] 5 5 5 J ≺ J Π { , , , } [80 , ≺ Π J ≺ J Π { , , , } [0 ,
80] 20 20 20 20 J ≺ J Π { , , } [0 ,
40] 5 5 5 J ≺ J Π { , , , } [40 ,
80] 20 20 20 20 Π ≺ Π J ≺ J Π { , , } [0 ,
20] 5 5 5 J ≺ J Π { , , , } [20 ,
80] 20 20 20 20 Π ≺ Π J ≺ J Π { , } [60 , J ≺ J Π { , } [60 , J ≺ J Π { , } [60 , J ≺ J Π { , , } [0 ,
20] 5 5 5 J ≺ J Π { , , , } [20 ,
60] 20 20 20 20 Π ≺ Π J ≺ J Π { , } [30 ,
70] 2 2Π { , , , } [40 ,
90] 20 20 20 20 J ≺ J Π { , , , } [80 , J ≺ J Π { , , , } [80 , J ≺ J Π { , , , } [130 , J ≺ J Π { , } [0 , { , , } [80 , J ≺ J Π { , } [120 , ≺ Π J ≺ J Π { , } [120 , { , , , } [150 , J ≺ J Π { , } [120 , J ≺ J TABLE VIII: The benchmark used for evaluating the performance of the proposed method. K = |P| Kn k |P s | |P s | n k Time (in ms)Scenario 1
32 91 24 56 ∼ Scenario 2
32 91 24 67 ∼ Scenario 3
32 91 24 64 ∼ Scenario 4
42 118 30 68 ∼ Scenario 5
47 135 29 64 ∼ Scenario 6
32 91 16 35 ∼ Scenario 7
32 91 24 60 ∼ Scenario 8
64 182 37 81 ∼ TABLE IX: Execution times of the eight scenarios.tight constraints, we conclude that the quality of the schedulesprovided by the proposed heuristic is good with respect to thecomplexity of the evaluated benchmarks. VII. F
UTURE WORKS
A. Variable resource availability
The proposed heuristic considers only resources with afixed availability of B ρ = 1 , ∀ ρ ∈ R . A generalization ofthe algorithm could take into account resources with variableavailability values, so that one resource could be used bydifferent tasks at the same time. Augmenting the resourceavailability could also lead to better schedules in terms ofnumber of plans scheduled into a fixed time window, asshowed in Example 4. Example 4.
Let P = { Π , Π } be a set of two plans Π and Π which have each one task, respectively J ( r = 1 , d = 6 , p = 3 ) and J ( r = 4 , d = 10 , p = 4 ). In Figure 6 are showed two possible schedules for the task J . If the resource has a maximum availability B = 1 (Figure 6a), the earlieststarting time for the task J would be , because otherwisethe usage of resource would exceed its availability. Instead, ifthe availability of the resource is (Figure 6b), the earlieststarting time would be set to (that is, the release time of thetask), and so the use of the resource is maximized. Also, inthe schedule showed in Figure 6b the time interval [5 , canbe employed for scheduling other tasks, whereas this is notpossible in the schedule in Figure 6a. R e s o u r c e s Time W s W e J J (a) Time W s W e J J R e s o u r c e s (b) Fig. 6: Scheduling of task J , which has a release time of ,into a resource with availability B = 1 (6a) and a resourcewith availability B = 2 (6b). B. p ki as function of time The value of the processing time p ki for a task J ki could bemodeled as a function of time p ki ( t ) in such a way that theprocessing time of a task J ki can vary according to the timeinstant in which it is scheduled. To motivate this extension,we present in Example 5 a case study of a RPAS that has toaccomplish some in-flight operation. Example 5.
Let us consider a RPAS that has to accomplish amission where it has to follow a straight trajectory and collectdata from an object R located in the terrain during a fixedtime range, as depicted in Figure 7. During the the time rangein which the RPAS is within the object’s range it has to sendinformation to the object R in the terrain. The operation ofsending information could require more time when the RPASis far from the object, but less time when it is near the object.Thus, the processing time function related to the operation ofsending information could be modeled as an inverse Gaussianfunction, as showed in Figure 8, where d max and d min arerespectively the maximum and the minimum distance betweenthe RPAS and the object R . t=t Object’s range R t=t +40t=t +20t=t +30t=t +10t=t +50 RPAS
RPAS’s range
Fig. 7: An example of RPAS that has to communicate in-formations to an object R . The processing time of the taskscommunicating with R could vary according to the distancebetween the object R and the RPAS with respect to the timeinstant t . t +20 t +30 t +40d min d max Fig. 8: An inverse Gaussian used to model the processing time p ( t ) of the the operation of sending information to a fixedobject for the RPAS in Figure 7. C. Alternative schedules
The proposed heuristic works in an incremental fashion,adding plans in order to a working schedule S w and keeping a set P s of successfully scheduled plans, as well as a set P f of unscheduled plans. The incremental process of constructionof a feasible schedule can be represented as an directedacyclic graph, as shown in the example graph in Figure 9.According to this representation, each vertex represents afeasible schedule, while a directed arc ( i, j ) , which has label Π k , represents the insertion of the plan Π k into the schedule S i , that leads to a new feasible schedule S j . S S S S S S Π Π Π Π Π Π S S Π Π ∅ Fig. 9: The graph representation of a feasible schedule withfour plans (in blue), and two possible alternative schedule(yellow and green).The incremental manner of constructing the schedules hasthe advantage of being able to return a feasible schedule ateach iteration of the algorithm.Since the proposed method builds only a graph with nobranches (no alternative schedule paths), a possible extensioncould consider different metrics to build alternative paths inthe graph of solutions. For example, as the proposed heuristicreturns a set P f of plans unscheduled due to constraintsviolations, one possible extension could increase the priorityvalues of the unscheduled plans in P f while lowering thoseof a subset of feasible plans in P s . In this manner, alternativepaths in the solution graph could be found. Also, these al-ternative paths could maximize further the objective function,thus allowing the heuristic method to escape from the localoptima. VIII. C ONCLUSIONS
This article presented a heuristic algorithm for the problemof scheduling plans of tasks. The algorithm may be employedin realistic scenarios where the classical scheduling techniquecan not be used due to the considered constraints.R
EFERENCES[1] M. L. Pinedo,
Scheduling . Springer US, 2012. DOI: 10.1007/978-1-4614-2361-4.[2] R. Klein,
Scheduling of Resource-Constrained Projects , vol. 10 of
Operations Research/Computer Science Interfaces Series . Boston, MA:Springer US, 2000. DOI: 10.1007/978-1-4615-4629-0.[3] L. Grivault, A. E. Fallah-Seghrouchni, and R. Girard-Claudon, “Agent-Based Architecture for Multi-sensors System Deployed on AirbornePlatform,” pp. 86–89, IEEE, Sept. 2016.[4] S. Kemkemian and M. Nouvel-Fiani, “Toward common radar & EWmultifunction active arrays,” pp. 777–784, IEEE, Oct. 2010.[5] S. Imai, E. Blasch, A. Galli, W. Zhu, F. Lee, and C. A. Varela,“Airplane flight safety using error-tolerant data stream processing,”
IEEEAerospace and Electronic Systems Magazine , vol. 32, pp. 4–17, Apr.2017. [6] C. Schwindt and J. Zimmermann, eds.,
Handbook on Project Manage-ment and Scheduling Vol.1 . Cham: Springer International Publishing,2015. DOI: 10.1007/978-3-319-05443-8.[7] T. H. Cormen, C. Stein, R. L. Rivest, and C. E. Leiserson,
Introductionto Algorithms . McGraw-Hill Higher Education, 2nd ed., 2001.[8] A. B. Kahn, “Topological sorting of large networks,”
Communicationsof the ACM , vol. 5, pp. 558–562, Nov. 1962.[9] R. L. Graham, E. L. Lawler, J. K. Lenstra, and A. H. G. R. Kan,“Optimization and Approximation in Deterministic Sequencing andScheduling: a Survey,”
Annals of Discrete Mathematics , vol. 5, pp. 287–326, Jan. 1979.[10] P. Brucker, A. Drexl, R. M¨ohring, K. Neumann, and E. Pesch,“Resource-constrained project scheduling: Notation, classification, mod-els, and methods,”
European Journal of Operational Research , vol. 112,pp. 3–41, Jan. 1999.[11] C. Artigues, S. Demassey, and E. Neron,