Week 6 Tutorial: Compare swaps with all 720
Implement a swap improver, find where it stops, and measure its exact gap against all 720 permutations.
31 March 2027
Open Week 6 in the Lab →Try your own change on this week's case.
Two-hour tutorial: preparation, coding and checks
This week’s task#
Model: Editable symbolic jobs A–F first. The canonical #01–#06 case is a separate experiment with real flight costs.
Before you start · 15 minutes#
Read W6. Predict what a full scan of 15 pair swaps proves and what it cannot prove.
Trace the example · 25 minutes#
Inspect the starting swap result (48,55), then check all 720 sequences. The exact result is (46,51); explain the two-unit lateness gap.
Implement and compare · 55 minutes#
Complete mySwaps using your timetable and the declared comparator. Log every accepted move and stop only after a full scan finds no strict improvement.
Use Open full Lab for editable inputs, strategy code, exports and the practice pack. The example on this page compares this week’s published cases; your local student runner must call the functions you complete.
Check and explain · 25 minutes#
Check the final neighbourhood and retain the exact benchmark. Repeat on the canonical case and report its zero gap without claiming swaps always find an optimum.
What to keep: A1: local search, exact comparison and the complete draft. Show the tutor your prediction, experiment and explanation for this week’s participation point; keep the record to develop your assignment.
Optional extension#
Edit a ready time in the six-job table and repeat the entire comparison from a fresh initial state.
W6 · Compare swaps with all 720 orders.
Does checking every pair swap prove a global optimum?
These six jobs use small, symbolic time units. Compare a good sequence with the best of all 720 possibilities.
Sequence A → B → C → F → E → D. Course objective (lateness, final return, energy): 48, 55, 0. Every pair swap was checked; this proves only a local optimum.
Computed from this case · 1.31 ms · lab-1.0 · six-jobs
6 × 5 × 4 × 3 × 2 × 1
Enumeration not runSwaps stop here. Is it the best?
| Method | Lateness | Final return |
|---|---|---|
| Starting swaps | 48 | 55 |
| Exact result | Not run | Not run |
Small symbolic time units. Exhausting pair swaps proves only that this neighbourhood has no improvement.
Explore the evidence, replay or open full Lab
Open full Lab ↗ for editable inputs, strategy code and saved comparisons.
Compare the swap result (48,55) with the exact result (46,51), in symbolic time units.
Read the example above
Compare the swap result (48,55) with the exact result (46,51), in symbolic time units.
Symbolic teaching case · Published example units; not flight-model totals · Neighbourhoods, acceptance and exact comparison
| Inspect | Order | Ready | Load start | Depart | Deliver | Return | Lateness |
|---|---|---|---|---|---|---|---|
| A | 5 | 5 | 5 | 8 | 11 | 0 | |
| B | 6 | 11 | 11 | 12 | 13 | 0 | |
| C | 3 | 13 | 13 | 19 | 25 | 7 | |
| F | 6 | 25 | 25 | 29 | 33 | 7 | |
| E | 1 | 33 | 33 | 38 | 43 | 13 | |
| D | 4 | 43 | 43 | 49 | 55 | 21 |
Continue in the Lab →The same case, with every input open to change.
The spec
What you bring to the session. Written so a reader can tell whether it has been met without asking you.
- your improver's stopping condition matches what your report claims
- you report the measured gap, including zero, and distinguish the canonical case from the symbolic counterexample
- "no further improvement" is never written as "optimal" in your report
Teaching team
- Kofi Marchetti — tutor