Opening Stable Doors: Complexity and Stability in Nonlinear Systems
Inman Harvey
Evolutionary and Adaptive Systems Group
University of Sussex
inmanh@gmail.com

Submitted to ECAL2011

Matlab code for replicating the Gardner and Ashby (1970) experiments, plus 'hand-drawn' curves to replicate the (mistaken) lines in their figure for n=10 and n=7. Original code by Inman Harvey. Improvements, added elegance (eg use of 'ScrambledList') due to David Waxman.

Reference: Gardner, M. R. and Ashby, W. R. (1970). Connectance of Large Dynamic (Cybernetic) Systems: Critical Values for Stability.
Nature, 228:784.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Stability.m

clear all

close all

clc

nlist=[4 7 10];             %the different values of n that G&A used

for loop=1:3

n=nlist(loop);          % Size of matrices

reps=100000;           % No. of repeats

Nmax=n^2-n;             % Max number of non-zero elements

Count=zeros(Nmax,1);    % Counts occurrence of stability

List=[1:n^2]';          % Labels of all elements in the matrix

List(1:n+1:end)=[];     % Labels, excluding those of diagonal elements

L=length(List);         % Should equal n^2-n

for j=1:Nmax            % No. of nonzero elements off-diagonal

for r=1:reps

M=zeros(n);                         % Initialise the matrix

ScrambledList=List(randperm(L));    %

Connect=ScrambledList(1:j);         % Non zero elements

M(Connect)=2*rand(size(Connect))-1; % Filled with U(-1,1)

M=M-diag(diag(0.1+0.9*rand(n)));    % Diagonal: U(-1,-0.1)

Count(j)=Count(j)+(max(real(eig(M)))<0);

end

end

hold on

plot([1:Nmax]/(n^2-n),Count/reps)           %uses the off-diagonal count, corresponds with G&A paper

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

GA10=zeros(1,1000);      %draw by hand the n=10 line from G&A, use GA10[ ...]

GA10(1:125)=1;              %initialise matrix, then insert points to fit their graph by eye

GA10(121:130)=[0.995 0.99 0.985 0.98 0.975 0.96 0.94 0.92 0.80 0.5];

GA10(131:139)=[0.3 0.08 0.06 0.04 0.025 0.02 0.015 0.01 0.005];

plot([1:1000]/1000,GA10)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

GA7=zeros(1,100);       %draw by hand the n=7 line from G&A, use GA7[...]

GA7(1:10)=[1 1 1 1 1 1 1 1 1 1];

GA7(11:20)=[1 1 1 0.99 0.98 0.97 0.96 0.95 0.92 0.9];

GA7(21:30)=[0.85 0.8 0.75 0.7 0.65 0.6 0.55 0.5 0.45 0.4];

GA7(31:40)=[0.35 0.3 0.25 0.2 0.15 0.10 0.06 0.03 0.015 0.01];

GA7(41:45)=[0.008 0.006 0.004 0.002 0.001];

plot([1:100]/100,GA7)

xlabel('C')

ylabel('Probability stable')

axis([0,1,0,1])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%