1 of 74

Agent simulations of complex systems: let's learn more about them

FEDORA - Future-oriented Science EDucation to enhance Responsibility and engagement in the society of Acceleration and uncertainty This project received funding from the European Union's Horizon 2020 Research and Innovation program under Grant Agreement n° 872841 www.fedora-project.eu

2 of 74

What words/concepts do you associate with "complexity"?

  • ...
  • ......
  • .........

3 of 74

Complex is not complicated!�Let's look inside the word

Complex, complicated, simple have an Indo-European root in common: -plek

In Latin we have

  • plicare = to fold
  • plectere = to weave

which resulted in

  • Complicated = of something that has folds and can be di-spliced
  • complex = of something that is intertwined and cannot be di-explained

4 of 74

Nico Vascellari - Nest, 2009 - courtesy Acacia Collection - photo Ela Bialkowska

5 of 74

Complex is many things

6 of 74

  • Complex systems should be studied both with the "magnifying glass," to study the laws of the minimal constituents, and with the "wide-angle lens," to get the overall view of the system

Complex because it can be studied at multiple levels

7 of 74

In two pictures (and a pun)

I model people's behavior

or

I focus on the agent!

8 of 74

  • If the laws describing a system are linear, small errors in the determination of the independent variables correspond to small errors in the solutions as well

  • In complex systems this is often not the case....

  • Butterfly effect or "deterministic chaos"

Complex because mathematically

non-linear

9 of 74

  • If in linear systems "the whole is equal to the sum of the parts," in complex systems this is not true

  • Emergent properties occur that characterize the system as a whole (at the macroscopic scale) and are not simply attributable to its individual component parts (microscopic scale)

Complex because it shows emerging properties

10 of 74

  • Complexity science covers so many disciplinary areas

  • Brain
  • Forest
  • Climate
  • Financial systems
  • Languages

  • They blur the distinctions between hard sciences and social sciences, between qualitative and quantitative methods

  • And the same goes for simulations....

Complex because multi-inter-transdisciplinary

  • City
  • Internet
  • Crystals
  • Fluids
  • Ant hills

  • Computational systems
  • Society
  • Cell
  • Flocks of birds

11 of 74

From the lecture of Prof. Bonacorsi

12 of 74

What are we going to do today?

  • An emblematic case for studying the equation-agent difference
  • Some very famous models and agent simulations in the field of complex systems

  • We don't want to become wizards of agent simulation!
  • However, we will try to explore the simulations to find out �what they look like and what they have to tell us

13 of 74

14 of 74

The phenomenon of predation

  • In many animal populations, similar dynamics occur with regard to interactions between prey and predators

  • If one considers so many generations and compares the size of prey and predator populations, one notices that there are regular phase-shifted fluctuations

  • When prey increases, there are fewer predators and vice versa

15 of 74

Predator-prey dynamics (Lotka-Volterra model)

  • A possible and very famous model

  • Assumptions on which the model is based:
    • Prey have unlimited food
    • Predators' only source of livelihood is prey
    • Prey only die a natural death
    • No evolutionary mechanisms are in place
    • The external environment does not change in favor of any of the species

16 of 74

Predator-prey dynamics (Lotka-Volterra model)

 

x(t) = number of prey at time t

dx(t)/dt = rate of change of the prey population over time

y(t) = number of predators at time t

dy(t)/dt = rate of change of predator population over time t

Coefficients:

a = birth of prey

b = predation

c = birth of predators

d = natural death of predators

17 of 74

Lotka-Volterra: equation-based simulation

  • The model is already expressed as a system of two differential equations

  • Let's solve them numerically...

  • We get the evolution over time of the two populations

18 of 74

Lotka-Volterra: equation-based simulation

  • A stable periodic solution: cyclical fluctuations between prey and predator populations

19 of 74

From model to reality to case study

  • The model in reality

20 of 74

