▲ Lab 2 (resit): Automaton.
▲ Lab 3 (resit): Network epidemics/spread.
▲ Lab 4: (resit): Network properties.
▲ Lab 5: (resit): Selfpropelled particles.
▲ Lab 6: (resit)): Genetic algorithms. Sample code in python and matlab available here.
▲ Final Project. The resit is the same assignment (if you submit both you need to pick different papers).
Monday 18th May: 14pm Lab 6: Genetic algorithms.
Lab 6 Warm up: GA specifics and implementing painter robot
1. We investigate different ways to 'generate' generation g+1 from generation g. Our setup is k individuals, with 'fitnesses' f(1), f(2), ..... '. Recall parent 1 and parent 2 give rise to child 1 and child 2, via 'crossover' as in lecture.
In the mutation phase each locus on each choromosome can mutate independently with probability p.
Choices  how to pick parent 1 and parent 2. E.g. tournament pick $t$ chromosomes at random then take one with highest fitness, with probability proportional to fitness, using threshold function etc. Also note one can choose parents with or without replacement.
2. Check you can implement the robot! As a starting point you may use the matlab or python implementations here.
3. For chromosome '333......3', check average score over some runs. (For 40x20 square expect about 0.3).
Monday 11th May: 9am12noon Lab 5: Selfpropelled particle models.
Lab 5 Warm up: Vicsek model
1. Run an implementation of the Vicsek alignment model with different parameter values. As a starting point you may use Align2D.m from here or the python implementation here.
2. By varying the parameter values create two videos with qualitatively different behaviour e.g. one with particles tending to become aligned and one where this does not occur.
3. Calculate the polarisation at each time step and plot how polarisation changes over time in one or more runs of the model. NB: Polarisation of particles with angles $\theta_1, \theta_2, \ldots, \theta_N$ is defined to be $\frac{1}{N}\sqrt{(\sum_j {\rm sin}(\theta_j))^2 +(\sum_j {\rm cos}(\theta_j))^2}$.
Here are some sketched notes on the Vicsek model and on polarisation.
Some example videos from the python implementation above with noise parameters $\eta=0.2$ and $\eta=0.6$ for $N = 100$ #particles, $r = 0.1$ radius, $\delta_t = 0.01$ timestep, from time $t = 0.0$ to time $T = 2.0$.
The assignment asks for a phase diagrams as here. They are nothing but 2D histograms with the heights indicated by the shading of the squares. The idea of them is to give an indication of the proportion of runs of the models which have certain ranges of alignment as $\eta$ varies. Nice example python implementation here.
Friday 23rd April: 14pm Lab 4: Network analysis and statistics.
Lab 4 Warm up: Network analysis
1. Find and load a real network with n>200 vertices.
2. Find modularity* of the network (*this will be heuristically calculated value, not the max)
3. Generate ER random graph with same expected number of edges as real network
4. Generate a configuration model random graph with same degree sequence as real network
Python
Airlines example with data from here. Links for data: airlines.txt and python code of mine to load in network data and find a partition of the airlines graph into communties: airlines_mod.py, and to sample via the configuration model a random graph with same degree sequence: airlines_config_model.py.
Tutorial on plotting, including boxplots, in python: here.
Matlab
Community detection toolbox available here. It includes three different algorithms for finding community partitions of networks, and also function to calculate the modularity value of a partition of a graph.
Background theory
Nice video on statistical inference on networks here from 1:071:11 discusses MonteCarlo test which is releated to 5b in the lab.
Wednesday 22nd April: 810am Lecture: Networks II, more on network measures, random models of networks.
Friday 17th April: 13pm Lab 3: Network epidemics.
Lab 3 Warm up: Friends of Friends.
1. Find and load a real network with n>200 vertices.
2. Plot the degree distribution (xaxis degree, yaxis #vertices with that degree).
3. Select S, a sample of approx n/50 vertices at random. Plot the degree distribution of the vertices in S.
4. Take the set of neighbours of vertices in S and plot their degree distribution.
Python
Airlines example from http://vlado.fmf.unilj.si/pub/networks/data/
Links for data: airlines.txt . Python code to load in graph: airlines_network.py. Python code of mine for degrees fo sample vs. degrees of neighbours of sample: over 100 runs airline_degrees.py. Same code as a jupyter notebook here airlines.ipynb.
Matlab
Karate club with matlab adapted from here. Link for data: karate.mat . Matlab code to load in graph and plot degrees : plot_degs.m
Degrees of sample vs. degrees of neighbours of the sample. Email network with data from http://networkrepository.com/iaemailuniv.php example provided by Kasia Kowalczyk. Link for data: iaemailuniv.mtx . Matlab code to load in graph and plot degrees : degree_distribution.m
Wednesday 15th April: 35pm Lecture: Networks I, representing networks, network measures.
Tuesday 14th April: 910am Lecture: Automaton I, 1012noon: Lab 2 exercises. BREAK.
12pm Lecture: Automaton II, 23pm Continuation of Lab/time for questions.
Lab 2: Warm up: Game of Life
1. Simulate Game of Life using your own or existing code.
2. Find an extra pattern of period 1 not covered in the lecture.
3. Find an extra pattern of period 2
4. Find an extra pattern which translates each t steps for some t
Examples shared during the lab included one in J programming language shared by Anton Wallgren  an online runnable version is here.
Course Details
Each lab covers a project each consisting of a series of questions. The first part of the course with Alejandro, assignments 1 and 2, will together count for 20 points of the final grade. In the second part of the course, 5 labs based assignments each worth 10 points. After each question is a number of points associated with it. There is a final project which will be worth 30 points. The total points over all the questions is 100.
To pass the course (grade 3) you must correctly answer questions amounting to at least 50 points. In order to get grade 4 you must get 70 points. In order to get a grade 5 you must get 75 points and at least 18 points on the final project (implementing scientific article).
Resits. Deadline will be 31st August. There will be an 'equivalent' resit version of Labs 2 to 6 and of the final project. The resit lab assignments will each be worth 10 points and the resit final project 30 points. There will be a single resit assignment to cover the part of the course taught by Alejandro which will count for 20 points. It will be possible to do resits assignment by assignment, so one could choose to resit only some of the assignments. Anyone can choose to resit any subset. You will also be able to do these in groups.

