2016-11-24 3 views
1

私の研究では、実際の作業環境を表すシミュレーションを構築しようとしています。 特に、私は人が複数のチームで働くシナリオをモデリングしています(一度に1つのプロジェクトだけで作業しますか?多くはそうしません...)。これを行うには、私はNetLogoで作業しています。エージェントまたはエージェントセットになると予想される入力をASKしてください。代わりにNOBODYを取得しました

カスタムリンクカメルセットの特定のエージェントに対するASKに問題があります。要点は、「入力がエージェントまたはエージェントセットになると思っていましたが、代わりにNOBODYがある」とエラーを報告することがありますが、エージェントが存在しない場合は「ASK」に到達してはいけません。私は間違って何をしていますか?

機能は以下の通りです:

to TeamRecruiting 
    ;; I ask non-complete teams to... 
    ask teams with [ teamsize != (count membership-neighbors) ] 
    [ 
    ;; ... count how many individuals they have... 
    let actualteammembers count membership-neighbors 
    ;; ... to save locally how many individuals they can share... 
    let teamoverlap overlap 
    ;; ... their target size... 
    let neededsize teamsize 
    ;; ... and their identity. 
    let teamwho who 
    ;; then I ask those individuals that have not yet more things than they can handle... 
    ask individuals with [ indMTM != (count membership-neighbors) ] 
     [ 
     ;; ... to save locally who they are... 
     let indwho who 
     let createdalink 0 
     ;; ... then if some conditions have been met ... 
     if(some conditions) 
     [ 
     ;; I create a link (of my specific type) with the team... 
     create-membership-with team teamwho 
     ;; I do the following because more than one individual could join the team teamwho in the same run of the function 
     ask team teamwho [ set actualteammembers (actualteammembers + 1) ] 
     set createdalink 1 
     ] 
     ;; if the association occurred, ... 
     if(createdalink = 1) 
     [ 
     ;; we ask all other teams to evaluate if the new connection violates their maximum overlap constraint between the team I am considering from the beginning of the function, and all other teams, in other words... 
     ask teams with [ who != teamwho ] 
     [ 
     let numpaths 0 
     let team2who who 
     ;; I count how many individuals say that they are shared by the two teams 
     ask individuals 
      [ 
      if((membership-neighbor? team teamwho) and (membership-neighbor? team team2who)) [ set numpaths (numpaths + 1) ] 
      ] 
     ;; ... and if the number of paths is more than the maximum allowed overlap... 
     if(numpaths > teamoverlap) 
      [ 
      ;; I take the connection away... 
      ask membership teamwho indwho [ die ] 
      ;; and I reduce the actual number of team members 
      set actualteammembers (actualteammembers - 1) 
      ] 
     ] 
     ] 
    ] 
    ] 
end 

あなたの貴重な助けをありがとう!

+0

注:この問題は次の場所で発生します:ask membership teamwho indwho [die] – ValerioI

答えて

0

あなたはあなたが死ぬことを求めているリンクを参照する方法に問題があると思われます。 membershipは無向リンクであるため、どのエージェントがend1であり、end2であるかは、エージェントが作成された順序に依存します。番号が小さいものはend1で、もう1つはend2です。チームエージェントが個々のエージェントの後に作成された場合、その特定のリンクはmembership indwho teamwhoになります。一般に、誰の番号を使うのは悪い習慣ですが、チームと個々のエージェントを誰の番号ではなく使っても同じ問題が発生します。

古いであるエージェントぶっきらぼう分からないとき、私は簡単に無向リンクを参照してくださいする方法についてのより良いアドバイスを持っているかもしれないより無向リンクの使用でより多くの経験を持つ誰かが、

ifelse (indwho < teamwho) [ 
ask membership indwho teamwho [ die ] 
] 
[ 
ask membership teamwho indwho [ die ] 
] 
のようなもの

が動作するはずです。有向リンクを使用すると、作成者エージェントは常にend1であり、ターゲットエージェントはend2であるため、この問題は解決されません。ですから、メンバーシップリンクが常に個人によって作成された場合、あなたは常にその個人がend1にいることを知っています。

これが役に立ちます。 チャールズ

関連する問題