Exercise 2
Using the get_laplacian function computed previously, we will simulate, in matrix form, the consensus protocol for the temperature measurement example shown in class and whose communication graph is shown in Figure 1.
a) Write a function:
def simulate_consensus(x_0, T, L, dt=0.001):
that takes as input a vector of size n of conditions o, a desired integration time T, a graph Laplacian L, and an optional integration time dt (which is 0.001 by default) and integrates the consensus protocol as the differential equations = L from t = 0 to t = T and returns a vector that contains all n robot states at each instant of time (i.e. [i,j] contains the state of robot i at time t[i]). Use the Euler integration scheme seen in class to do the integration.
b) Simulate the consensus protocol for the initial temperature measurements:
o = [10, 20, 12, 5, 30, 12, 15, 16.25]
(3)
Plot the state of every robot as a function of time in a single graph. How much time does it take until the states reach consensus? (assume that consensus is reached when the states are within a distance of 0.01 of each other). How does the result compare to the theoretical prediction?
c) How will the convergence change if we remove the edges between 2 and 6 and between 2 and 4? Verify your prediction experimentally.
d) How will the convergence change if a complete graph is used instead? Compare your theoretical prediction with a simulation.
e) Same question as d) for a cycle graph.
Figure 1: Communication network for the temperature measuring drones