NetLogo:从另一个中减去一个补丁集

时间:2014-09-22 08:19:41

标签: netlogo

我尝试创建patch-set而无需单独定义列表中的每个补丁。但是,为了做到这一点,我需要从另一个中减去一个patch-set。在我的模型中,patches own O2。我有几个选定的补丁,其中O2的值不应该改变。我想为patch-set的补丁创建一个pxcor = max-pxcor,但要排除那些应该保持O2不变的补丁。我已经尝试减去补丁集,但收到错误消息说-expected this input to be a number, but got a patch agentset instead.我也尝试将补丁集设置为列表,然后使用remove命令修改列表。但是,这会在我ask列表执行某些操作时出现问题,我收到错误ASK expected an agent or agentset, but got a list instead

以下是我尝试构建补丁集的相关代码:

set NS1 (patch-set patch -8 -5 6 patch -8 -5 -5 patch -8 6 6 patch -8 6 -5  patch 8 -5 6 patch 8 -5 -5 patch 8 6 6 patch 8 6 -5) 
set NS2 (patch-set patch -8 0 6 patch -8 0 -5 patch 8 0 6 patch 8 0 -5  )  
set NS3 (patch-set patch -4 -5 6 patch -4 -5 -5 patch 4 -5 6 patch 4 -5 -5 patch -4 6 6 patch -4 6 -5 patch 4 6 6 patch 4 6 -5) 
set NS4 (patch-set patch -4 0 6 patch -4 0 -5 patch 4 0 6 patch 4 0 -5 )  
set NS5 (patch-set patch -8 0 0 patch 8 0 0 )                 
set NS6 (patch-set patch -8 -5 0 patch -8 6 0 patch 8 -5 0 patch 8 6 0 )      
set NS7 (patch-set patch -4 -5 0 patch -4 6 0 patch 4 -5 0 patch 4 6 0   )   
set NS8 (patch-set patch 0 0 6 patch 0 0 -5 )             
set NS9 (patch-set patch 0 -5 6 patch 0 -5 -5 patch 0 6 6 patch 0 6 -5)
set NS10 (patch-set patch 0 -5 0 patch 0 6 0 )             
set NS11 patch 0 0 0                          
set NS12 (patch-set patch -4 0 0 patch 4 0 0 )             

set FEMnodes (sentence NS1 NS2 NS3 NS4 NS5 NS6 NS7 NS8 NS9 NS10 NS11 NS12)  
set Xmaxmin (list (patch-set patches with [ pxcor = min-pxcor] patches with [ pxcor = max-pxcor]))
set lateral remove FEMnodes Xmaxmin
set Ymaxmin (list (patch-set patches with [ pycor = min-pycor ] patches with [ pycor = max-pycor ]))
set FB remove FEMnodes Ymaxmin
set Zmaxmin (list (patch-set patches with [ pzcor = min-pzcor ] patches with [ pzcor = max-pzcor ]))
set TP remove FEMnodes Zmaxmin

1 个答案:

答案 0 :(得分:1)

我认为FEMnodes包含具有常数O2的补丁,对吗?如果是这样,您可以执行以下操作:

patches with [ pxcor = max-pxcor and not member? self FEMnodes ]

获取pxcor = max-pxcor以外的所有FEMnodes补丁。

所以,我认为您希望Xmaxmin实际定义如下:

set Xmaxmin patches with [ (pxcor = min-pxcor or pxcor = max-pxcor) and not member? self FEMnodes ]

对于一般补丁集差异,您可以使用:

to-report patch-set-difference [ set1 set2 ]
  report set1 with [ not member? self set2 ]
end

但我认为我提供的Xmaxmin的定义更多是您想要使用的策略。