From model to reality to case study

  • Even for this extremely model-adherent case study, all of its assumptions did not apply:
    • The environment changes and moose do not find unlimited food
    • The wolf population has been affected by diseases

  • You can refine the model by adding more parameters
  • Habitat variability parameter: takes into account density-dependent factors (diseases) and also independent factors (weather)
  • Carrying capacity of the environment: is the maximum number of individuals in a population that an environment can support

21 of 74

What if we want to change our perspective?

Instead of writing with an equation how populations evolve over time, let us imagine that we have many wolves (predators) and many sheep (prey) waiting for precise instructions from us on how to behave.

Let's move on to agent simulation

Task 1) What rules should individual predators and prey follow to give the observed oscillation result?

22 of 74

Different rules for wolves and sheep

Wolf:

  • He starts his life with a random amount of energy
  • With each tick of the simulation, it moves to an adjacent cell and its energy decreases by E1
  • If a sheep is in the same box, it eats it and its energy increases by E 2
  • When the energy reaches 0, the wolf dies
  • At any given time, it has a probability R1 of reproducing itself

Sheep:

  • With each tick, it moves to an adjacent cell
  • At any time, it has a probability R2 of reproducing itself

23 of 74

Differences between equation-based and agent-based model

Wolf:

  • He starts his life with a random amount of energy
  • With each tick of the simulation, it moves to an adjacent cell and its energy decreases by E1
  • If a sheep is in the same box, it eats it and its energy increases by E 2
  • When the energy reaches 0, the wolf dies
  • At any given time, it has a probability R1 of reproducing itself

Sheep:

  • With each tick, it moves to an adjacent cell
  • At any given time, it has a probability R2 of reproducing itself

 

x(t) = number of prey at time t

dx(t)/dt = rate of change of the prey population over time

y(t) = number of predators at time t

dy(t)/dt = rate of change of predator population over time t

Coefficients:

a = frequency of prey birth

b = predation frequency

c = birth frequency of predators

d = frequency of natural death of predators

24 of 74

Differences between equation-based and agent-based model

(Each individual) Wolf:

  • He starts his life with a random amount of energy
  • With each tick of the simulation, it moves to an adjacent cell and its energy decreases by E1
  • If a sheep is in the same box, it eats it and its energy increases by E 2
  • When the energy reaches 0, the wolf dies
  • At any time, it has a probability R1 of reproducing itself

(Every single) Sheep:

  • With each tick, it moves to an adjacent cell
  • At any time, it has a probability R2 of reproducing itself

 

x(t) = number of prey at time t

dx(t)/dt = rate of change of the prey population over time

y(t) = number of predators at time t

dy(t)/dt = rate of change of predator population over time t

Coefficients:

a = frequency of prey birth

b = predation frequency

c = birth frequency of predators

d = frequency of natural death of predators

25 of 74

Differences between equation-based and agent-based model

(Each individual) Wolf:

  • He starts his life with a random amount of energy
  • With each tick of the simulation, it moves to an adjacent cell and its energy decreases by E1
  • If a sheep is in the same box, it eats it and its energy increases by E 2
  • When the energy reaches 0, the wolf dies
  • At any time, it has a probability R1 of reproducing itself

(Every single) Sheep:

  • With each tick, it moves to an adjacent cell
  • At any time, it has a probability R2 of reproducing itself

 

x(t) = number of prey at time t

dx(t)/dt = rate of change of the prey population over time

y(t) = number of predators at time t

dy(t)/dt = rate of change of predator population over time t

Coefficients:

a = frequency of prey birth

b = predation frequency

c = birth frequency of predators

d = frequency of natural death of predators

In the equation model, only macroscopic quantities appear, whereas in the agent model we focus on the individual with whom the rules are associated

26 of 74

Differences between equation-based and agent-based model

Wolf:

  • He starts his life with a random amount of energy
  • With each tick of the simulation, it randomly moves to an adjacent cell and its energy decreases by E1
  • If a sheep is in the same box, it eats it and its energy increases by E 2
  • When the energy reaches 0, the wolf dies
  • At any time, it has a probability R1 of reproducing itself

