In this question we will investigate using graph searching to design video presentations.
Suppose we represent a node as the term
vp(To_Cover,Segs)where Segs is a list of segments that must be in the presentation, and To_Cover is a list of topics that also must be covered, such that none of the segments in Segs covers any of the topics in To_Cover.
The neighbors of a node are obtained by first selecting a topic from To_Cover. There is a neighbor for each segment that covers the selected topic.
Given that the goal is to design a presentation that covers all of the topics in MustCover, the starting node is vp(MustCover,[]), and the goal nodes are of the form vp([],Presentation). The length of the path from a start node to a goal node the time of the presentation. An optimal presentation is then the shortest presentation that covers all of the topics in MustCover.
Here is the solution. The nodes are expanded according to the circled numbers. The circled (5) is the first goal node found -- this is the shortest presentation that covers all the topics.
Solution #1: For each topic, t, let s(t) be the length of the smallest segment that covers topic t. Let h(vp(TC,Segs)) = maxt in TC s(t). That is, we find the topic t for which s(t) is maximum.
Yes, it satisfies the monotone restriction as the actual distance between any two nodes is the sum of the length of the topics added between the two nodes (the only nodes that have actual distances that those where there is a path from one to the other). The difference between the h-values of the two nodes must be less than the time of the segments added to solve that goal.
Solution #2: For each segment let the contribution of the segment be the time of the segment divided by the number of topics the segment covers. For each topic, t, let s(t) be the smallest contribution for all of the segments that covers the topic. Let h(vp(TC,Segs)) = SUMt in TC s(t). That is, we sum s(t) for all of the topics t in TC.
The intuition is that each topic t requires at least s(t) time. Note that we need to divide by the number of topics the segment covers to make sure that we don't double count the time for segments added that cover multiple topics.
Yes it satisfies the monotone restriction (for similar arguments to those above).
Both of these solution require one pass through the segment database to build the s(t) function, but once this is built, the heuristic function can be computed in time proportional to the length of the To_cover list.
Solution:
remove(E,[E|R],R). remove(E,[H|T],[H|R]) <- remove(E,T,R).
What are all of the answers to the following queries:
Just run this.ask remove(a,[b,a,d,a],R). ask remove(E,[b,a,d,a],R). ask remove(E,L,[b,a,d]). ask remove(p(X),[a,p(a),p(p(a)),p(p(p(a)))],R).
Solution:
subsequence([],[]). subsequence([X|L],[X|R]) <- subsequence(L,R). subsequence(L,[_|R]) <- subsequence(L,R).
How many different proofs are there for each of the following queries:
There are 2 answers to this because the a can either refer to the first a or the second a.ask subsequence([b,a],[b,a,d,a]).
There are C42 solutions, This is the number of way to choose 2 elements from a set of 4. (You are choosing two positions from the set of all positions).ask subsequence([X,Y],[b,a,d,a]).
There are 24 solutions. This is the number of subsets of 4 elements.ask subsequence(S,[b,a,d,a]).
For each of the questions in this assignment, please estimate the amount of time you spent on it. What this a reasonable amount of time for one week in one course?
Solution: Question 1: about 1 hour. Question 2: about 1 hour. Question 3: about 2 minutes. I would expect more difficult assignment for a 3rd-year course.
Last weeks assignment was more difficult, but not unreasonable.