Eadan Fahey

... 

Public Listings

ORDER BY
Behavior
Barabási–Albert Network
@eadan/create_barabasi_albert_network.js
This behavior generates agents connected on a Barabási–Albert network. Networks generated using this behavior have the "scale-free" property, that is, the degree distribution follows a power law. The following variables controlling the structure of the network: num_nodes: (int) number of nodes (i.e. agents) in the network. avg_degree: (int) average degree of the network. This behavior is intended to be used in conjunction with @hash/create_agents.js. A minimal init.json is: [ { "agentid": "networkcreator", "behaviors": [ "@eadan/createbarabasialbert_network.js", "@hash/create_agents.js", "@hash/remove_self.js" ], "network_template": { "name": "person", "num_nodes": 1000, "avg_degree": 10, "behaviors": ["AGENTBEHAVIOR1.js", "AGENTBEHAVIOR2.js"], "field_a": "xyz" } } ] The state of each agent in the network will be populated with a neighbors field containing a list of agent IDs. These IDs may be used to message an agent's neighbors. For example: for (agentID of state.get("neighbors") { state.addMessage(agentID, "hello", {name: "Alice"}); } `
Simulation
3
SIR Infection Network
This is an SIR (susceptible-infected-recovered) infection model with agents connected on a network. It is based on the paper "An Agent-Based Model of COVID-19", C. Wolfram. The model The network is constructed according to the Watts-Strogatz algorithm. This algorithm produces "small-world" networks with high clustering. The parameters numagents, avgdegree and beta control the number of nodes in the network, the average number of edges between nodes, and the randomness of edges, respectively. Agents may have one of three statuses: susceptible, infected or recovered. Agents with status susceptible may become infected by interacting with one of their infected neighbors. Infected agents eventually recover. Recovered agents cannot become infected again. The network is initialized with a certain number of infected agents, controlled by the initialnuminfected parameter. Each agent has their own recovery time sampled from an exponential distribution with mean avgrecoverytime. At each time step agents may meet with a number of their connected neighbors. This number is sampled from an exponential distribution with mean avg_meetings. Visualization The plot shows the number of susceptible, infected and recovered agents over time. Observations The number of infected agents tends to grow, reaching a peak which is lagged by the number of recovered agents, until finally there are no infected agents. After the average number of meetings per time step passes a certain point, the model undergoes a phase transition where almost all of the agents become infected. Before this point, the number of interactions is low enough where most of the susceptible agents never become infected. A similar phenomenon may be observed by increasing the average degree of the network. Extending the model Here are a few enhancements that could be made to the model Not all infections have long-lasting immunity. Extend the model by allowing some of the recovered agents to become infected again. Heterogeneity in meeting rates. Currently, all agents share the same distribution for the number of interactions at each time step. Extend the model by giving each agent their own distribution. Similarly, one could simulate the effect of quarantines by restricting the ability of some agents to have any interactions. Try different network models, such as the scale-free Barabási–Albert model or the Erdős–Rényi model.
Behavior
Watts-Strogatz Network
@eadan/create_watts_strogatz_network.js
This behavior generates agents connected on a Watts-Strogatz network. The following variables controlling the structure of the network must be set in globals.json: num_nodes: (int) number of nodes (i.e. agents) in the network. avg_degree: (int) average degree of the network. beta: (float) rewiring probability. This behavior is intended to be used in conjunction with @hash/create_agents.js. A minimal init.json is: [ { "agentid": "networkcreator", "behaviors": [ "@eadan/createwattsstrogatz_network.js", "@hash/create_agents.js", "@hash/remove_self.js" ], "network_template": { "name": "person", "behaviors": ["AGENTBEHAVIOR1.js", "AGENTBEHAVIOR2.js"], "field_a": "xyz" } } ] The state of each agent in the network will be populated with a neighbors field containing a list of agent IDs. These IDs may be used to message an agent's neighbors. For example: for (agentID of state.get("neighbors") { state.addMessage(agentID, "hello", {name: "Alice"}); } See the SIR Infection Network model for an example use-case of this behavior.
Simulation
1
Yard Sale Wealth Model
This is a simple model of wealth dynamics inspired by the "Yard-Sale model" first proposed by [1] and expanded upon by [2]. This is a good introductory article explaining the model: https://www.scientificamerican.com/article/is-inequality-inevitable/ The model All agents start with equal wealth. Agents are shown on a grid with each agent's wealth represented as the cell height on a logarithmic scale. The wealth dynamics are outlined as follows: At each step an agent engages in at most one transaction with another agent. In a transaction a fraction of the poorer agent's wealth is transferred. The direction of the transfer is determined by a coin flip. The coin may be biased with a "wealth attained advantage". At each time step wealth may be redistributed. Agents pay taxes and receive benefits. An agent with wealth greater than the average will see a reduction in their wealth, and vice-versa for an agent with wealth less than the average. The plots window shows the wealth of the richest agent and the Gini coefficient over time. Parameters The simulation is controlled with the following global parameters: wealthtransferrate: the proportion of the poorer agent's wealth transferred during each transaction. Can take values in the range [0, 1]. tax_rate: the proportion of each agent's wealth which is taxed and redistributed at each time step. Can take values in the range [0,1]. wealth_bias: the bias of the coin towards the agent with greater wealth in the transaction. A value of 0 implies no bias, i.e. a fair coin. Can take any non-negative value, but values in the range [0,5] should be sufficient to observe most behavior. Wealth dynamics Several interesting behaviors may be observed in the following cases. Complete oligopoly Without any redistribution, setting tax_rate = 0, eventually a single individual will hold all wealth. This is independent of the bias and the transfer rate. Low inequality Even a small tax rate is enough to prevent a single individual from controlling all the wealth. The simulation stays in an equilibrium, with wealth being redistributed among all agents at each time step. Wealth attained advantage Although taxes pull each agent's wealth towards the average wealth, biasing the transaction coin has the opposite effect, adding more variability into the wealth distribution. Even with some taxation, increasing wealth_bias will tend to condense wealth of the system in a small number of agents. References [1] Distributions of money in model markets of economy, (https://arxiv.org/abs/cond-mat/0205221v1) [2] Oligarchy as a Phase Transition: The effect of wealth-attained advantage in a Fokker-Planck description of asset exchange (https://arxiv.org/abs/1511.00770v2)
Simulation
1
Firefly Synchronization
This model demonstrates how distributed agents may synchronize their actions without centralized decision making. The model consists of fireflies randomly moving on a grid. Fireflies flash for one time step by turning yellow. The simple mechanism controlling their flashing behavior is: All fireflies have an internal clock with the same number of time steps. The length of this clock is controlled by the period parameter. Each firefly starts its clock at a random position. When its clock resets to zero, the firefly flashes. If a firefly sees a nearby firefly flash, it synchronizes its clock with that firefly. Fireflies start off flashing erratically, but as the simulations progresses you will see clusters of fireflies flashing together. Eventually, one of these clusters dominates and all fireflies flash in synchrony.