Sheep:

  • With each tick, it moves to an adjacent cell
  • At any time, it has a probability R2 of reproducing itself

 

x(t) = number of prey at time t

dx(t)/dt = rate of change of the prey population over time

y(t) = number of predators at time t

dy(t)/dt = rate of change of predator population over time t

Coefficients:

a = frequency of prey birth

b = predation frequency

c = birth frequency of predators

d = frequency of natural death of predators

27 of 74

Differences between equation-based and agent-based model

Wolf:

  • He starts his life with a random amount of energy
  • With each tick of the simulation, it randomly moves to an adjacent cell and its energy decreases by E1
  • If a sheep is in the same box, it eats it and its energy increases by E 2
  • When the energy reaches 0, the wolf dies
  • At any time, it has a probability R1 of reproducing itself

Sheep:

  • With each tick, it moves to an adjacent cell
  • At any time, it has a probability R2 of reproducing itself

 

x(t) = number of prey at time t

dx(t)/dt = rate of change of the prey population over time

y(t) = number of predators at time t

dy(t)/dt = rate of change of predator population over time t

Coefficients:

a = frequency of prey birth

b = predation frequency

c = birth frequency of predators

d = frequency of natural death of predators

The equation model is deterministic while the agent model is probabilistic

28 of 74

29 of 74

Where do we find these rules in the simulation?

30 of 74

Where do we find these rules in the simulation?

31 of 74

What happens to the system with these rules?

  • The model rules reproduce the oscillation of the two populations we observed earlier

  • This pattern, however, is �only transient and unstable

  • Or the number of sheep �"explodes" by increasing�exponentially...

32 of 74

What happens to the system with these rules?

  • Or both populations end up going extinct after a few fluctuations....�

Task 2)

  • Why does this happen?

  • What do we need to �fix in our �model?

33 of 74

Actually, the behavior observed with simulation is not so absurd...

  • In 1934, the first laboratory experiments on prey-predator interactions found the same result!

  • Either the predators would eat all the prey and then starve, or the predators would die first and the prey would multiply wildly

  • What is similar about laboratory and simulation, and different from the natural environment?
  • What is similar about laboratory and simulation, and different about the assumptions of the mathematical model?

34 of 74

Laboratory vs. natural environment

  • In the laboratory, there are no limits to prey population growth
  • In nature yes (finite resources and density)

  • There is no "environmental complexity" in the laboratory: prey cannot escape predators by taking refuge in a certain area of the environment

  • Our agent simulation also experiences the same limitations, so we reproduced the behavior of the experiment

35 of 74

A struggle between models

  • Yet the Lotka-Volterra model also had the same assumptions but the solutions�of the equations are stable and�reproduce the behavior�in nature, but not that�in the laboratory!

  • Is it the Lotka-Volterra model �that is "false" or the one with �agent?

  • Compared with agent simulations, Classical equation-based models make it very easy to get implausible macroscopic results!

36 of 74

A struggle between models

  • This happens because by modeling to equation, I focus on what I want to achieve (stability)

  • Whereas in the agent approach, I am only concerned with assigning rules, without any assumptions at the macro level

  • It is therefore possible that there simply are NO rules at the local level that produce for us the stability result that the equation model predicted!

37 of 74

Differences between equation-based and agent-based model

Wolf:

  • He starts his life with a random amount of energy
  • With each tick of the simulation, it moves to an adjacent cell and its energy decreases by E1
  • If a sheep is in the same box, it eats it and its energy increases by E 2
  • When the energy reaches 0, the wolf dies
  • At any time, it has a probability R1 of reproducing itself

Sheep:

  • With each tick, it moves to an adjacent cell
  • At any time, it has a probability R2 of reproducing itself

 

x(t) = number of prey at time t

dx(t)/dt = rate of change of the prey population over time

y(t) = number of predators at time t

dy(t)/dt = rate of change of predator population over time t

Coefficients:

a = frequency of prey birth

b = predation frequency

c = birth frequency of predators

d = frequency of natural death of predators

