Skip to content

Algorithm

Edds edited this page Aug 13, 2017 · 18 revisions

We decided to use the A* algorithm to produce optimal solutions for task graphs up to 20 nodes. It is a best first state space search algorithm, that reduces the state space search by our implemented cost function and clipping techniques.

Description and details of the algorithm used and its implementation.

Heuristics

The A* algorithm relies on priority queues to determine which partial solutions to visit next in the total state space of partial solutions. In determining the priority for each partial solution, heuristics are used. Heuristics are essentially underestimates of the current partial solution - that is, given the current partial solution, all partial or full solutions that can be generated from that current partial solution is guaranteed to have a total cost that is greater than that underestimate.

There are several cost functions the algorithm uses to determine a partial solution's underestimate: idle time, bottom level, and parent's underestimate. Each heuristic outperforms its peers based on the type of the input graph. Naturally, the best underestimate is the highest underestimate - if one cost function guarantees the cost function to be at least 5 seconds, and another cost function guarantees 8 seconds, then the first cost function is implied by the second. Thus, the algorithm's candidate heuristic is Max(all heuristics).

Bottom Level

The bottom level heuristic of each node calculates the longest path from the selected node. This helps provide an underestimate for the length of the schedule. Thus, all full schedules that can be generated from a partial schedule must be at least as great as the maximum time to get to a leaf. The calculation only takes into consideration all the weights of the nodes in the path, ignoring the edge weights.

The bottom level is calculated once and once only, prior to the generation of the partial solutions. This is because the bottom level for each node is specific to that node, and remains static throughout the generation of partial solutions. Thus, after calculation, it is cached in a hashmap and is referenced throughout the partial schedule generation in O(1) time.

Implementation

The bottom level cache is generated by using a queue, with the leaves of the graph being queued first. The bottom level for a node is calculated by SUM(MAX(Bottom level of all children)+self.weight). Because the leaves have no children, their bottom level weights are their weights themselves. Every time a node's bottom level is added to the cache, it checks that node's parents and sees if all of that parent's children's bottom level is already in the cache. If it is true, then it adds the parent to the queue. In this way, the queue moves up the tree towards the root/s.

Idle Time

The idle time heuristic takes into account the amount of time being wasted by a processor in a partial solution.

Parent's Underestimate

The parent's underestimate acts as a guarding heuristic against the other heuristics. This guarding property is arises as the parent's underestimate guarantees the children's underestimates to be at least as large as the parent's underestimate.

Clone this wiki locally