以下是修改后的LT模型代码:

globals [
  beta       ;beta参数
  theta      ;theta参数
  global_rr  ;全网渗透率
  count
]

to setup
  clear-all
  set-default-shape turtles "circle"
  set-default-shape links "line"
  set beta 0.5 ;设定beta参数
  set theta 0.5 ;设定theta参数
  set global_rr 0.0 ;初始化全网渗透率
  set count 0
  create-turtles 100 [
    setxy random-xcor random-ycor
    set color black
    set size 1
    set rr 0.0 ;初始化节点渗透率
  ]
  ask n-of 1 turtles [
    set color red
    set rr 1.0 ;将初始节点渗透率设为1.0
  ]
  reset-ticks
end

to go
  ask turtles [
    if not any? my-links with [color = red] and (beta * neighbor-rr + (1 - beta) * global_rr >= theta) [
      set color red
      set rr 1.0
    ]
  ]
  set global_rr (count turtles with [color = red]) / count turtles
  set count count + 1
  tick
end

在修改后的模型中,对于未激活节点,当beta*邻居渗透率+(1-beta)全网渗透率≥theta时,该节点激活。beta和theta参数可以在setup过程中设定,全网渗透率通过计算所有激活节点的比例得到。在go过程中,先对所有节点进行判断和更新,然后再计算全网渗透率,并将计数器加1


原文地址: https://www.cveoy.top/t/topic/eP98 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录