| 6.170 | Laboratory in Software Engineering
Spring 2001 6.170 Problem Set 5: Abstract Reasoning, Object Models and Graph Building Due: Monday, March 19, 2001 at 5pm |
Quick links:
Contents:
Abstract reasoning is important throughout all stages of developing a software system. Thus this problem set starts off with some development of your ability to reason abstractly about the properties of the code you write.
Object models are one method for visualizing a design, which can help you to spot design flaws. In this problem set, you will get experience working with object models, and then you will analyze the MapQuick problem using object models.
Finally, you will think ahead about MapQuick's graph-building algorithm.
This problem set involves drawing several object models. Microsoft Visio (Windows only) and Dia (Athena, Solaris and Linux only) are programs which can be used for drawing such models and are available for your use. See the tools handout for details.
You are not, however, required to use computerized drawing packages for your diagrams; if you prefer, you may draw your models by hand and submit those diagrams hard-copy-only. If you do so, be sure to note this with the rest of your electronic turnin, and make your diagrams neat and easy to read.
For electronic submissions, use plain text for written solutions and PDF format for diagrams. We will not accept Visio or Dia files. Recall that distill (in the acro locker) converts PostScript files to PDF. Recall also that your Manifest file must list all files that you wish to submit. Any files not listed will not be considered for grading.
You may submit diagram PDF files either in one file per problem, named problem3.pdf, for instance, or you may submit them in separate files for each part, with an appropriate filename such as problem3.2a.pdf. Either way, note the location of each diagram in your plain text file.
In Problem Set 3, you specified and implemented a generic graph abstraction. Now write an abstraction function and a representation invariant for your graph ADT. Ensure that your overview and specfields correspond to a graph abstraction and not your implementation. If this is not the case first correct your graph specification. Make these changes directly in your ps3/Graph.java file. It should be listed in your Manifest file as ../ps3/Graph.java.
Using the abstraction function and representation invariant, answer the following questions in problem1.txt.
Consider the abstract data type outlined in IntegerSet.java.
Place answers to parts (b) and (c) in problem2.txt.
The exercises of this first part are intended to help you become familiar with the basic notions of object models, and to develop your understanding of how to pick appropriate abstractions for modeling a particular problem. Place your written solutions in problem3.txt. You will consider some rather abstract models for graphs and apply them to some concrete problems. All models you construct for this problem should be problem object models, not code object models.
Here are four object models that describe graphs.
Graph 1:
This model has a single domain, Node, representing the nodes of the graph, and a single relation adj that maps each node to the nodes it is adjacent to.
Graph 2:
This model has a second domain, Link, that represents the links between nodes; there is a single relation nodes that associates a link with the nodes it connect.
Graph 3:
This model is a variant that replaces the single relation with two relations.
Graph 4:
This model adds a domain, End, that represents the ends of a link. There are two relations, source and target, that map a link respectively to its source and target ends, and a relation node that associates an end with the node that it sits on.
These four models are not equivalent; they allow different kinds of graph to be described.
Suppose you want to model how an email client stores messages in folders. The folder structure can be viewed as a graph, with an edge from a folder or message to the folder that contains it.
Now consider a classification where Folder and Message are both subdomains of Email Object, where email objects in turn can be stored in folders.
Suppose you want to model the topology of a network in which there are host machines with undirected links among hosts, and that an important concern is the bandwidth of the links.
Suppose you are designing a new diagramming tool, and you want to model the kinds of diagram that are to be produced. Diagrams are constructed from components, namely boxes and arrows, which can optionally be labelled. An arrow must be connected to a box at each end, and can be labelled in the middle and at each end. Components can be grouped; groups may carry labels and can themselves be grouped.
Develop a Problem Object Model for MapQuick. You must use the following domains in your model: Length, Angle, Location, Path, Street, Number, Zip-code, Address, and Name. You may add other domains as you see fit. Be careful not to develop a Code Object Model; the goal is to understand the abstract problem domain.
For each of the domains (those provided and those you add) and each of the relations among them, write a textual description describing its role in the model. Your model should also include textual descriptions of constraints that cannot be expressed graphically. Submit your written solution in problem4.txt.
In Problem Set 6, you will build a graph-based representation of the streets in the MapQuick database.
Consider the following pseudo-code to build such a graph from a collection of StreetSegments:
for each segment s in the collection of segments
s_r <- reverse of s
add s to the set of nodes
add s_r to the set of nodes
for each segment s in the set of nodes
for each segment s' in the set of nodes
if s.p2 = s'.p1
add an edge from s to s'
else if s.p1 = s'.p2
add an edge from s' to s
Note: We are ignoring the issue of one-way streets. Thus, we are assuming that all street segments in the database allow bidirectional travel and are therefore placing both a segment and its reverse in the set of nodes.
Unfortunately, this algorithm requires quadratic time in the number of segments. For MapQuick, this is unacceptable due to the large number of segments in the database.
Give a more efficient algorithm to build the graph. Your algorithm should run in time O(n*outDegree) where n is the number of segments and outDegree is the maximum number of segments a single segment connects to. Describe your algorithm in problem5.txt and argue that it meets the specified time bound.
Feel free to use pseudo-code and to introduce auxiliary data structures or helper procedures as necessary.
This section will list clarifications and answers to common questions about problem sets.
This section details the changes made since the handout was posted to the website. You may use the version number at the bottom of your hardcopy to determine what has changed since you printed this handout.
| revision 1.34: | Updated Problem 1b to clarify that we're talking about two concrete states of your implementation. Also added Q & A section. |
| revision 1.32: | Stated explicitly that Problem 3 refers to problem object models, not code object models. |
| revision 1.31: |
Changed ps3/Graph.java turnin method. See Problem 1.
Moved IntegerSet.java out to its own file. Created a starter Manifest file. Also added point distributions. |