在 netlogo 中比较来自不同海龟的变量

comparing variables from different turtles in netlogo

我从两个代理(行业)的简单模型开始,我想打印两个变量中较小的一个(属于每个代理)。我不太确定如何比较来自不同代理的两个变量并打印值。代码的相关部分粘贴在下面:

to setup-turtles  
 create-I1 1 [  
  setxy 0 7  
  set shape "factory"  
  create-active-links-to I2  
  set color 125  
   set product product-I1  
  set raw-material 0.35 * product-I1  
  set waste (0.003 * product-I1)  
  ]  

  create-I2 1 [  
  set shape "factory"  
  create-active-links-to I1  
  set color 55  
  set product product-I2  
  set raw-material 0.102 * product-I2  
  set waste 0.032 * product-I2  
  ]  

end  

*the problem is here  
to-report E1-2 min [waste of I2 or raw-material of I1]  
  report E1-2  
end  

你是想比较 I2 的浪费价值和 I1 的原始价值吗-material?看起来 I1 和 I2 都是海龟品种,而且每个品种只有一只海龟。如果这是正确的,那么下面的代码将起作用。

to-report E1-2
  report min (list [waste] of one-of I2 [raw-material] of one-of I1)
end

请注意,我已将 one-of 添加到您的尝试中。 NetLogo 不知道您将永远只有一个 T1 和一个 T2,因此您必须告诉 NetLogo select 来自所有 T1 的一只乌龟和来自所有 T2 的一只乌龟进行比较。在这种情况下,list 不是必需的,因为您只有两个值要比较,但我包含了它以防您想在更多值上取最小值。