- Notifications
You must be signed in to change notification settings - Fork3
Agent Based Model on GPU using CUDA 12.2.1 and OpenGL 4.5 (CUDA OpenGL interop) on Windows/Linux
License
KienTTran/ABMGPU
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
| 🎉 Demo of agent based model on GPU using CUDA 12.2.1 and OpenGL 4.5 (Windows/Linux) 🎉 |
A demo of using CUDA and OpenGL to render different locations with multiple agents with their own properties.
This is a useful begin place for those want to illustrate or experiment how an agent based model works.
You can update theadjust_person_entity
function insrc/gpu/GPUBuffer.cu
to change the moving path and color of each agent.
🎯 Each triangle is an agent with different color and trajectory.
🎯 On GTX 3060 the software can render 5-10M agents without problem.
🎴 The image below illustrates a demo of 12,000 agents each location (60,000 agents in total) for easier observation.
In this demo, each triangle is an independent agent and it has two properties: color and moving path.
The color is assigned by the location so all agents in the same location will have the same color.
The moving trajectory is randomized for each agent.
🎴 The image below illustrates a demo of ~500,000 agents of 100 (10x10) locations configured a from GIS raster file where each location has a random number of agents. This demo is fromdev
branch.
🎴 The image below illustrates a demo of ~15,000,000 agents of 21,798 (173x126) locations configured a from GIS raster file of Burkina Faso. Moreover, the population is dynamically changed based on census data. The color of each agent is based on the population density of each location. This version will be released soon.
| 💎 Features 💎 |
✅ Agent instances on GPU memory
✅ Uses SSBO (Shader Storage Buffer Object) for instanced objects (with GLSL 450 shaders)
✅ CUDA OpenGL interops
✅ Renders with GLFW3 window manager
✅ Dynamic camera views in OpenGL (pan,zoom with mouse)
✅ Libraries installed using vcpkg
✅ Load configuration as YAML file
✅ Load location data in GIS raster file (.asc file)
✅ Update number of agents dynamically based on census data
| 📚 Libraries 📚 |
vcpkg install glfw3 opengl glew glm imgui[core,glfw-binding,opengl3-binding] easyloggingpp date yaml-cpp
| 📝 Citation 📝 |
This repo is a GPU implementation of original CPU based simulation fromhttps://github.com/maciekboni/PSU-CIDD-Malaria-Simulation, which was originally developed by Nguyen Tran.The spatial (raster/Burkia Faso movement model) part was implemented by Robert Zupko. Kien Tran implemented display and GPU processing.
Tran, K. T., Tran, N., & Zupko, R. (2025). Agent based simulation using GPU and OpenGL.Zenodo. [https://doi.org/10.5281/zenodo.14967981](https://zenodo.org/records/14967981)
or
@software{Tran_Agent_based_simulation_2023,author = {{Tran, Kien Trung},{Tran, Nguyen Dang},{Zupko, Robert}},doi = {10.5281/zenodo.14967981},month = dec,title = {{Agent based simulation using GPU and OpenGL}},url = {https://github.com/KienTTran/ABMGPU},version = {1.0.1},year = {2025}}
| ❓ How it works ❓ |
The simulation is a combination of instancing feature and parallel computing fromOpenGL
andCUDA
respectively.
UsingOpenGL
, you can instance as many objects as you want usingSSBO
and compute position and color of clone objects on shader viaGLSL
file. Instead of using shader, this demo usingCUDA
to compute postion and color (viaglm::mat4 matrix
andglm::vec4 color
arrays) of all instances at the same time and all agents are computed in batch processing.
| 🌟 How to build 🌟 |
- Clone the repository
- Install
vcpkg
and install requirement librariesvcpkg install glfw3 opengl glew glm imgui[core,glfw-binding,opengl3-binding] easyloggingpp date yaml-cpp
Note: Some libraries are extra for experiment and future development (imgui, easylogging, date, glew) - On Window:
- Use any IDE (I'm using
CLion
) supportsCMake
project to load the project folder - Edit the CMakeList file to match your
vcpkg cmake
file andCUDA
installation folder on your computer. - Build and run with arguments:
-i <path to config file>
(e.g.-i ../../input/config.yaml
)
- Use any IDE (I'm using
- On Linux:
- Edit the CMakeList file to match your
vcpkg cmake
file andCUDA
installation folder on your computer. - In the project folder, type
mkdir build && cd build && cmake ..
then execute the binary built with arguments:-i <path to config file>
(e.g../ABMGPU -i ../../input/config.yaml
)
- Edit the CMakeList file to match your
- Star 🌟, issue and pull request are welcomed
About
Agent Based Model on GPU using CUDA 12.2.1 and OpenGL 4.5 (CUDA OpenGL interop) on Windows/Linux