Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Agent Based Model on GPU using CUDA 12.2.1 and OpenGL 4.5 (CUDA OpenGL interop) on Windows/Linux

License

NotificationsYou must be signed in to change notification settings

KienTTran/ABMGPU

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 fromdevbranch.

🎴 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
⚠️ Code is dirty and buggy

| 📚 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 🌟 |

  1. Clone the repository
  2. Installvcpkg and install requirement libraries
    vcpkg 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)
  3. On Window:
    • Use any IDE (I'm usingCLion) supportsCMake project to load the project folder
    • Edit the CMakeList file to match yourvcpkg cmake file andCUDA installation folder on your computer.
    • Build and run with arguments:-i <path to config file> (e.g.-i ../../input/config.yaml)
  4. On Linux:
    • Edit the CMakeList file to match yourvcpkg cmake file andCUDA installation folder on your computer.
    • In the project folder, typemkdir build && cd build && cmake .. then execute the binary built with arguments:-i <path to config file> (e.g../ABMGPU -i ../../input/config.yaml)
  5. 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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp