Research Article

Potential Consequence of Interconnected Intervention against Systemic Risk (COVID-19) via a Model-Driven Network-Agent Dynamic

Table 3

Code example of the strategy dynamics (imitation).

for i in range (n):# loop for every individual within the t loop
 #-------------------------------------------------------
 # imitation
 #==========
 R1 = np.random.random()# randomly choose a certain (%) only 1 time
 if R1 <= pr:# conditional
  ff = i# focal individual (each node i)
  while True:# it is true
   rr = np.random.choice (n)# randomly choose role individual
   if ff ! = rr:# until focal choose a different role individual
   break# exit out of the loop
  pi = 1/(1 + (np.exp (−s(B[rr,0]-B[ff,0]))))# calculate (Fermi) function
  R2 = np.random.random()# randomly choose a certain (%) only 1 time
  if R2 <= pi:# conditional
    temp[ff, 1:3] = B[rr,1:3]# imitate the role individual
 B [ : , 1 : 3] = temp [ : , 1 : 3]# update strategy values