The equation model contains a pre-judgment about the system (top-down), while the agent model produces everything from the rules (bottom-up)

38 of 74

Let's try some new rules

Wolf:

  • He starts his life with a random amount of energy
  • With each tick of the simulation, it moves to an adjacent cell and its energy decreases by E1
  • If a sheep is in the same box, it eats it and its energy increases by E 2
  • When the energy reaches 0, the wolf dies
  • At any given time, it has a probability R1 of reproducing itself

Sheep:

  • He starts his life with a random amount of energy
  • With each tick, it moves to an adjacent cell and its energy decreases by E3
  • If grass is found in the same box, he eats it and his energy increases by E4
  • When the energy reaches 0, the sheep dies
  • At any given time, it has a probability R2 of reproducing itself

Land:

  • If it is green: do nothing
  • If it's brown, wait for X tick and then it turns green

39 of 74

What do we get?

  • With these new rules, we have stable fluctuations between the amount of prey and predators (and grass!).

  • By limiting the sheep's resources, you increase their chances of survival (enrichment paradox)

  • Adding a level of complexity in this case resulted in increased stability, not more "chaos"!

Task 3) Experiment with the same model as above in the second variation and note the main phenomena observed.

40 of 74

41 of 74

A model for changing opinion

  • What is an opinion? For example, something that an individual "owns" and can change as a result of interactions with other individuals or the outside world
  • Let us simplify: each agent has an opinion that may be worth 0 or 1 and is influenced by its neighbors

  • Each agent will assume the same opinion as the �majority of his neighbors. If his neighbors are�tied, he does not change his opinion.

Task 4) What do we expect to happen in a �system in which every agent follows �this rule?

42 of 74

43 of 74

Task 5) Experiment with simulation trying to explain why the behaviors you observe at the macroscopic level.

44 of 74

Where do we find the rules in the simulation

Definition of agent

45 of 74

For each agent, we look at the sum of the surrounding agents' opinions and update the variable total

After calculating the sum of neighbors' opinions, the reference agent assumes the opinion of the majority of its neighbors.

The procedure continues until no agent changes his or her opinion any more

46 of 74

What happens with these rules?

47 of 74

Two possible variations

It is possible to modify the basic model with two variations.

By selecting change-vote-if-tied? ON, in case of a 4-4 tie, the reference agent always changes its opinion.

By selecting instead award-close-calls-to-loser? ON, in case of a 5-3 result, the reference agent votes as the minority instead of as the majority.

48 of 74

Stable regions of the same color are formed, but there are fluctuations at the edges

4-4

Parity

FLIP

4-4

Parity

FLIP

49 of 74

4 vs 4 🡪 tie 🡪 change to 0 the opinion of the central agent

0

0

0

0

1

1

1

1

1

0

0

0

0

0

1

1

1

1

4 vs 4 🡪 tie 🡪 change to 1 the opinion of the central agent

50 of 74

Wait a minute,

I had perhaps not signed up

to a class in physics!!!

51 of 74

In physics there is actually a very similar phenomenon...

52 of 74

A model of a magnet

  • At the macroscopic level, a magnet is an object capable of generating a magnetic field

  • At the microscopic level, it is a spin lattice

53 of 74

A model of a magnet

  • At the macroscopic level, a magnet is an object capable of generating a magnetic field

  • At the microscopic level, it is a spin lattice

Ising's model

  • Spins are nothing but "objects" that can have an up or down property, 0 or 1, blue or green

  • They have the property of influencing each other with their neighbors

54 of 74

Does this remind us of anything?

  • At low temperatures, the spins tend to align, causing the material to spontaneously magnetize 🡪 ferromagnetic phase system

  • When the temperature is high, there is no spontaneous magnetization 🡪 paramagnetic phase system

55 of 74

The emergent property of the system

  • Magnetization configurations are typical of the macroscopic scale of the system
  • Iron/paramagnetic properties depend on the spins of individual lattice points

  • Like the distribution of opinions in the "voting" simulation, here we have different magnetization configurations

  • This is an emergent property, visible at the macroscopic scale of the system but dependent on the actions of individual agents

