You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Create a list of our different ethnicities
ethnicities = ["Green", "Blue", "Mixed"]
# Create agents
MoneyAgent.create_agents(model=self, n=n, ethnicity=self.random.choice(ethnicities))
This results in a monotone chart.
On a separate issue I changed 'ethnicity' to 'allegiance', as I feel it is less contentious.
I modified my example so that agents are created with no allegiance.
My step definition of the step in the model hasn't changed, apart from using allegiance and changing 'Mixed' to 'Neutral' in the if... else...
def step(self):
self.datacollector.collect(self)
# groupby returns a dictionary of the different allegiances with a list of agents
grouped_agents = model.agents.groupby("allegiance")
for ally, similars in grouped_agents:
if ally != "Neutral":
similars.shuffle_do("give_money", similars)
else:
similars.shuffle_do("give_money", self.agents) # This allows mixed to trade with anyone
I feel that the result is a more interesting histogram that shows the Neutrals end up poorest with 0 or 1, having given their money away, but not received any money from green or blue.
I feel this may be closer to what was originally intended in the Group by example, as the definition of the model's step can deal with a mix of ethnicities, but this doesn't actually occour in the original example.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The Group By example in the Introductory Tutorial -- The Boltzmann Wealth Model sets up 3 ethnicities in the model, but then chooses just one at random and sets all agents to this ethnicity
This results in a monotone chart.
On a separate issue I changed 'ethnicity' to 'allegiance', as I feel it is less contentious.
I modified my example so that agents are created with no allegiance.
This is reflected in the Agent Class __init__. This class also has a new choose_allegiance function defined.
After creating the Agents the model than asks them to choose their allegiance.
When plotting the histogram I added the multiple='stack' parameter to produce a stacked histogram.
My step definition of the step in the model hasn't changed, apart from using allegiance and changing 'Mixed' to 'Neutral' in the if... else...
I feel that the result is a more interesting histogram that shows the Neutrals end up poorest with 0 or 1, having given their money away, but not received any money from green or blue.
I feel this may be closer to what was originally intended in the Group by example, as the definition of the model's step can deal with a mix of ethnicities, but this doesn't actually occour in the original example.
Beta Was this translation helpful? Give feedback.
All reactions