Recitation 8
Recitation notes for the week of March 12, 2025.
This recitation we will essentially go over the material from the project page. The material on Problem 2 are just copied over from the project page. Discussion on reflection problem 2 is also mostly copied over from the reflections page, though there is some new material here.
Reminders
There are quite a few moving parts in the project and so it is easy to forget the numerous reminders and suggestions, so we collect those here again for your reference.
Groups should agree on one programming language
While the submission for the coding problems in this project can be done in any of C++,Java
and Python
like in Question 3s on the homework, we highly recommend that the group agrees on one programming language for the group. This will make it much easier for your group to make progress and collaborate.
The same group for ALL problems
You are expected to work in the same group for ALL problems in the coding project. Not doing so will be considered to be an academic integrity violation. Please note that you will have to sign up your group separately for each problem on Autolab and we will check for group consistency at the end of the semester. So please make sure you follow this rule.
There is ONE exception to the above rule: It is OK if the group becomes smaller (e.g. if a group member resigns) but in that case another student cannot be added to group. If you need clarification on this, please get in touch with your instructor.
There are no optimal algorithms known!
Other than the first problem, we do not know of optimal algorithms to solve the rest of the problems and we suspect that doing so is not possible (definitely not within a semester). Note that this is unlike the HW Q3s where your code is supposed to always output the optimal/correct solution: i.e. you will have to think of algorithms where you might not be able to prove any guarantee on how good your output is.
Start early!
There is a reason we are giving you about two months to do this project. If your group starts even the week before the project is due, your group will be in trouble especially beyond the first problem. Also for most problems you will have to think of algorithms beyond what we cover in class, so the more time your spend on this, the better.
Optimizing the runtime of your code is NOT the main objective
Unlike the HW Q3s, there will be no timeouts for individual inputs (though there will be one overall per submission). This is because unlike the HW Q3s, the main goal in this coding project submissions will be to generate as much "revenue" as possible (read on for more details on this)-- optimizing the runtime would/should be a secondary object but again there is an overall timeout so really inefficient implementations (and definitely not polynomial runtime algorithms) will not make the cut.
Problem 2
Input
The input for the problem is the same as the previous one except for the bandwidth being limited and the tolerance threshold for every client being an arbitrary value greater than or equal to $1$. To put it formally, following is the input:
- $G = (V, E)$
- $i \in V$
- $C$ s.t. $C \subseteq V \setminus \{i\}$
- For all $u \in V \setminus \{i\}$, $b_u$ s.t. $b_u < \infty$
- For all $c \in C$, $\alpha_c$ s.t. $\alpha_c \ge 1$
- For all $c \in C$, $\text{pmt}_c$
- For all $c \in C$, $\text{priority(c)} =$ PRIORITY_DEFAULT
Note
The highlighted input, is the part of the input that is different from the previous problem.
Output
Now given these real-world limitations, you should come up with an algorithm that generates $i-c$ paths for each client $c \in C$, in a way that contributes towards achieving the objective. Just like Problem 1, you should output a list of $i-c$ paths for all $c \in C$. That is, you need to output:
- $L_{P'}$ which is a list of $P'_c$'s for all $c \in C$
Objective
Same as Problem 1.
Example 2
A Solution
If the graph $G$ for this problem is our graph from Example 0, then here is a valid output:



Note
The $\alpha$ values given above will be used in the example graph for the remaining problems also (except for a small change to $\alpha_3$ in Problem 5).
That is, the output $L_{P'} = [P'_1,P'_3,P'_6,P'_7,P'_8]$. Where, $P'_1 = [0,10,1], P'_3 = [0,10,1,2,3], P'_6 = [0,10,1,5,6], P'_7 = [0,10,1,4,7], P'_8 = [0,9,3,8]$.
We will consider the paths given above to compute the penalties for each client. So for path $1$, $\alpha_1\cdot d(1)$ is $1 \cdot 2$, which is $2$. Next we compare that to our $D(P’_1)$, by finding the number of edges in each path and making sure that there is enough bandwidth to transfer packets each tick. If our $D(P’_c)$ is less than or equal to $\alpha_c\cdot d(c)$ value we receive no penalty. For notational convenience (in our worked out calculation below), if $D(P’_c) \leq \alpha_c \cdot d(c)$ we say “accept”, else “reject”.
Total Revenue
We claim that the revenue generated from the above solution is $\$155$ while the solution from Example 1 will generate a total revenue of $\$110$ for this input. See below for more details
Determining $D(P')$ for every client
We claim that: $D(P’_1) = 2, D(P’_3) = 4, D(P’_6) = 4, D(P’_7) = 4, D(P’_8) = 3$. We verify this by tracing each time step in the routing simulation:
At Time Tick $0$:
Current: All packets at 0.
Passed on: All
At Time Tick $1$:
Current:
- $\text{pkt}_1$ at node $10$
- $\text{pkt}_3$ at node $10$
- $\text{pkt}_6$ at node $10$
- $\text{pkt}_7$ at node $10$
- $\text{pkt}_8$ at node $9$
Passed on: All
At Time Tick $2$:
Current:
- $\text{pkt}_1$ at node $1$
- $\text{pkt}_3$ at node $1$
- $\text{pkt}_6$ at node $1$
- $\text{pkt}_7$ at node $1$
- $\text{pkt}_8$ at node $3$
Reached: $\text{pkt}_1$
Passed on: $\text{pkt}_3, \text{pkt}_6, \text{pkt}_7,\text{pkt}_8$
At Time Tick $3$:
Current:
- $\text{pkt}_3$ at node $2$
- $\text{pkt}_6$ at node $5$
- $\text{pkt}_7$ at node $4$
- $\text{pkt}_8$ at node $8$
Reached: $\text{pkt}_8$
Passed on: $\text{pkt}_3, \text{pkt}_6, \text{pkt}_7$
At Time Tick $4$:
Current:
- $\text{pkt}_3$ at node $3$
- $\text{pkt}_6$ at node $6$
- $\text{pkt}_7$ at node $7$
Reached: All packets have reached their destination so routing terminates.
Determining Penalty and Calculating total revenue
Now lets see what $pen_0$ function outputs for each client:
- $pen_0(1) = 0$
- $D(P’_1) = 2 , d(1) \cdot \alpha_1 = 2, 2 \leq 2$, so accept
- $pen_0(3) = 0$
- $D(P’_3) = 4 , d(3) \cdot \alpha_3 = 8, 4 \leq 8$, so accept
- $pen_0(6) = 35$
- $D(P’_6) = 4 , d(6) \cdot \alpha_6 = 3, 4 > 3$, so reject
- $pen_0(7) = 0$
- $D(P’_7) = 4 , d(7) \cdot \alpha_7 = 4, 4 \leq 4$, so accept
- $pen_0(8) = 0$
- $D(P’_8) = 3 , d(8) \cdot \alpha_8 = 3, 3 \leq 3$, so accept
Our total revenue is calculated by subtracting the summation of all penalties from our total possible revenue.
Total revenue $= 190 - 35 = 155$
Example 1 solution
The solution to Problem 1 is a worse solution for this problem. We will go through the calculations to see what total revenue generated by using Example 1's solution for this problem.
Solution to Example 1



In the above picture we use Example 1's solution to solve this problem. Now we will see, why this solution is worse for this problem.
Determining $D(P')$ for every client
We claim that: $D(P’_1) = 2, D(P’_3) = 2, D(P’_6) =4, D(P’_7) = 4, D(P’_8) = 5$. Let's now trace each time tick in the routing simulation:
At Time Tick $0$:
Current: All packets at 0.
Passed on: All
At Time Tick $1$:
Current:
- $\text{pkt}_1$ at node $10$
- $\text{pkt}_3$ at node $9$
- $\text{pkt}_6$ at node $9$
- $\text{pkt}_7$ at node $10$
- $\text{pkt}_8$ at node $9$
Passed on: $\text{pkt}_1, \text{pkt}_3, \text{pkt}_7$
Delayed: $\text{pkt}_6, \text{pkt}_8$
At Time Tick $2$:
Current:
- $\text{pkt}_1$ at node $1$
- $\text{pkt}_3$ at node $3$
- $\text{pkt}_6$ at node $9$
- $\text{pkt}_7$ at node $1$
- $\text{pkt}_8$ at node $9$
Reached: $\text{pkt}_1, \text{pkt}_3$
Passed on: $\text{pkt}_6, \text{pkt}_7$
Delayed: $\text{pkt}_8$
At Time Tick $3$:
Current:
- $\text{pkt}_6$ at node $3$
- $\text{pkt}_7$ at node $4$
- $\text{pkt}_8$ at node $9$
Passed on: $\text{pkt}_6, \text{pkt}_7, \text{pkt}_8$
At Time Tick $4$:
Current:
- $\text{pkt}_6$ at node $6$
- $\text{pkt}_7$ at node $7$
- $\text{pkt}_8$ at node $3$
Reached: $\text{pkt}_6, \text{pkt}_7$
Passed on: $\text{pkt}_8$
At Time Tick $5$:
Current:
- $\text{pkt}_8$ at node $8$
Reached: $\text{pkt}_8$
NOTE:
Some of the $D(P'_c)$ values have changed from the previous solution due to bandwidth restrictions.
Determining Penalty and Calculating total revenue
Now let us see what $pen_0$ function outputs for each client:
- $pen_0(1) = 0$
- $D(P’_1) = 2 , d(1) \cdot \alpha_1 = 2, 2 \leq 2$, so accept
- $pen_0(3) = 0$
- $D(P’_3) = 2 , d(3) \cdot \alpha_3 = 8, 2 \leq 8$, so accept
- $pen_0(6) = 35$
- $D(P’_6) = 4 , d(6) \cdot \alpha_6 = 3, 4 > 3$, so reject
- $pen_0(7) = 0$
- $D(P’_7) = 4 , d(7) \cdot \alpha_7 = 4, 4 \leq 4$, so accept
- $pen_0(8) = 45$
- $D(P’_8) = 5 , d(8) \cdot \alpha_8 = 3, 5 > 3$, so reject
So the total revenue $ = \$190 - (\$35 + \$45) = \$110$. Hence, this is definitely worse than the previous solution for this problem.
Reflection Problem 2
Important reminders about reflection questions
There is no "right" or "wrong" answer
Perhaps the biggest difference from other CSE 331 questions (both programming and proof based questions) is that pretty no much no answer is "right" or "wrong" in any absolute sense. You will notice that for some of the questions, the answer might depend on some of the assumptions you make and in many cases the answer would really depend on who is answering the question. While ambiguity might feel a bit disquieting, the ambiguity is inherent for these kinds of questions: so embrace the ambiguity!
More specifically, do not waste your time trying to figure out what we are expecting from an answer-- because we do not have any set answer that we are looking for! What we are interested is in hearing your group's thoughts on the questions. In particular, even if we disagree with your justification, that does NOT mean you will get penalized. Again there is no "right" or "wrong" answer!
The justifications do not have to be long
While it might seem like there are a lot of questions, please note that we are not expecting really long details justifications. In most cases a couple of sentences or a paragraph would suffice. To give a sense of the amount of detail expected, think of the level of detail to be on the lines of what is expected of you in a proof idea. So we only want to read about the main ideas behind your justification.
A useful resource
For the specific reflection questions, we will be quoting from Cathy O'Neil and Hanna Gunn's book chapter titled Near-Term Artificial Intelligence and the Ethical Matrix .
You can access the book chapter as a PDF from UB Libraries .
While the book is about ethical issues in AI, the concepts in the book chapter are applicable more widely and in particular, for our project (that does not have anything to do with AI).
The actual questions
Your Task
Listed below are four questions. The first question is to present the algorithm idea of the code that you submitted for the second coding problem. For the rest of the questions, you group has to answer each question and justify your answers.
Now that you’ve had a chance to think about your design, reflect on how your algorithm works for your stakeholders and which stakeholders it performs best for. Ideally, everyone on your network would receive the same services consistently, but in actuality this is difficult to realize.
In their book chapter, O’Neil and Gunn suggest bringing stakeholders into the room and asking for their desired outcomes and concerns. However, in this situation, we will assume the ForProfitOnly
company you work for is not interested in hosting this conversation. Thus, as the software designer you are tasked with imagining what your stakeholders need and designing your algorithm to meet as many of those needs as possible.
As O’Neil and Gunn argue, design decisions are often also moral decisions (250). If your algorithm works well for customers in urban areas, but not rural ones, then you’ve made a decision to supply rural residents with systemically slower internet. This decision raises an ethical question of fairness. Unfortunately, there is no current industry standard for defining fairness in algorithmic design. So, for this assignment, we are using O’Neil and Gunn’s definition in their book chapter. O’Neil and Gunn argue that “fair institutions and policies can be understood as those that are not significantly responsive to arbitrary differences between individuals and that do not disadvantage those whom we already recognize as being disadvantaged” (253). Thus, in our earlier example, an algorithm that works well for urban customers, but not rural ones, would privilege urban customers.
We should note that fairness is not binary. You cannot simply assess a complex system as being completely fair or completely unfair. Fairness exists on a spectrum and changes depending on which stakeholders we are concerned with. So, if you answer question four below by simply stating “my algorithm is fair/unfair,” you will not receive full credit.
For this reflection, please answer these questions:
Algorithm Idea (2 points)
In one paragraph, state the algorithm idea behind the code that you submitted for the second coding problem. This would be similar to a usual algorithm idea submission in a homework.
Whom does your algorithm work best for? (2 points)
What clients does your algorithm try to make their $pen_0$ value to be $0$? I.e. for which clients $c$ does your algorithm try to make sure to try get the $\text{pmt}_c$ revenue from them? Show how your answer follows from the algorithm idea above.
Whom doesn’t your algorithm work well for? (2 points)
What clients does your algorithm not try (actively) to make their $pen_0$ value to be $0$? I.e. for which clients $c$ does your algorithm not mind to get a revenue of $c$ from them? Show how your answer follows from the algorithm idea above.
How fair is your algorithm? (4 points)
How fair was the decision that your group made in the algorithm design to favor one group of customers (those identified in the second question above) over another (those identified in the third question above? Justify your answer.
If some of your customers are not as well served as others, are there ways for you to address this unfairness that might result in a more ethical distribution of services?
Preliminary Grading Guidelines
Below is a preliminary instantiation of the generic grading rubric above for (the last three questions) on Problem 2. (The Algorithm Idea part will be graded similarly to algorithm ideas in homework submissions.) In actual grading, we will use a grading rubric that expands on the preliminary grading rubric below.
- Level 0.
- The authors did not answer all reflective questions; OR
- Answers may not be entirely relevant to the assignment.
- Level 1.
- The authors answers all reflective questions, although the responses are underdeveloped; AND
- (For the 2nd and 3rd questions) Authors have identified un/favored users/stakeholders, but have either missed a stakeholder who should have been identified as either favored or unfavored OR have given little justification for their assessment.
- (For the 4th question) The authors clearly understand the questions, but have not demonstrated much effort in thinking through the connection between their algorithm and fairness to stakeholders. Answers may seem perfunctory.
- Level 2.
- The authors answer all reflective questions thoroughly and thoughtfully; AND
- (For the 2nd and 3rd questions) The authors clearly demonstrate their grasp of the questions and their algorithm’s potential to favor some users/stakeholders interests over others.
- (For the 4th question) Outside sources— i.e. O’Neil and/or Gunn’s definition of fairness (or parts of their definitions)—are directly referenced in responses. Authors have clearly connected these sources to their own designs.
A sample solution
To get you started on the above reflection as well as give a sense for how the preliminary rubric would be applied, we present solutions for each of the four questions. (Note that other than the fourth questions, we present only solutions for one level).
Algorithm Idea (2 points)
Level 1 solution
All clients with an odd index $c$ are routed in a way so that their paths share as many edges as possible. On the other hand the rest of the clients (i.e. those with an even index $c$) are routed in a way so that their paths share as few edges as possible (with paths of all clients).
The above solution is level 1 since there is no indication as to show for odd index client the algorithm will ensure that "their paths share as many edges as possible" (similar issue with even index clients and "their paths share as few edges as possible").
No guarantees that the above idea works
Just to make sure there is no confusion: the above algorithm idea is for illustrative purposes ONLY. The idea most likely will not work on the actual testcases on Autolab but we cannot say for sure since we have not implemented this idea. So if you want to try out the above idea, do as at your own risk!
Whom does your algorithm work best for? (2 points)
Level 2 solution
The algorithm works best for clients with even indices. This is because since they share as few edges as possible with any other path, this means in the routing algorithm, there will be fewer "bottlenecks", which means their routing delay would be closer to their minimum path delay. This by definition of $pen_0$ implies that the penalties for clients with even indices would more likely be $0$.
The above solution is level 2 since not only does it correctly identify which clients are favored but it clearly states why this follows from the algorithm idea.
Whom doesn’t your algorithm work well for? (2 points)
Level 2 solution
The algorithm does not work well for clients with odd indices. This is because since they share as many edges as possible with other paths (at least with paths of other clients with odd indices), this means in the routing algorithm, there will be more "bottlenecks", which means their routing delay would likely be much larger than their minimum path delay. This by definition of $pen_0$ implies that the penalties for clients with even indices $c$ would more likely be $pmt_c$.
The above solution is level 2 since not only does it correctly identify which clients are not favored but it clearly states why this follows from the algorithm idea.
How fair is your algorithm? (4 points)
Level 0 solution
Our algorithm is completely fair.
The above solution is level 0 since it gives a sweeping statement about the algorithm being fair without any justification.
Level 1 solution
Since the algorithm favors even index clients over those with odd indices it is not fair (to clients with odd indices).
The above solution is level 1 since while it does identify unequal treatment it does not justify why this unequal treatment is unfair. Here is an example from employment law where unequal treatment does not imply unfair treatment. Consider job applicants who get the job of an Imam for a mosque. Now, if one sees that only Muslims get the job but applicants from another religion is not even given an interview this technically implies unequal treatment based on religion (which is a protected group as per US anti-discrimination law ). However, being Muslim is a requirement for being an imam so this is not a case of unfairness/discrimination.
Level 2 solution
The algorithm favors even index clients over those with odd indices. However, the choice to favor even indices over odd indices is completely arbitrary (e.g. swapping the roles of odd and even indices does not change anything fundamental about the algorithm). In particular, there is not even a business justification for favoring clients with even indices. Alternatively, there is no recourse for clients with odd indices to be able to make changes so that they are not favored anymore. Of course having a recourse that e.g. costs a lot of money/resources to fix is not good either but even that (really really) bad option is not available.
The above solution is level 2 since not only does it point out unequal treatment it also clearly states why the unequal treatment is not fair: basically an arbitrary design choice of the algorithm led to unequal treatment.