12.2 Capstone: Model and Optimize a Smart-City Network
This final section is a guided design project. You will not meet a new mathematical topic without preparation. Instead, you will connect ideas already developed across the course: sets describe the objects, logic states the rules, functions and relations connect data, proofs justify claims, algorithms carry out decisions, counting measures possibilities, probability represents uncertainty, trees organize choices, graphs represent routes, Boolean circuits make immediate decisions, and finite-state machines control behavior over time.
Our setting is a small smart city. Ambulances and fire engines must reach incidents quickly, intersections must change signal phases safely, and a limited budget must be spent on upgrades that improve resilience.
1. Translate a Story into a Mathematical Model
Before optimizing anything, identify the objects and the questions.
The city has six important sites:
where is the hospital, the fire station, the central intersection, and the north and south districts, and the power depot.
Roads connect pairs of sites. Let be the set of roads. Travel time in minutes is a weight function
where means the set of positive real numbers. Together,
is a weighted graph.
| Road | Normal time | Road | Normal time |
|---|---|---|---|
The letters denote the edge ; they do not mean multiplication. If roads allow travel in both directions with equal time, this is an undirected graph. A closure removes an edge temporarily. Congestion changes an edge weight rather than removing the edge.
Questions determine the right structure
One real system can require several models:
| Question | Mathematical structure |
|---|---|
| Which sites and roads exist? | sets and a graph |
| What is the fastest emergency route? | weighted shortest path |
| Should a priority request be sent? | Boolean function |
| Which signal phase comes next? | finite-state machine |
| How many upgrade packages fit the budget? | systematic counting |
| What is average delay under uncertain incidents? | probability and expectation |
| Why can two green directions never conflict? | invariant and proof |
Choosing a graph alone does not finish the model. A good model states what each vertex, edge, weight, bit, state, and event means in the real system.
2. Separate Immediate Decisions from Timed Control
Suppose three input bits are observed at the central intersection:
- means an emergency vehicle has requested priority;
- means an ordinary road sensor reports a waiting queue;
- means the pedestrian crossing is active.
Define a Boolean request signal
This says that an emergency request sets , while an ordinary request sets it only when no pedestrian crossing is active. Importantly, does not mean “turn the light green immediately.” It asks the state machine to begin a safe transition.
The signal controller uses four states:
- Normal: the ordinary schedule is running.
- Clear: all vehicle directions are held while the intersection clears.
- Priority: the emergency route receives a green phase.
- Recover: the controller clears the intersection again before returning to normal.
A simplified transition pipeline is
This separation is a design principle:
The circuit answers a current yes-or-no question. The state machine enforces a safe sequence over time.
3. Dispatch Is an Algorithm, Not a Guess
When an incident occurs at , the city compares the hospital route and the fire-station route. Dijkstra’s algorithm from Chapter 11 computes shortest travel times because all road weights are positive.
From , Dijkstra first records tentative labels and . It settles next because . Relaxing edge proposes , so the label of remains . All other unsettled labels are larger, and is then settled. Therefore:
There are two different shortest routes, and , both with total time . This is a useful reminder: a shortest distance may be unique even when the shortest path is not.
If road closes, the remaining route still takes . The network has redundancy for that failure. If also closes, may still be reached through , but the travel time changes. Connectivity says whether service remains possible; shortest-path distance says how costly that remaining service is.
Close or congest roads on the live city map, compare dispatch routes, evaluate the priority-request circuit, and advance the signal controller until the chosen vehicle receives a protected phase.
4. State Requirements Before Choosing Upgrades
An upgrade is only “better” relative to stated requirements. We use four:
1. Reachability: every district must remain connected to at least one emergency station after any single road failure. 2. Response: expected emergency travel time should be small. 3. Safety: conflicting traffic directions must never be green together. 4. Budget: the total installation cost may not exceed .
Suppose there are candidate upgrades. Define a decision bit
If upgrade costs , the budget constraint is
The summation adds the cost of every selected upgrade because terms with contribute nothing.
Candidate upgrades may have different effects:
| Upgrade type | Model change |
|---|---|
| backup road | add an edge to |
| traffic sensor | reduce a congested edge weight when detection succeeds |
| backup controller | reduce the probability of a signal-controller failure |
Comparing only purchase cost would ignore these different benefits.
5. Model Uncertainty with Scenarios
A scenario is one possible incident-day condition: an incident location, congestion pattern, road failure, and controller status. Let the finite scenario set be
Assign probability to scenario , with
For an upgrade plan , let be the shortest emergency response time in scenario . Its expected response time is
This is the weighted average from Chapter 9. A rare but disastrous disconnection should not silently disappear, so define if the scenario loses emergency service and otherwise. Then
6. Make Trade-offs Explicit
An objective function turns a proposed design into a score to minimize. One example is
where are policy weights:
- expresses the importance of response time;
- expresses the importance of installation cost;
- expresses the importance of avoiding service loss.
These weights are not probabilities. They encode priorities and make different units comparable. Changing them can change the preferred design, so a responsible report shows the chosen values and tests whether the recommendation remains stable under reasonable alternatives.
Sometimes safety and budget should be hard constraints, not terms that can be traded away:
This formulation never accepts an unsafe design merely because it is fast.
7. Search the Feasible Designs Systematically
With yes-or-no upgrades there are subsets before applying the budget. For a small capstone, exhaustive search is appropriate:
1. generate each bit vector ; 2. reject it if its cost exceeds ; 3. test graph and controller constraints; 4. simulate every scenario; 5. compute the objective; 6. keep the best feasible design.
This procedure links several chapters:
For larger , grows quickly, as Chapter 5 explained. Then one might use smarter optimization methods, but exhaustive search is valuable here because it is transparent and produces a complete certificate: every feasible plan was considered.
8. Validate, Stress-Test, and Prove
A simulation is evidence about the scenarios tested. A proof covers every case named by its assumptions. A strong design uses both.
Graph validation
For each allowed single-edge failure :
1. form the remaining graph ; 2. run BFS from and from ; 3. verify that each district belongs to at least one visited set.
Controller safety invariant
Let mean north-south traffic is green and mean east-west traffic is green. The safety requirement is
To prove it, check the output assigned to every reachable controller state and show that no state outputs . Then check that every transition stays inside the set of these safe states.
Boundary and adversarial tests
Test more than an ordinary day:
- no emergency requests;
- simultaneous sensor and pedestrian requests;
- an emergency that ends during Clear;
- each single road failure;
- maximum modeled congestion;
- a budget exactly equal to the selected upgrade cost.
These tests target boundaries where definitions change and where implementation mistakes often hide.
Allocate a changing budget among backup roads, sensors, and controllers. Replay a fixed deck of incident days, inspect every scenario contribution, and compete against an exhaustive-search certificate for the best feasible plan.
9. The Final Design Argument
A complete capstone submission is not just a map or a score. It is a chain of claims supported by mathematical evidence:
Use this checklist:
1. Definitions: state what every set, graph element, weight, random variable, bit, state, and input means. 2. Assumptions: state which roads are bidirectional, which failures are considered, and how scenario probabilities were chosen. 3. Correct method: explain why the algorithm applies—for example, Dijkstra requires nonnegative weights. 4. Reproducible calculation: show route totals, transition traces, scenario tables, and the budget sum. 5. Proof obligations: prove the safety invariant and the required failure resilience. 6. Trade-off: explain what improves, what it costs, and what uncertainty remains.
10. Course Synthesis
The city model reveals the unifying idea of discrete mathematics: complex systems become understandable when we identify a finite collection of objects, define exact relations and rules, and reason from those definitions.
| Course idea | Role in the capstone |
|---|---|
| sets and functions | define sites, roads, weights, and outputs |
| logic and proof | state requirements and prove safety |
| relations | describe connectivity and reachability |
| algorithms and complexity | compute and judge whether search scales |
| counting | enumerate upgrade plans and scenarios |
| recurrence and trees | organize recursive search and decisions |
| number theory | support secure communication when required |
| probability | quantify uncertain congestion and failures |
| graphs | model routes and network resilience |
| Boolean circuits | combine current sensor signals |
| finite-state machines | enforce safe behavior through time |
You began the course by asking how a real situation becomes a discrete model. You can now answer with a disciplined workflow: define the objects, choose structures that preserve the relevant relationships, compute with explicit algorithms, and justify the result with proofs and tests. That workflow—not any single formula—is the lasting tool of discrete mathematics.