Reputation: 717
I am working on a model of tax evasion.
I have stationary traders and moving customers that choose to make a transaction at the cheapest trader. The result is stored as a trader variable called turnover. After 1000 ticks or one tax-period, the trader files his taxes. This calculation is based on several factors:
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
Everything works fine thus far. But after this period, I want to reset the turnover counter, etc, so that the next tax period will be based on the new income this coming period.
So what I would like is to have the history of turnover etc, so that I can see how reported income etc change over time.
One solution would be to make a code for 1000, 2000, 3000 ticks etc, and have variables called turnover1, turnover2, turnover3 etc. But this will make the code a bit long and not very elegant. Is there another way of storing these results? Like in an excel file?
Upvotes: 2
Views: 153
Reputation: 30453
You could use file-open
and file-print
(and other file-*
primitives) to generate a text file (perhaps in CSV format) readable from Excel, R, etc. See File Output Example, in the Code Examples section of the NetLogo Models Library.
And/or, you could accumulate the data in memory, in lists, using lput
to add items on the end. See http://ccl.northwestern.edu/netlogo/docs/programming.html#lists. Here's an example showing a turtle remembering which patches it has visited:
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)
Upvotes: 3