2014-09-22 66 views
0

我試圖創建一個patch-set,而不必單獨定義列表中的每個修補程序。但是,爲了做到這一點,我需要從另一箇中減去一個patch-set。在我的模型中,patches own O2。我有一些選定的補丁,其O2值不應改變。我想爲pxcor = max-pxcor的修補程序創建patch-set,但排除應該保持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 insteadNetLogo:從另一個減去一個修補程序集

下面是相關的代碼,我嘗試建立補丁集:

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

我認爲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定義我給出的是更多你想要使用的策略。