Download presentation

Presentation is loading. Please wait.

Published byJeremiah Peterkin Modified over 2 years ago

1
SWS: Group 4 Laurence Cabenda, Niels Reyngoud, Roy van den Broek

2
Problem Find a generic specification for graph problems like “shortest path” and “highest path” Give the abstract specification Embed concrete problems into this specification We assume that we have a start and an end node

3
Given: Some type Node Some type D :: (Path, L) Path :: Sequence(Node x Node) L = R U { } : absorbing element of L Example: When adding real numbers, is the absorbing element

4
Given: We stepped away from last weeks representation with the operators defined on a type D : L -> L -> L Combining the values of two sequential paths : L -> L -> L Choosing the best value out of the values of two parallel paths Both are commutative and associative

5
Input: Sequence S {0…n-1} -> Node Function f: Node x Node -> L Returns the value of the arc between two nodes Gives back when there’s no direct arc between two nodes Node start, end, such that start end

6
Output: (solution_path, solution_value) :: D

7
Intermezzo: All possible paths We need to have a notion of all possible paths P is the set of all possible paths P = P seq (all 2_tuplepermutations of S )

8
Intermezzo: All possible paths 2_tuplepermutations {1,2,3} -> {(1,2),(1,3),(2,1),(2,3),(3,1),(3,2)} Analog to k_permutations of a set, k_permutations gives a set of sets k_tuplepermutations gives a set of tuples

9
Intermezzo: All possible paths P seq (powersequence) {(1,2),(1,3),(2,1),(2,3),(3,1),(3,2)} -> { [(1,2)], [(1,2),(1,3)], [(1,2),(1,3),(2,3)], [(1,3),(1,2)], … } Analog to powerset of a set powerset gives a set of sets powersequences gives a set of sequences

10
Intermezzo: All possible paths New problem: not all of these paths are valid (e.g. of the form (a,b), (b,c), … ) A path P with length n is valid if: i {0..n-2} : f(fst(P[i]), snd(P[i])) snd(p[i]) = fst(P[i+1])

11
Another helper function We assume a function exists that calculates the value of a path. value could be defined as: value [] = 0 value (a,b) = f(a,b) value (a,b):rest = f(a,b) value(rest)

12
Such that: solution_path must be valid: valid solution_path solution_path should have the correct start and finish nodes first(head(solution_path)) = start second(last(solution_path)) = end solution_value must be equal to the value of solution_path solution_value = value (solution_path)

13
Such that: And most important ;-): (solution_path, solution_value) is the best possible solution: (pospath, posval = value (pospad)) : pospath P : (valid pospath /\ fst (head (pospath)) = s /\ snd (last (pospath)) = e ) -> solution_value posval = solution_value

14
Embedding shortest path Shortest path: should be defined as should be defined as + should be defined as The generic operators in valid, value and the notion of best path now become concrete

15
Embedding highest path Highest path: should be defined as 0 should be defined as should be defined as

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google