Ass 2
Ass 2
Learning Outcomes
In this project you will demonstrate your understanding of structures and arrays of structures, and will
develop a computational solution for a non-trivial problem. You are expected to make extensive use of
functions; and to demonstrate that you have adopted a clear and elegant programming style. You will find
it difficult to create a working solution unless you plan your program carefully in advance, and develop
it incrementally.
where name is a letter that identifies the shopping center; xloc and yloc are the (x, y) locations in
kilometers of a shopping center relative to the center of the city; glam is its glamour score, a measurement
of the attractiveness of that shopping center, see below; and carp is a measure of the difficulty of getting
a carpark at that shopping center. The city has as many as fifty different shopping centers.
To obtain full marks you need to exactly reproduce the required output lines. Full examples can be found
on the FAQ page linked from the LMS. The input provided to your program will always be sensible and
correct, and you do not need to perform any data validation.
1
Stage 2 – Walking a Grid (marks up to 16/20)
The relative attractiveness of a shopping center to a resident of the city is determined by
glamour
RA = ,
distance + carpark
where distance is how far that person lives from the shopping center, calculated in kilometers based
on Euclidean straight-line travel (we might also consider using rectilinear distances if the road network
contains roads that only run north-south and east-west, but that is for another day).
Suppose that each resident always goes to the shopping center that has the greatest RA value, based
on where they live. So shopping centers that have higher glamour scores tend to draw people from
suburbs that might actually be closer to a less glamorous shopping center. People are also prepared to
drive further if the car parking is easier. For example, in malls1.tsv shopping center f is reasonably
glamorous, but its carparking situation is not so good.
No resident will go to any shopping center if its RA is below 1.0 at their address. This may mean
that some residents can’t go shopping, and have to rely on deliveries. Your program is intended to help
identify the business opportunities that these “no shopping nearby” spots create.
Suppose that the city stretches across a square range defined by x ∈ [−25.0, +25.0] kilometers and
y ∈ [−25.0, +25.0] kilometers, and that we wish to compute the “attraction zone” of each shopping
center as a percentage of the total space occupied by the city (which is 2500 square kilometers).
To do this, we split the city into 0.1 × 0.1 kilometer grid cells (that is, a grid containing 500 × 500 =
250,000 cells), and compute the preferred shopping center at the midpoint of each such cell. For example,
the south-west cell spans the area [−25.0, −24.9]×[−25.0, −24.9], and is represented by its central point
at (−24.95, −24.95). By computing a RA value for each known shopping center at that point, we can
determine which shopping center that point is attracted to, and then count that whole grid cell as going to
the same center. This will then give an approximation of the desired percentage attraction; if we wanted
to, we could decrease the edge size of each grid cell to get a more precise estimate.
The required output from your program from this stage for malls1.tsv is:
2
S3, +--------------------------------------------------+
S3, 24.0km | fffffffffffffff |
S3, 22.0km | fffffffffffffffffff |
S3, 20.0km | fffffffffffffffffffff |
S3, 18.0km | fffffffffffffffffffffff |
S3, 16.0km | fffffffffffffffffffffff |
S3, 14.0km | iiiiiii fffffffffffffffffffffuuuuuuuu |
S3, 12.0km | iiiiiiiiiiiiiiiiffffffffffffffffffuuuuuuuuuuu|
S3, 10.0km | iiiiiiiiiiiiiiiiiiiifffffffffffffffuuuuuuuuuuuuu|
S3, 8.0km | iiiiiiiiiiiiiiiiiiiiiiifffffffffffuuuuuuuuuuuuuuu|
S3, 6.0km |iiiiiiiiiiiiiiiiiiiiiiiiyyyyfffffuuuuuuuuuuuuuuuuu|
S3, 4.0km |iiiiiiiiiiiiiiiiiiiiiiiyyyyyyyyuuuuuuuuuuuuuuuuuuu|
S3, 2.0km |iiiiiiiiiiiiiiiiiiiiiiyyyyyyyyyyuuuuuuuuuuuuuuuuuu|
S3, 0.0km |iiiiiiiiiiiiiiiiiiiiiiyyyyyyyyyyuuuuuuuuuuuuuuuuuu|
S3, -2.0km |iiiiiiiiiiiiiiiiiiiiiiyyyyyyyyyyyuuuuuuuuuuuuuuuuu|
S3, -4.0km |iiiiiiiiiiiiiiiiinniiiiyyyyyyyyyyuuuuuuuuuuuuuuuuu|
S3, -6.0km |iiiiiiiiiiiiiinnnnnnnniiyyyyyyyy uuuuuuuuuuuuuuuu|
S3, -8.0km |iiiiiiiiiiiiiinnnnnnnniiiiiyy uuuuuuuuuuu |
S3, -10.0km |iiiiiiiiiiiiiinnnnnnnniiiii |
S3, -12.0km | iiiiiiiiiiiiiiinnnnniiiii |
S3, -14.0km | iiiiiiiiiiiiiiiiiii |
S3, -16.0km | iiiiiiiiiiiii |
S3, -18.0km | |
S3, -20.0km | |
S3, -22.0km | |
S3, -24.0km | |
S3, +--------------------------------------------------+
Figure 1: The required Stage 3 output.
“blank out” any cells in the map that have the same label as all of their eight neighboring cells – see the
Assignment video for details of this requirement. Now the map looks like Figure 2.
3
S4, +--------------------------------------------------+
S4, 24.0km | fffffffffffffff |
S4, 22.0km | fff fff |
S4, 20.0km | ff ff |
S4, 18.0km | ff ff |
S4, 16.0km | f fff |
S4, 14.0km | iiiiiii ff fffuuuuuuuu |
S4, 12.0km | iiiiii iiiiiff fffuuu uu|
S4, 10.0km | iiii iifff fffuuu u|
S4, 8.0km | ii iiifffff fffuuu u|
S4, 6.0km |ii iiyyyyfffffuuu u|
S4, 4.0km |i iiyy yyyyuuu u|
S4, 2.0km |i iyy yyu u|
S4, 0.0km |i iy yuu u|
S4, -2.0km |i iiii iyy yyu u|
S4, -4.0km |i iiiinniiiiyy yyuu u|
S4, -6.0km |i innnnnnnniiyyyyyyyy uuuu uuu|
S4, -8.0km |i in niiiiiyy uuuuuuuuuuu |
S4, -10.0km |ii innn nni ii |
S4, -12.0km | iiii iiinnnnniiiii |
S4, -14.0km | iiii iiiiiiii |
S4, -16.0km | iiiiiiiiiiiii |
S4, -18.0km | |
S4, -20.0km | |
S4, -22.0km | |
S4, -24.0km | |
S4, +--------------------------------------------------+
Figure 2: The required Stage 4 output.
Marking Rubric: A rubric explaining the marking expectations is linked from the assignment’s LMS,
and you should study that rubric very closely. Feedback, marks, and a sample solution will be made
available approximately two weeks after submissions close.
Academic Honesty: You may discuss your work during your workshop, and with others in the class,
but what gets typed into your program must be individual work, not copied from anyone else, and not
developed jointly with anyone else. So, do not give hard copy or soft copy of your work to anyone else;
do not “lend” your “Uni backup” memory stick to others for any reason at all; and do not ask others to
give you their programs “just so that I can take a look and get some ideas, I won’t copy, honest”. The best
way to help your friends in this regard is to say a very firm “no” if they ask to see your program, pointing
out that your “no”, and their acceptance of that decision, are the only way to preserve your friendship. See
https://academicintegrity.unimelb.edu.au for more information. Note also that solicitation of
solutions via posts to “tutoring” sites or online forums, whether or not there is payment involved, and
whether or or not you actually employ any solutions that may result, is also serious misconduct. In the
past students have had their enrolment terminated for such behavior.
The LMS page links to a program skeleton that includes an Authorship Declaration that you must
“sign” and date and include at the top of your submitted program. Marks will be deducted (see the
rubric linked from the LMS page) if you do not include the declaration, or do not sign it, or do not
comply with its expectations. A sophisticated program that undertakes deep structural analysis of C
code identifying regions of similarity will be run over all submissions. Students whose programs are
identified as containing significant overlaps will have substantial mark penalties applied, or be
referred to the Student Center for possible disciplinary action, without further warning.