56 of 74

The power of abstraction

  • Ising's model of magnetization is very simple and very abstract

  • It can be used to describe a wide range of physical phenomena, for example as a model of liquid/gas phase transitions

  • It has also been used as a basis for simulating phenomena outside physics (in the social sciences), such as change of opinion!

57 of 74

The power of abstraction

"For interdisciplinarity, complex systems are important not only in physics and mathematics but also in epidemics and, I don't know, in the social sphere, and this connects to the third element, which would be the science-society interweaving."

"You can study what behaviors between people are like anyway, run simulations."

58 of 74

A reading on this topic

59 of 74

60 of 74

A model for cooperative behaviors

  • Cooperation is an evolutionary mechanism, much studied in biology and the social sciences
  • Different types of agents compete for the same resources, and obtaining the resources determines their evolutionary success

  • Two kinds of agents (cows), gluttonous and cooperative

61 of 74

A model for cooperative behaviors

  • Cooperation is an evolutionary mechanism, much studied in biology and the social sciences
  • Different types of agents compete for the same resources, and obtaining the resources determines their evolutionary success

  • Two kinds of agents (cows), gluttonous and cooperative

They eat as much as possible, regardless of the abundance of resources

They only eat if the resources are above a certain threshold (below that threshold, resources take longer to regenerate)

62 of 74

A model for cooperative behaviors

  • Cooperation is an evolutionary mechanism, much studied in biology and the social sciences
  • Different types of agents compete for the same resources, and obtaining the resources determines their evolutionary success

  • Two kinds of agents (cows), gluttonous and cooperative

Task 6) What do we expect from a system in which there are only these two types of agents behaving this way?

63 of 74

64 of 74

Only the selfish survive!

65 of 74

Number of agents at the beginning

"Step" of agents in moving

Probability of having cooperative agents (in this case half are cooperative, half are selfish)

Energy lost by agents in reproducing themselves

Energy required for agents to reproduce

Energy lost at each turn (without eating) i

66 of 74

Energy gained from eating

Probability of grass growth when low

Maximum grass height

Threshold between low grass and high grass

Probability of grass growth when high

67 of 74

Different scenarios...

  • The many parameters of the simulation allow for many different "experiments" by changing the various parameters, resulting in different scenarios at the collective level

Try some configurations in groups, changing one parameter at a time: what do you get? Why?

68 of 74

An example

By changing the movement the cows can make at each step, it varies the number of iterations required for the greedy population to pass cooperatives

Indeed, they will always find grass to eat, even if they have already eaten what was in the previous position.

In contrast, being able to move only short steps in space makes cooperative behavior more convenient.

69 of 74

Another example

We vary the amount of energy each agent spends to move

With little energy expended with each movement, gluttonous cows easily outperform cooperative ones

If we instead increase the value of the parameter, we arrive at a dynamic equilibrium condition in which the two populations coexist

70 of 74

Concluding

  • We have seen many examples of complex systems

  • Simple rules between two agents do not always allow us to explain the evolution of the complex system in a simple way

  • Simulation can help us in this!

71 of 74

Concluding

  • We have seen different forms of modeling, typical of different disciplines

  • Mathematical models consisting of differential equations only

  • Models inspired by the physical interactions of the microscopic world

  • Computational models to build the agent simulations

  • We have seen how these basic simulation ingredients combine to produce not one but many possible configurations

72 of 74

The power of interdisciplinarity

"You cannot isolate one subject because you know that anyway all subjects are also interrelated. Then this aspect we can link it to simulations because it still allows us to analyze a situation from multiple points of view."

"Simulations can allow us to see what would happen if we did certain certain actions."

73 of 74

For the next lecture

Continue to experiment with the three simulations seen today, or with NetLogo in general

Start thinking about possible applications of these simple models to real problems in your daily life or in our society

Next time we will start from here!

74 of 74

for your attention