Reputation: 1
I am struggling with developing of a Agent-based model for human migration. I created a network with different countries and calculated the reputation per country based on several parameters now I want to say that from the batch of the refugees in point XY should refugees go based on the country reputation to the specific country.
Can you please help how to write the code that the agents(refugees) will be distributed in the network based on the country reputation?
I set the country reputation as a parameter for the agent country and also included for each country the reputation.
This is my Code:
extensions [ nw ]
breed [countries country]
breed [nodes node]
breed [refugees refugee]
breed [houses house]
create-houses 1 [setxy 49 6 ]
create-countries 1 [setxy 44 5 set reputation 0.007]
create-countries 1 [setxy 43 13 set reputation 0.028]
create-countries 1 [setxy 46 16 set reputation 0.008]
create-countries 1 [setxy 39 16 set reputation 0]
create-countries 1 [setxy 34 18 set reputation 0.001]
create-countries 1 [setxy 32 18 set reputation 0.001]
create-countries 1 [setxy 37.5 21 set reputation 0.024]
create-countries 1 [setxy 36 22 set reputation 0.001]
create-countries 1 [setxy 34 22 set reputation 0.088]
create-countries 1 [setxy 32.5 25.5 set reputation 0.004]
create-countries 1 [setxy 25 26 set reputation 0.462]
create-countries 1 [setxy 40 29 set reputation 0.007]
create-countries 1 [setxy 22 28 set reputation 0.032]
create-countries 1 [setxy 23 31 set reputation 0.075]
create-countries 1 [setxy 31 35 set reputation 0.049]
create-countries 1 [setxy 37 42 set reputation 0.211]
create-countries 1 [setxy 44 33 set reputation 0.001]
create-countries 1 [setxy 42 37 set reputation 0.001]
create-countries 1 [setxy 42 41 set reputation 0.001]
set-default-shape refugees "refugee"
create-refugees 10 [
set location house 0
move-to location]
Thank you very much!
Upvotes: 0
Views: 52
Reputation: 17678
The code you have provided is pieces of different procedures that makes it very hard to understand what you are actually asking. And you mention network a few times but give no detail about what is actually connected in your network.
From your comments, I think that you want each refugee to be initially located in a random country, with the random selection weighted proportional to the country's reputation. If so, here is a complete model that does this. It uses the weighted-one-of
primitive from the rnd
extension, which randomly selects weighted by whatever attribute you specify (in this case, reputation). I have no idea how houses and countries relate to each other and have ignored this, and have moved a refugee to a country instead of a house.
extensions [ rnd ]
breed [countries country]
breed [refugees refugee]
countries-own [reputation]
refugees-own [location]
to setup
create-countries 1 [setxy 44 5 set reputation 0.007]
create-countries 1 [setxy 43 13 set reputation 0.028]
create-refugees 10
[ set location rnd:weighted-one-of countries [reputation]
move-to location
]
end
Upvotes: 2