Answers

6.01 Midterm 1
Name:
Fall 2013
Answers
Section Number:
Kerberos (Athena) name:
Section
1:
2:
3:
Design Lab Time
Thursday AM
Thursday PM
Friday PM
Please WAIT until we tell you to begin.
During the exam, you may refer to any written or printed paper material.
You may NOT use a calculator, computer, phone, or music player.
Enter all answers in the boxes provided.
For staff use:
1.
/20
2.
/24
3.
/20
4.
/16
5.
/20
total:
/100
1
6.01 Midterm 1
Fall 2013
1 State and Potatoes (20 Points)
For each of the following systems, state whether it is describable as an LTI system.
• For those systems that are describable as LTI systems, draw a block diagram representing the
system.
• For those that are not describable as LTI systems, define a new subclass of SM representing the
system, defining the startState attribute and getNextValues method appropriately.
Recall that getNextValues(self, state, inp) is a pure function that takes a state and an
input, and returns a tuple containining a new state and an output. getNextValues should not
directly access or modify the internal state of the machine.
1.1 System 1
The output of system1 at time n is the negated sum of the the inputs received at times n − 1, n − 2,
and n − 3.
Can this system be described as an LTI system? (Yes/No)
Yes
If so, draw a representative block diagram in the box below. If not, define a representative subclass
of SM in the box below.
X
R
+
R
R
2
−1
Y
6.01 Midterm 1
Fall 2013
1.2 System 2
The output of system2 is the largest input so far.
Can this system be described as an LTI system? (Yes/No)
No
If so, draw a representative block diagram in the box below. If not, define a representative subclass
of SM in the box below.
class system3(SM):
startState = float(’-inf’)
def getNextValues(self, state, inp):
new = max(state,inp)
return (new, new)
1.3 System 3
The output of system3 is half of the sum of all the inputs so far.
Can this system be described as an LTI system? (Yes/No)
Yes
If so, draw a representative block diagram in the box below. If not, define a representative subclass
of SM in the box below.
X
1
2
+
R
3
Y
6.01 Midterm 1
Fall 2013
1.4 System 4
The output of system4 at time n is 2n , regardless of the input.
Can this system be described as an LTI system? (Yes/No)
No
If so, draw a representative block diagram in the box below. If not, define a representative subclass
of SM in the box below.
class system5(SM):
startState = 0
def getNextValues(self, state, inp):
return (state+1, 2**state)
4
6.01 Midterm 1
Fall 2013
2 Searchin’ Every Which-a-Way (24 Points)
In this problem, we will consider several different strategies and implementations of graph search.
As a point of comparison, consider the following implementation of breadth-first search:
def search(startNode, goalTest, dfs=False):
if goalTest(startNode.state):
return [startNode.state]
else:
agenda = [startNode]
while len(agenda) > 0:
current = agenda.pop(0)
for child in current.getChildren():
if goalTest(child.state):
return child.getPath()
agenda.append(child)
return None
#
#
#
#
#
#
#
#
#
#
#
#
if the starting state satisfies the goal condition,
return the path containing only that state
initialize the agenda to contain the starting node
while there are still nodes to be considered:
pop the first node off the agenda
for each child of the current node:
if the child’s state satisfies the goal condition,
return the path represented by the child node
otherwise, add the child to the agenda
if the agenda is empty, return None
2.1 The Statistician
Having heard of the wonders of probability and statistics, Lem E. Tweakit decides that, instead
of popping items out of the agenda based on the order in which they were added, he is going to
try an algorithm which pops nodes off the agenda in a random order. He first defines a method
popRandomElement(L), which removes a random element from the input list L and returns that
element.
Below is Lem’s code, with changes highlighted in bold:
def search(startNode, goalTest, dfs=False):
if goalTest(startNode.state):
return [startNode.state]
else:
agenda = [startNode]
while len(agenda) > 0:
current = popRandomElement(agenda)
for child in current.getChildren():
if goalTest(child.state):
return child.getPath()
agenda.append(child)
return None
Which of the following best describes Lem’s search routine? Circle one:
Breadth-first Search
Depth-first Search
Something Else
Is Lem’s search guaranteed to find the shortest path from start to goal?
Yes or No:
No
Is Lem’s search guaranteed to terminate in a search domain with finitely-many states?
Yes or No:
No
5
6.01 Midterm 1
Fall 2013
2.2 The Curator
Ben Bitdiddle, curator of the British Museum, also decides to implement his own search function. Ben first defines a function allPaths(startNode, L), which returns a list of instances of
SearchNode representing all possible paths of length L starting from startNode’s state (including
even those paths that repeat states).
Ben makes use of this function to implement his graph search:
def search(startNode, goalTest):
L = 1
while True:
for p in allPaths(startNode, L):
if goalTest(p.state):
return p.getPath()
L += 1
Which of the following best describes Ben’s search routine? Circle one:
Breadth-first Search
Depth-first Search
Something Else
Is Ben’s search guaranteed to find the shortest path from start to goal?
Either*
Yes or No:
Is Ben’s search guaranteed to find a valid path if one exists?
Yes
Yes or No:
Is Ben’s search guaranteed to terminate in a search domain with finitely-many states?
Yes or No:
No
*
Answer depends on interpretation. If a “path of length L” includes L states and L-1 connections,
then the search is guaranteed to return the shortest path. If a “path of length L” instead contains
L connections and L+1 states, then the search is not guaranteed to return the shortest path.
6
6.01 Midterm 1
Fall 2013
2.3 The Professor
The venerable Professor R. E. Cursion (the “R” stands for “R. E. Cursion”) suggests that, “back in
his day,” people thought about search problems differently. He suggests the following alternate
implementation:
def search(currentNode, goalFn):
if goalFn(currentNode.state):
return currentNode.getPath()
else:
for child in currentNode.getChildren():
if child.state not in currentNode.getPath():
result = search(child, goalFn)
if result is not None:
return result
return None
Which of the following best describes this search routine? Circle one:
Breadth-first Search
Depth-first Search
Something Else
Is this search guaranteed to find the shortest path from start to goal?
Yes or No:
No
Is this search guaranteed to find a valid path if one exists?
Yes or No:
No
Is this search guaranteed to terminate in a search domain with finitely-many states?
Yes or No:
Yes
7
6.01 Midterm 1
Fall 2013
3 Dancing Queen (20 Points)
Consider the system described by the following block diagram:
X
+
−
+
R
A
Y
R
B
3.1 Preliminaries
How many poles does this system have?
2
Enter the number of poles:
Will changing the gain A affect the poles of the system?
Yes or No:
No
Will changing the gain A affect the unit sample response of the system?
Yes or No:
Yes
Will changing the gain B affect the poles of the system?
Yes or No:
Yes
Will changing the gain B affect the unit sample response of the system?
Yes or No:
Yes
8
6.01 Midterm 1
Fall 2013
3.2 Responses
The graph below represents the unit-step response S of this system for some particular values of
A and B.
1
s[n]
...
0
0
n
s[0] = 0
s[1] = 1
s[2] = 1
s[3] = 0
s[4] = 0
...
Determine the first 5 samples of the system’s unit-sample response H (for the same values of A
and B) and enter them in the boxes below:
h[0] =
0
h[1] =
1
h[2] =
0
h[3] =
−1
h[4] =
0
For these same values of A and B, what is the magnitude of the dominant pole of the system?
Dominant Pole Magnitude:
1
For these same values of A and B, what are the poles of the system?
Poles:
±j
9
6.01 Midterm 1
Fall 2013
4 On The Right Track (16 Points)
Track:
C
G
A
B --- E
F --- I
--- ----- --------D
H
Two trains are moving along a track with different sections, labeled with letters above. The goal is
to get train 1 to location I and train 2 to location A without causing a collision. Each train occupies
a single labeled section at any given time.
We wish to conduct a search to find a safe path for the trains. We will define our state to be a tuple
containing train 1’s location and train 2’s location, in that order.
The rules for movement are:
• On each timestep, each train may move to any connected segment or stay in the same location.
Note that this means that both trains (or only one, or neither) might move during one timestep.
• The two trains may not occupy the same track at the same time
• The trains may not swap locations (e.g., if train 1 is on section E and train 2 is on section F at
time n, moving train 1 to F and train 2 to E on time n + 1 is not allowed).
Heuristics
Let n1 be the length of the shortest path (in terms of number of segments) from train 1 to state I,
and let n2 be the length of the shortest path from train 2 to state A.
Let e1 be the Euclidean distance in miles from train 1 to track I, and let e2 be the Euclidean distance
from train 2 to track A. These distances are calculated between the center of the track currently
occupied by the train and the center of the goal track. Assume that each segment of track is between
1 and 10 miles long.
Consider the following heuristics when answering the questions on the facing page:
A. e1
B. e1 + e2
C. min(e1 , e2 )
D. n1
E. n1 + n2
F. min(n1 , n2 )
G. max(n1 , n2 )
H. 4n1
10
6.01 Midterm 1
Fall 2013
4.1 Normal
Assume that each step has a cost of 1, regardless of whether zero, one, or both trains move
during that step.
Under this cost model, which of the heuristics above are admissible on an arbitary track layout
(not only the configuration shown above)? Enter their associated letters in the box below, or enter
None if none of the heuristics are admissible.
Letters, or None:
D, F, G
Which heuristic would be likely to reduce the number of expanded states most effectively (across
all possible track layouts), while retaining the guarantee that the path returned is optimal?
Enter a single letter:
G
4.2 Calculated Risk
Now assume that the two trains can share a track segment if they go really slowly. Since this is a
risky procedure, any transition to such a state has a cost of 4 (all other costs are the same as above).
Under this cost model, which of the heuristics above are admissible on an arbitary track layout
(not only the configuration shown above)? Enter their associated letters in the box below, or enter
None if none of the heuristics are admissible.
Letters, or None:
D, F, G
4.3 Eat Fresh
Now assume that the city adds some tracks that are underground. These tracks can be maintained
better, so the trains can move extra fast on them, so any transition to a state with at least one train
on an underground track costs 0.5 (all other costs are the same as above).
Under this cost model, which of the heuristics above are admissible on an arbitary track layout
(not only the configuration shown above)? Enter their associated letters in the box below, or enter
None if none of the heuristics are admissible.
Letters, or None:
None
11
6.01 Midterm 1
Fall 2013
5 Back in the USR (20 Points)
Consider the system described by the following difference equation
8y[n] − 6y[n − 1] + y[n − 2] = x[n]
where x[n] and y[n] represent the nth samples of the input and output signal, respectively.
5.1 Samples
Recall that the unit sample response of a system is the output y[n] when the input is the unit
sample signal (x[n] = δ[n]). Determine the first 3 samples of the unit-sample response of the
system described above.
y[0] =
1
8
y[1] =
3
32
y[2] =
7
128
5.2 Closed Form
The unit sample response of this system can be represented by a closed-form expression of the
form:
y[n] = a · bn + c · dn + f · gn + . . .
for all n > 0.
Enter a number in each box below to complete the expression. If more boxes are given than are
required, enter None in the extra boxes.
y[n] =
1
4
·
1
2
n
+
− 18
·
1
4
n
for all n > 0.
12
+
None · None
n
+
None · None
n