如何在NetLogo中创建2个滑块值不能超过定义值的条件?

问题描述 投票:0回答:1

我创建了一个模型,作为2个不同的滑块,即ratio1ratio2。它们位于界面上,它们的值应该加起来为1(此处为:labour-unit),也不能超过此值。现在,NetLogo让我超过了条件。

我试过这个:

to setup
  create-turtles number-of-turtles   ;; number of firms to be defined through slider
  set labour-unit ratio1 + ratio2
  set labour-unit 1
end

因此,我的问题是:如何在2个滑块值不能超过定义值的设置中创建条件?

interface slider conditional netlogo agent-based-modeling
1个回答
2
投票

如果值总是加1,你有什么理由需要两个滑块吗?你能不能只用一个名为“与劳动型x的比例”的滑块或者你正在建模的任何东西?然后,您可以让记者返回您之后的实际比例的值 - 例如:

to-report ratio1
  report proportion-slider
end

to-report ratio2
  report precision ( 1 - proportion-slider ) 2
end

然后在你的界面上你可以有滑块(和监视器,如果需要):

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.