Ilaria Brustolon

Computer Science and Simulation for Economics

Project work on

"Virus spread and social welfare."


The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.

powered by NetLogo

view/download model file: virus_spread_and_social_welfare.nlogo


The model shows the diffusion of a virus and its connection with adults' wealth.
The world is simplified, there are the houses, the cinema, the bar, the pharmacy and the hospital. Adults live their life going to the different places. They can become infect by the virus attack or by the contagion and they diffuse the virus in the street, in the cinema and in the bar if they are near infected people.
If they go to the hospital thay could generate a new life or die,they heal if they go to the pharmacy, and they enjoy going to the cinema or to the bar.

Structure of the model:
Time: Discrete form, 1 period is 1 cycle of daybyday;
Space: Grid 16 X 16;
Individual behavior: Stochastic;
Expectations: There is no expectation;
Interaction: Localized virus spread in the street and news share in the different places of the world;


The first procedure is SETUP:
It regenerates the black screen of the interface;
Different places in the world are built: homes, pharmacy, bar, cinema and the hospital.
A number of adults equal to the value of the slider initial_adults is created.
Turtles do not have the shape of the triangle but that of a man stylized with pink color, number 19, the state of infection "no", and a wealth equal to starting_wealth slider.
The latest instructions of the setup procedures allocate the next globals variables: street diffusion, newlife days at the value 0 and current_adults at the value of initial_adults.
The world is thus created.

The second procedure is DAY , which is not activated from the button but it is one of the procedures of daybyday.
The instructions are:
Initially a variable called cure_probability is assigned to adults with a casual generation into the interval [0,100].
If age < 10, there is a probability of 15% to die and a probability of 85% to alive going out of the hospital.
If age is between 10 and 20 adult has a probability of 80% (if age is between 20 and 30 it is not 80 but 50 ) * birth_probability value to generate a new life. He will spend 10 points of wealth but if he is poor the State will pay. He has 10% probability to heal if he is infect . The costs depend on the choser living_cost and the percentage of state assistance slider.
Then there is 10% (15% if age is between 20 and 30) probability to die . If adult is older then 30 , if cure_probability is < 80 adult will die otherwise he will go to the cinema, to the bar or to the pharmacy.
When adult dies the state_charge goes down the variable cemetery increases and the wise_knowledge too. If adult is still alive after the hospital visit, out_of_hospital is 1, he goes to the pharmacy if he is infect with a probability that is 66- his infect_knowledge, and if he is sane he goes to the bar or to the cinema with a probability that is 66 + sane_knowledge.
If switch knowledge is on he changes his probability of going to pharmacy or cinema and bar because he understand that he would be better to go to the pharmacy if he is infect. His knowledge is increased by the wise knowledge and by the crowd knowledge, crowd are people that populate the same place that share the same information. The importance of this different news depend on the apposite sliders personal_experience, wise_experience and crowd_experience.
When adult goes to bar he spend a part of his wealth and if there is anyone infected this could infect other people with a probability depending on the bar_cleanliness.
When adult goes to cinema he spend part of his wealth depending on the living costs, then he could became infect if cinema cleanliness is low.
When adult goes to pharmacy he heals and he spend points of wealth referring to living cost.

The procedure STREET simulates the movement of adults from various places in homes and vice versa. The procedure does not have a button staff but is part of the procedure daybyday.
Adults to move towards a coordinated x and y coordinate a randomly generated .
There are 4 infected areas with a radius of 3,an infected adult has 10% chance of spreading the virus,if the virus is transmitted to a person already infected, he takes a shade of color equal to 17.

The procedure VIRUS has its own button on the main screen: for a number of times equal to the entire value of virus_strength * current_adults / 100 there will be the order to a generic adult to change his label infect in "yes" and to take a color equivalent to 18.

The procedure TAX is the tax payment by rich adults, it is launched every 50 days,or the user can activate the procedure pressing the button tax in the interface. During the procedure there is a turtle,collector, with the form of "sad face".

The procedure PLOTS1 is referred to the chart "rich vs. Poor". I created two pens, one follows the trend of variable maxwealth, maximum wealth, and the second of minwealth, wealth minimal.

The procedure PLOTS2 regards the chart "healthy vs Infect", here there are 2 pens, the first monitors the number of infected and the second rather than the healthy.

The procedure PLOTS3 regards the chart "age", here there are 3 pens, the maximum age the medium age and the minimum age.

The procedure DAYBYDAY has the appropriate button on the main screen. At its activation, the followers procedures are called in:

Age of people is increased of 1.

Analyzing the module of the division between day and 40 the value season becomes autumn, hiver, spring and summer, the virus is more stronger in spring and autumn.

Every 50 days rich people pay tax.

If adults are 0 the program stops.


You create the world with the button setup and with button daybyday the adults start to interact in the world. On the interface there are a lot of variables like initial_adults,virus_strength, bar_cleanliness, health_care, starting_wealth, living_cost, birth_probability,wise_experience, personal_experience and crowd_experience that can be moved by their sliders and chosers, their changing modifies the virus spread the social welfare of the world.


Find the value of each variable that leads the model to equilibrium, in order to define an equilbrium asset.
Move each variable from the equilibrium to understand the different consequences on the model.
Interact the variables moving together.


About the world:
- Introduce a less simple world with more places or introduce a true map as world;
- Introduce rules to create a structured world, for examples youngs go to school and man go to work. Youngs don't earn...
About the rules:
- Introduce new system of salary, by presenting different working places;
About the turtles:
- Create agents with mind, with RNA system, in order to let them optimize their actions (enjoy or work) in order to maximize utility and satisfaction.


Wilensky, U. (1997). NetLogo AIDS model.
Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
Copyright 1997 Uri Wilensky. All rights reserved.
See for terms of use.


The virus spread is analized in, this is an european project started in 2004.
Another site,, presents a project to improve the efficiency in the emergence.