## "Patients and hospitals."

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.

## WHAT IS IT?

This work based on Netlogo has the intent of building a semplified simulation of the dynamics that run the movement of patients between different hospitals.
Our objective is to understand how some variables that we presume be at the base of these movements create obstacle or encourage this changing.
From the empirical evidence reached through experiments we will deduct the behaviour of patients and try to understand if they are rational agents or not.

## HOW IT WORKS

At the beginning of the simulation the turtles distribute theirselves randomly in one of the four hospitals.
At the “go” if they are not happy (the crowdedness of patients in their hospital is not in the interval setted with the sliders and the cost of ticket are too high) and their personal level of income and familily constraint allows it, they start to move.
Basically they turn left or right and they move forward of 8 steps.

## HOW TO USE IT

The setup button creates the starting situation in our simulation.
After, the go button makes the simulation changing from static to dynamic.
We have different sliders that control the varibles in our system:
1)“the number slider” controls how many patients are in our simulation.
2)“the income limit slider” control the minimum income necessary for the patients to move.
3)“the family constraint limit” slider control the maximum level of familiy constraint that allows to move
4) “crowdedness lim inf” and “lim sup” are two sliders that control the interval of the crowdedeness accepted by the patients
There is also a graph and four monitors that plot the number of patients in all hospitals.
5) the “ticket cost” slider controls the price level of the ticket
Two monitors show the number of patients happy and unhappy.

## THINGS TO NOTICE

At the end of the simulation look at the monitors displaying the number of patients that are happy and unhappy.
Try to understand when the model reaches its steady state and why.

## THINGS TO TRY

Try to change the values of the sliders in order to understand how change the model.
1) modify the overall number of patients
2) modify the income limit
3) modify the family constraint limit
4) modify the crowdedness lim sup and lim inf values

## NETLOGO FEATURES

To construct the environment of my simulation I divide the space in four rectangles,
giving to the patches that identify each rectangle a different colour.

The patients are distributed following a random command.
I order the turtles at the setup to place in one of the four hospitals randomly.
Before I have identify “hospitals” with the patches belonging to the four hospitals.

## EXTENDING THE MODEL

In order to implement my project we can add new sliders like one controlling the degree of emergency that each patients holds or one controlling in a “crowdedness way like” the interval of queue that a patient can accept.

## RELATED MODELS

The model take inspiration mainly from a work of the Netlogo’s library.
The model is name “Party” and is a social simulation that shows how people interact
in a party. People have a refence Tollerance slider that defines their comfort level with a group that has members of the opposite sex.
When they are unhappy they move to another group.

## CREDITS AND REFERENCES

This model was created as a project work for the course “Simulation Models for Economics” by Professor Pietro Terna, Faculty of Economics, University of Turin.

As source of inspiration I also report these two papers:

# CODE

```globals [hospitals patient_hospital-1 patient_hospital-2 patient_hospital-3 patient_hospital-4]

turtles-own [family_constraint
income
happy?]

to setup
;; (for this model to work with NetLogo's new plotting features,
;; __clear-all-and-reset-ticks should be replaced with clear-all at
;; the beginning of your setup procedure and reset-ticks at the end
;; of the procedure.)
__clear-all-and-reset-ticks
set hospitals patches with [hospital?]
setup-hospital-1
setup-hospital-2
setup-hospital-3
setup-hospital-4
set-default-shape turtles "person"
setup-turtles
count-turtles
my-setup-plots
my-update-plots
end

to setup-hospital-1
ask patches with [ pxcor >= -16 and pxcor < -8 and pycor >= -8 and pycor <= 8]
[ set pcolor yellow]
end

to setup-hospital-2
ask patches with [ pxcor >= -8 and pxcor < 0 and pycor >= -8 and pycor <= 8 ]
[ set pcolor red]
end

to setup-hospital-3
ask patches with [ pxcor >= 0 and pxcor < 8 and pycor >= -8 and pycor <= 8 ]
[ set pcolor blue]
end

to setup-hospital-4
ask patches with [ pxcor >= 8 and pxcor <= 16 and pycor >= -8 and pycor <= 8 ]
[ set pcolor brown]
end

to setup-turtles
create-turtles number
[set color white
move-to one-of hospitals
set family_constraint random 10
set income random 100]

end

to-report hospital?
report
(pxcor >= -16 and pxcor <= 16 and pycor >= -8 and pycor <= 8)
end

to count-turtles
set patient_hospital-1 count turtles with [ pxcor >= -16 and pxcor < -8 and pycor >= -8 and pycor <= 8]
set patient_hospital-2 count turtles with [ pxcor >= -8 and pxcor < 0 and pycor >= -8 and pycor <= 8 ]
set patient_hospital-3 count turtles with [ pxcor >= 0 and pxcor < 8 and pycor >= -8 and pycor <= 8 ]
set patient_hospital-4 count turtles with [ pxcor >= 8 and pxcor <= 16 and pycor >= -8 and pycor <= 8 ]
end

to update-happiness
ask turtles with [ pcolor = yellow ] [set happy? crowdedness_lim_inf < patient_hospital-1 and patient_hospital-1 < crowdedness_lim_sup and ticket_cost < income_limit / 2]
ask turtles with [ pcolor = red ] [set happy? crowdedness_lim_inf < patient_hospital-2 and patient_hospital-2 < crowdedness_lim_sup and ticket_cost < income_limit / 2]
ask turtles with [ pcolor = blue ] [set happy? crowdedness_lim_inf < patient_hospital-3 and patient_hospital-3 < crowdedness_lim_sup and ticket_cost < income_limit / 2]
ask turtles with [ pcolor = brown ] [set happy? crowdedness_lim_inf < patient_hospital-4 and patient_hospital-4 < crowdedness_lim_sup and ticket_cost < income_limit / 2]
end

to go
tick
my-update-plots
end

to leave-if-unhappy
if not happy? and family_constraint < family_constraint_limit
[
fd 8
]
if not happy? and income > income_limit and family_constraint < family_constraint_limit
[
fd 16
]

end

to my-setup-plots
set-current-plot "Number of patients"
set-plot-y-range 0 number
end

to my-update-plots
set-current-plot "Number of patients"
set-current-plot-pen "hospital-1"
plot count turtles with [ pxcor >= -16 and pxcor < -8 and pycor >= -8 and pycor <= 8]
set-current-plot-pen "hospital-2"
plot count turtles with [ pxcor >= -8 and pxcor < 0 and pycor >= -8 and pycor <= 8 ]
set-current-plot-pen "hospital-3"
plot count turtles with [ pxcor >= 0 and pxcor < 8 and pycor >= -8 and pycor <= 8 ]
set-current-plot-pen "hospital-4"
plot count turtles with [ pxcor >= 8 and pxcor <= 16 and pycor >= -8 and pycor <= 8 ]
end

```