Welcome to the preantepenultimate week of the term.

Questions about anything?

First let me say that I know many folks have been dealing with illness and stress, and I understand. Don't panic. We have 3.5 weeks left, and a good chunk of that should be time for you to work on your final projects. Please do connect with tutors and/or me by appointment as needed.

Second, let's go around the room and see what you're thinking of for the final projects.

Third, anything you'd like to talk about regarding the SQL we did last week?

Here's what I have in mind for coming attractions:

- traveling salesman
- complexity : P vs NP, formal languages, turing machines & all that ... bird's eye overview
- search example : n queens done two ways : backtracking, gradient descent
- mid-May 1-on-1 project meetings
- dynamic programming : coins
- other example problems worked on in class

If there are any particular topics you'd like to add, let me know.

The "Traveling Salesman Problem" (TSP) is one of the all-time classic graph algorithms. No one has ever found a fast exact algorithm, though many have tried. This is a problem that does need to be solved in real life, and typically we use approaches that give routes that are good enough (1% or so within the best answer) for practical purposes.

We'll discuss what the problem is, what sorts of solutions there are, and play around with some code exercises in class.

- wikipedia: TSP
- my starting code ... turtle graphics
- Can we implement the brute force exact solution for small n?
- Sub-task: how do we loop over all paths?
- ... some in-class coding as a class or in small groups.

- improving a solution with a "local search" ... Arthur Maheo's code
- gitlab repo
- heuristics
- lin-kernighan
- ... let's see if we can understand the general approaches here.

We had a digression to discuss permutations and how to generate them :

- wikipedia: algorithms to generate permutations
- permutations.py
- change ringing ... related and amusing
- ring out your dead (Midsomer Murders S5 E2) |
- jokes
- plain bob (one change ringing permutation pattern) | video | pattern

Note that this local search notion is a common and powerful approach, a dominant part of machine learning algorithms. The idea is

- Find a (poor) starting solution to your problem.
- Invent "neighboring" solutions by modifying something, giving an abstract space (graph) of solutions.
- Improve your best-so-far with hill climbing (or more typically "valley descending") i.e. gradient descent (if it's smooth).
- But understand the difference between local and global minimums.
- Techniques like simulated annealing (sometimes go uphill depending on temperature) might work ...
- or perhaps try a genetic evolution search.
- There are many variations.

The algorithms we've done earlier this term are all in the category P : polynomial time. (Note that n*log(n) is faster than n**2, and so still "polynomial".). The TSP
is in the NP category (or at least, variations of it are depending on how we formulate the problem). NP stands for "non-deterministic polynomial".

Whether or not there is a difference between P vs NP is one of the best known unsolved problems in theoretical computer science.

Let's define & discuss these categories briefly:

This is profound, important stuff, and worth discussing further to understand the gist of what's going on ... so that's where we're headed next. It'll take a bit of background to really appreciate this stuff.

In our next excursion into a few other interesting topics as we wind down the term, and as you all work on your final projects, I'd like us to read about and discuss a few "big picture" ideas related to algorithms. There won't be as many "write this code" problems here, but instead hopefully give you some context for the sorts of questions that computer scientists study. If you continue on with computer science, these topics form the core of the "math theory" of what can be computed.

I've put up some complexity notes which can be a starting point for an overview of these topics.

https://cs.bennington.college /courses /spring2022 /algorithms /notes /may2

last modified Wed May 4 2022 3:32 pm

last modified Wed May 4 2022 3:32 pm