用iain-couzin等人的模型模拟鱼群行为。

couzinswarm的Python项目详细描述


Iain Couzin et al.模型模拟鱼群行为 小心使用,因为我似乎无法复制某些行为(例如 环面蜂拥而至)。

示例

fromcouzinswarmimportSwarmswarm=Swarm()r,v=swarm.simulate(1000)

安装

pip install couzinswarm

详细示例

importnumpyasnpimportmatplotlib.pyplotasplfrommpl_toolkits.mplot3dimportAxes3DfromcouzinswarmimportSwarm# note: the dimension of space is measure in fish length,# such that r = 1 means a length of one fishswarm=Swarm(number_of_fish=20,repulsion_radius=1,orientation_width=10,attraction_width=10,# this angle is given in radians# up to np.pi (not 360 degrees as in# the paper)angle_of_perception=np.pi,# radians per unit of timeturning_rate=0.1,# fish lengths per unit of timespeed=0.1,# in units of fish lengthnoise_sigma=0.1,dt=0.1,# geometry of boxbox_lengths=[100,100,100],# boundary conditionsreflect_at_boundary=[True,True,True],verbose=False,)fig=pl.figure()ax=fig.add_subplot(111,projection='3d')N_t=1000t=np.arange(N_t+1)# Note that r.shape = v.shape = ( N_fish, N_t+1, 3 )positions,directions=swarm.simulate(N_t)r,v=positions,directionsforiinrange(swarm.number_of_fish):ax.plot(r[i,:,0],r[i,:,1],r[i,:,2])pl.show()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用户界面java,使用gui连接到另一台计算机/服务器的文件系统   运行sbt的ubuntu返回错误:“javahome需要<path>参数”   java如何在Android中处理许多ImageView而不出现内存问题?   查询中非法字符的java相同URL失败   安卓取消引用可能会产生“java”。lang.NullPointerException'   java中的indexoutofboundsexception“java.lang.ArrayIndexOutOfBoundsException”错误   xml Java将dom保存到文件>文件在程序结束后由另一个进程打开   Java的垃圾收集器是如何工作的?   Java如何筛选值(列表)   java处理字符串我怎样才能像在真实的书籍中一样在上面部分生成“小数字”呢?   java SonarQube是否有一个API来获取所有项目分析的一部分?   java startActivity(intent)什么都不做   JAVAutil。扫描器类Java   java如何从Firebase更新电子邮件?UpdateMail方法已被弃用   java Hibernate。如何正确组织带有注释的onetomany关系?   在java中获得卷标和驱动器号之间的映射(而不是FileSystemView)的解决方法是什么   java查找文件的路径