File Exchange

image thumbnail

Agent-Based Modeling

version 1.0.5 (694 KB) by wgl
Demonstrations of Agent-Based Modeling in the scenarios of driver-assistance driving.


Updated 13 Dec 2018

View Version History

View License

Agent-Based Modeling (ABM) is a style of modelling to investigate and predict the emergence of complex group behaviors through simulating the actions and interactions of a large among of autonomous agents in given scenarios. ABM has been extensively used in the academia, e.g., game theory, complex system and computational sociology. With respect to autonomous driving, ABM is also a popular simulation approach, e.g., in developing driving policies and safety verification. The conventional motion planning and control methods, e.g., PID control, feedback linearization or model predictive control, expect a prediction over the future trajectories of other traffic participants in order to avoid collisions, but real traffic scenarios involve complex interactions among various road users (Schwarting, Planning and Decision-Making for Autonomous Vehicles, MIT, 2018). To conquer this challenge, the emerging trends are the behavior-aware motion planning and learning-based approaches. ABM is then could be naturally exploited to handle the complex, cluttered environments while modeling the uncertain interactions with each other. This would expend Simulink as an integrated platform to develop and verify learning-based algorithms. For a description, you can see this video:

Cite As

wgl (2021). Agent-Based Modeling (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (19)

Mohamad Khalil

Hi! Thanks for your efforts. It's really amazing. Do you have a full tutorial on this to walk us through the blocks step-by-step? I'd really appreciate your reply.

Mauro Fusco

This is just amazing. I love you, thank you!

HI. Good to see examples for agent-based modeling using Simulink. However, I think it is too large for starting to create agent-based models with Simulink. It has many objects, many model blocks, many variables, etc. I think it would be great if simpler examples with fewer elements with only essential variables and blocks. Thanks.

Zekun Guo

Can we use the blocks in this model to build our own agent-based model for academic use?

cao kaifa

Hi, TK, it is good work, thanks. I'd like to know what documents are available for work?

Fu Zhang

@Linfeng Zhang: Probably you don't have write permission of your D drive. Just download the file to a directory you have write permission, unzip it and click run in R2018b.

Linfeng Zhang

I have some errors when i run this program, here is the details, the version is R2018b.
Updating Model Reference SIM Targets 1
Elapsed: 24 sec
Building mDriver 1
Elapsed: 23 sec
### Build procedure for model: 'mDriver' aborted due to an error.
Line 1: Keyword expectedcannot open output file "D:\study\matlab.dll:
Component:Simulink | Category:Model error
Error while bringing model references of model AgentBasedModeling up to date: see errors reported above for details.
Component:Simulink | Category:Model error

Junwei Zhao

i have some truble when i run it( My matlab is 2018b),here is the error message when i first run it:
Building mDriver:###Build procedure for model:'mDriver' aborted due to an error.
Line1:Keyword expectedMissing exports.Aborting
Component Simulink | Category:Model error
Error while bringing model references of model AgentBasedModeling up to date: see error reported above for details.
There have two Error when i run the simulation.
Anyone who can help me ? Thanks

Jorge Pesantez

Fu, thank you for your response. The version was the issue.

Fu Zhang

@Jorge: I just download the file to a directory \AMB and open AgentBasedModeling.slx, click play. The model runs fine without any issue. I am using MATLAB 2018b. What version of MATLAB are you using? Can you try download and run it again?


Jorge Pesantez

It is a very useful tool to start using Simulink to build ABM. However, when running the AgentBasedModeling.slx file, I got the following error: "The model 'mvehicle1' referenced by 'AgentBasedModeling/Agents Pool/Vehicle 1: Driver Strategy & Vehicle Model' is not found.
Component:Simulink | Category:Block error"

Could anyone point out where this file is or what's the error?
Thanks in advance,

Nick Sarnie

@medianto Hi, are you able to reproduce the error you mentioned in your previous comment?

It appears to be an error during code generation for one of the models in this file exchange submission. If you can reproduce it, can you please let me know of the reproduction steps?

Thank you!


Thank you for your reply. I realized that the software is guaranteed to run on Standard license but Home license.


Thanks for your interests in our demo. I have never seen that error message before. I would like to suggest to remove all the .slxc files and the slprj folder and run it again, or just unzip the files into a new folder and rerun.


but i have problem while running it
this is the error massage

"Internal error while creating code interface description file: codeInfo.mat. Aborting code generation.
Caused by:
Undefined function or variable 'writeCodeInfoFcn'.
Variable 'writeCodeInfoFcn' does not exist.
Suggested Actions
Load a file into base workspace."

best regard


Thanks for your interests in our demo. This demo was created in R2018b. I can run this demo using R2018b:
1. Open AgentBasedModeling.slx (Don't need to load mVehOut.mat. It will be loaded automatically.)
2. Click Play button

I wonder may you provide more information regarding your problem, like error messages, as well as the version of MATLAB you are using?


Please help me.
It doesn't work.

I tried this 3 steps.
#1. Open [AgentBasedModeling.slx].
#2. Load [mVehOut.mat].
#3. Run the simulation


MATLAB Release Compatibility
Created with R2018b
Compatible with R2018b
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!