ART – Individual-based Modelling in Computational Systems Biology
FLAME
Flexible Agent-based
Modelling Environment
Presented by:
Mariam Kiran
1
Talk Agenda
z
z
z
z
z
2
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox
and Rabbit Example
Conclusions
Useful Links
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Studying Complex Systems
z
z
z
z
3
Simulate emergent behaviour in complex
systems like traffic systems.
Self organization depends on individual
interactions.
Systems usually stabilize otherwise go into
chaos.
Bottom-up Approach: Observations on
individual and/or group basis.
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Agent Based Modelling (ABM)
z
z
z
4
From boids (bird flocking) to humans (crowd
behaviour).
Alternative to conventional modelling method
of biological systems using differential
equations.
ABM allows to produce patterns that can be
tested.
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Introducing FLAME
What it is?
Theory behind it
Practical approach
5
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
What is FLAME?
z
z
z
z
6
Stands for Flexible Agent-based Modelling
Environment.
Phd work of Simon Coakley.
Based on formal systems – X machines.
Uses MPI and HPC libraries to parallelize
large simulations.
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
FLAME’s FLexibility
z
Projects using FLAME currently range from
cells to organisms.
–
–
–
–
–
7
Epitheliome project
NF-kB pathways
Cardiac spiral wave propagation
Stem cell colonies
EURACE
Modelling European Economy
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
FLAME : Theory behind it
Each agent is an Xmachine.
8
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Structure of an X-Machine Agent
9
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
FLAME : Theory Behind it
Each agent is an Xmachine.
Parallel – Divide into
space partitions (4).
Each partition is an
X-machine node.
Uses MPI for
message passing.
10
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Structure of an X-machine node
11
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
FLAME : Theory behind it
Each agent is an Xmachine.
Parallel – Divide into
space partitions (4).
Each partition is an
X-machine node.
Uses MPI for
message passing.
Interaction radius
12
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
FLAME - Practical approach
(In 3 steps- describe, start, get)
Model Files
model_name.xml
functions.c
Createstartstates.c
Getdata.c
13
xparser.exe
Compile
Iterations
0.xml
Simulation
Code
Simulation
program
Results
Model Files
XML file
C File
14
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
XML File – Defines the X-machine
Agent
z
Variables are declared as:
<memory>
<var><type>int</type><name>id</name></var>
<var><type>double</type><name>value</name></var>
</memory>
15
z
Functions are given as:
<functions>
<function><name>Firm_3</name></function>
<function><name>Firm_4</name><depends><name>Firm_3</name>
<type>internal</type></depends>
</function>
</functions>
z
Function dependencies
Figure: Example of
the use of function
dependencies.
(From C@S model in
economics)
16
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
XML File (Continued)
z
Communication between agents- Messages
<messages>
<!-------Message posted to record the price inflation --------->
<message>
<name>priceinflation</name>
<note>This message is posted by the firm for calculating next price
of the goods. </note>
<var><type>double</type><name>priceinflation</name></var>
</message>
</messages>
17
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
C File - Defining Rules
z
z
z
C compiler – (Unix: gcc, Windows: mingw)
Return 0 at the end of the function. Returning 1 kills the
agent.
Set and get functions: set_variable(type )
set_id(int i)
get_variable()
z
get_id()
Advanced access pointer
xmachine_memory_aname * xmemory = current_xmachine->
xmachine_aname;
xmemory->varname;
z
Adding new agent
add_xmachinename_agent(variable1, variable2, ...);
18
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
C File (Continued)- Using messages
Adding message
add_messagename_message(variable1, variable2, ...);
z
Reading message
messagename_message = get_first_messagename_message();
while(messagename_message)
{
/* process message code here */
// To access the variable within the message
//messagename_message-> variable;
z
messagename_message =
get_next_messagename_message(messagename_message);
}
19
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Demonstrating FLAME
Case Study: Fox and
Rabbit Example
20
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Step 1: Describe the Model
z
Scenario:
Foxes have a life expectancy which increases if they eat a
rabbit. Foxes look for rabbits and chase them, whereas rabbits
try to dodge the foxes.
z
Identify agents – Fox, Rabbit
Identify agent memory
z
Fox
Rabbit
21
posx, posy, iradius, life_expectancy
posx, posy, iradius, id
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Step 1: Describe the Model (Cont.)
z
Identify functions and messages for communication
Fox
z
z
22
Messages
Chase_rabbits
Dodge_foxes
fox_location
Fox_survives
Rabbit_location
eaten
Fox_location
z
Rabbit
rabbit_location
Determine function dependencies
Using forces to calculate the next location
Using defined radii to check the occurrence of other agents
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Compiling the files – In the Xparser
folder
z
z
Compile the xparser code for exe file
> make
Point the xparser to the xml file:
>xparser.exe ..\predator\predator.xml
Functions.c
Predator.xml
23
main.c
memory.c
xml.c
header.c
makefile
dgraph.dot
dgraph.svg
Files produced (Simulation program)
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Using Dotty to show function
dependency
24
>dotty dgraph.dot
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Using Mozilla Firefox for function
dependencies
25
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Step 2: Starting values of the Model
z
26
Write a program in C/java which can produce
a file ‘0.xml’
<states>
<itno>0</itno>
<xagent>
<name>Fox</name>
<life_expectancy>10</life_expectancy>
<posx>29.113054</posx>
<posy>8.329377</posy>
<iradius>10.000000</iradius>
</xagent>
….
</states>
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Running the model
z
Go to the predator folder
> make
> main.exe 100 its\0.xml
z
27
Produces 100 iteration files
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Step 3: Getting the Results
z
28
Write a program in C/java to extract
information required
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Testing the Model
z
Structural Testing
z
z
z
Functional Testing
z
29
Memory variables
Messages required
Run the simulations to check results
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Conclusion
z
z
z
z
z
z
z
30
Agent based modelling is becoming more
important in research.
Useful way to understand complex systems.
Few uses have given unknown results.
Based on interactions – agent-agent, agentenvironment.
Flexibility of Flame for different scenarios.
Agents are autonomous.
Models are easily parallelized.
Points to Remember
z
z
z
z
z
z
31
Note the x-machines (in Flame) are defined by the
functions, not to be confused as defined states.
While running functions, agent lists are randomized
preventing priority.
If using an id? Problems with adding agents might
crop up.
Discussed the fox/rabbit example.
3 steps – Describe, Start, Get
Your assignment would be in serial.
Agent-based Modelling
FLAME
Demonstrating FLAME- Case study : Fox and Rabbit Example
Conclusions
Useful Links
Useful Links
z
Email me:
–
z
Email Simon:
–
z
–
www.dcs.shef.ac.uk/~stc/dept_only/art/
www.dcs.shef.ac.uk/~mariam
FLAME
–
32
s.coakley@dcs.shef.ac.uk
Files for download and details:
–
z
m.kiran@dcs.shef.ac.uk
www.flame.ac.uk
© Copyright 2025 Paperzz