我正在研究逃税模式。
我有固定交易员和移动客户选择在最便宜的交易者处进行交易。结果存储为名为营业额的交易者变量。在1000个刻度或一个税期后,交易者提交税款。此计算基于以下几个因素:
to pay-taxes
set rep-turnover (turnover) * (1 - evasion-level) ;Evasion level is set by a slider
set cost-of-goods ((rep-turnover / 100) * 25) ;assumes cost-of-goods to be 30 per cent of reported turnover
set rep-wage-expences ((rep-turnover / 100) * 35);assumes wage expences to be 30 per cent of reported turnover
set general-cost 20000 ; 20 000 in general costs assumed (rent, power, etc)
set workers-tax (rep-wage-expences / 100) * workers-tax-level ; calculates the workers-tax, workers-tax-level based on slider
set rep-net-result rep-turnover - workers-tax - rep-wage-expences - cost-of-goods - general-cost; calculates the net-result
set hidden-economy turnover - rep-turnover;calculates how much hidden income the trader has
end
到目前为止一切正常。但在此之后,我想重置营业额等,以便下一个税收期将基于未来期间的新收入。
所以我想要的是拥有营业额等历史,以便我可以看到报告的收入等随着时间的推移而变化。
一种解决方案是制作1000,2000,3000等等的代码,并且有变量称为turnover1,turnover2,turnover3等。但这会使代码有点长而且不是很优雅。还有另一种存储这些结果的方法吗?就像在excel文件中一样?
答案 0 :(得分:3)
您可以使用file-open
和file-print
(和其他file-*
基元)生成可从Excel,R等读取的文本文件(可能是CSV格式)。请参阅文件输出示例,在NetLogo模型库的代码示例部分。
和/或,您可以使用lput
在列表中的内存中累积数据,以便在末尾添加项目。见http://ccl.northwestern.edu/netlogo/docs/programming.html#lists。这是一个示例,显示一只乌龟记住它访问了哪些补丁:
turtles-own [history]
to setup
clear-all
create-turtles 1 [ set history [] ]
reset-ticks
end
to go
ask turtles [
fd 1
set history lput patch-here history
]
tick
end
observer> setup
observer> repeat 5 [ go ]
turtles> foreach history print
(patch 0 -1)
(patch 0 -2)
(patch 0 -3)
(patch 1 -4)
(patch 1 -5)