Git Product home page Git Product logo

socialforcemodel's Introduction

This is a fork from fawwazbmn/SocialForceModel. I just made some changes to make it compilable with g++ std=c++11. Given that I had some issues getting to work the C++ Port of the vecmath Package, I modified the vecmath code to make it compatible with c++11 standard and I added it as part of the source code.

The code can be compiled (with linux g++ compiler) and run using the following commands:

g++ -std=c++11 -I vecmath/ -c SocialForce.cpp
g++ -std=c++11 -I vecmath/ -c Agent.cpp
g++ -std=c++11 -I vecmath/ -c Wall.cpp
g++ -std=c++11 -I vecmath/ -c Core.cpp
g++ -std=c++11 Agent.o Wall.o SocialForce.o Core.o -o executable.exe -lGL -lGLU -lglut
./executable.exe
Press key a to start the simulation

Social Force Model in C++

The social force model was originally introduced by Helbing and Molnár (1995), and is one of the microscopic technique in crowd simulation. It presents an idea that the agents’ internal motivation to perform certain movements affects their motion. Throughout the years, many improvements were made to the original model. One of the latest improvement was made by Moussaïd et al. (2009). In their research, the model parameters were calibrated to match the results of the experiment they have conducted on the real-world crowd. The Social Force Model in C++ project is created based on this research.

Getting Started

This project consists of three header files and four source files. Core.cpp is used to setup the scene and display the position of all agents and obstacle walls, while the remaining header and source files are used to store the characteristics of agents and obstacle walls, and perform calculations.

Prerequisites

This project requires the following libraries.

This project also requires users to use compilers that support C++ 11.

Creating a Simple Scene

Core.cpp will create for you a corridor with 400 agents. Pressing the key a will start the simulation. However, if you wish to create your own scene, kindly follow the steps below.

Create a Pointer to the SocialForce Object

SocialForce *socialForce;

Create an Obstacle Wall

Wall *wall = new Wall(x1, y1, x2, y2);  // Step 1: Create wall and define its coordinates
socialForce->addWall(wall);             // Step 2: Add wall to SFM

Add an Agent

Agent *agent = new Agent;            // Step 1: Create agent
agent->setPosition(x, y);            // Step 2: Set initial position
agent->setPath(x, y, targetRadius);  // Step 3: Set target position

You can set multiple targets by repeating step 3. Adding multiple targets will automatically loop the agent between all targets

Retrieve Obstacle Wall Position

vector<Wall *> walls = socialForce->getWalls();

for (Wall *wall : walls) {
    wall->getStartPoint();
    wall->getEndPoint();
}

Retrive Agent Position

Agent *agents = socialForce->getCrowd();

for (Agent *agent : agents)
    agent->getPosition();

Authors

  • Fawwaz Mohd Nasir
  • Shamsul Mohamad

socialforcemodel's People

Contributors

arteagac avatar fawwazbmn avatar

Watchers

 avatar

Forkers

franklinbf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.