Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Update apt repo
run: sudo apt update

- name: Install tools manually
run: sudo apt install libtbb-dev

- uses: actions/checkout@v4
with:
submodules: true
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/cmake_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Install tools manually
run: |
if [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
sudo apt update
sudo apt install libtbb-dev
elif [ ${{ matrix.os }} == 'macos-latest' ]; then
brew install tbb
fi

- uses: actions/checkout@v4

- name: Configure CMake
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cmake_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Install tools manually
run: sudo apt update && sudo apt install libtbb-dev
- uses: actions/checkout@v4

- name: Build and install
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/cmake_install_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ jobs:
runs-on: macos-latest

steps:
- name: Install tools manually
run: brew install tbb

- name: Set environment variables
run: |
echo "CPLUS_INCLUDE_PATH=$(brew --prefix tbb)/include" >> $GITHUB_ENV
echo "LIBRARY_PATH=$(brew --prefix tbb)/lib" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$(brew --prefix tbb)/lib" >> $GITHUB_ENV

- uses: actions/checkout@v4

- name: Build and install
working-directory: ${{github.workspace}}
run: |
mkdir -p build && cd build
cmake ..
cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix tbb)
cmake --build .
sudo cmake --install .

Expand All @@ -27,5 +36,6 @@ jobs:
touch test.cpp
echo "#include <dsm/dsm.hpp>" >> test.cpp
echo "int main() {}" >> test.cpp
g++ test.cpp -std=c++20 && echo "Compiled successfully" \
|| (echo "Cannot include dsm" ; exit 1)
g++ test.cpp -std=c++20 -I$(brew --prefix tbb)/include -L$(brew --prefix tbb)/lib -ltbb \
&& echo "Compiled successfully" \
|| (echo "Cannot include dsm" ; exit 1)
2 changes: 1 addition & 1 deletion .github/workflows/cmake_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: sudo apt-get update

- name: Install tools manually
run: sudo apt-get install lcov gcovr
run: sudo apt install lcov gcovr libtbb-dev

- uses: actions/checkout@v4

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cmake_test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
runs-on: macos-latest

steps:
- name: Install tools manually
run: brew install tbb

- uses: actions/checkout@v4

- name: Configure CMake
Expand Down
55 changes: 19 additions & 36 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '22 20 * * 5'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
Expand All @@ -28,47 +22,36 @@ jobs:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Install TBB (MacOS & Ubuntu)
run: |
if [[ "$RUNNER_OS" == "macOS" ]]; then
brew install tbb
echo "CPLUS_INCLUDE_PATH=$(brew --prefix tbb)/include" >> $GITHUB_ENV
echo "LIBRARY_PATH=$(brew --prefix tbb)/lib" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$(brew --prefix tbb)/lib" >> $GITHUB_ENV
elif [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt update && sudo apt install -y libtbb-dev
fi

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- run: |
echo "Build C++"
- name: Build C++
run: |
mkdir -p build && cd build
cmake ..
if [[ "$RUNNER_OS" == "macOS" ]]; then
cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix tbb)
else
cmake ..
fi
cmake --build .
sudo make install

- name: Perform CodeQL Analysis
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/profile_exec_time.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Install tools manually
run: sudo apt update && sudo apt install libtbb-dev
- uses: actions/checkout@v4

- name: Build test simulation
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/profile_mem_usage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Install tools manually
run: sudo apt update && sudo apt install libtbb-dev
- uses: actions/checkout@v4

- name: Install valgrind
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(TBB REQUIRED CONFIG)

file(GLOB SOURCES "src/dsm/sources/*.cpp" "src/dsm/utility/*.cpp")

add_library(dsm STATIC ${SOURCES})
target_include_directories(dsm PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/headers>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(dsm PRIVATE TBB::tbb)

install(TARGETS dsm
EXPORT dsmConfig
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# DynamicalSystemFramework
<!-- [![codecov](https://codecov.io/github/sbaldu/DynamicalSystemFramework/graph/badge.svg?token=JV53J6IUJ3)](https://codecov.io/github/sbaldu/DynamicalSystemFramework) -->
[![Standard](https://img.shields.io/badge/c%2B%2B-20/23-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)
[![TBB](https://img.shields.io/badge/TBB-C%2B%2B20%2F23-blue.svg)](https://github.com/oneapi-src/oneTBB)
[![codecov](https://codecov.io/gh/physycom/DynamicalSystemFramework/graph/badge.svg?token=JV53J6IUJ3)](https://codecov.io/gh/physycom/DynamicalSystemFramework)

The aim of this project is to rework the original [Traffic Flow Dynamics Model](https://github.com/Grufoony/TrafficFlowDynamicsModel).
This rework consists of a full code rewriting, in order to implement more features (like *intersections*) and get advantage from the latest C++ updates.

## Requirements

The project only requires `C++20` or greater and `cmake`.
The project requires `C++20` or greater, `cmake` and `tbb`.
To install requirements on Ubuntu:
```shell
sudo apt install libtbb-dev cmake
```
To install requirements on MacOS:
```shell
brew install tbb cmake
```

Utilities are written in python. To install their dependencies:
```shell
Expand Down
21 changes: 7 additions & 14 deletions benchmark/Dynamics/BenchDynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@ using Bench = sb::Bench<long long int>;

int main() {
Graph graph{};
graph.importMatrix("../test/data/matrix.dat", false);
for (const auto& [streetId, street] : graph.streetSet()) {
street->setMaxSpeed(13.9);
}

Itinerary it1{0, 118};
Itinerary it2{4, 115};
Itinerary it3{8, 112};
Itinerary it4{12, 109};
graph.importOSMNodes("../test/data/forlì_nodes.csv");
graph.importOSMEdges("../test/data/forlì_edges.csv");
graph.buildAdj();

Dynamics dynamics{graph};
dynamics.addItinerary(it1);
dynamics.addItinerary(it2);
dynamics.addItinerary(it3);
dynamics.addItinerary(it4);
std::vector<dsm::Id> destinations{10, 42, 69, 121, 420, 690, 777, 999, 1020, 1212};
dynamics.setDestinationNodes(destinations);

const int n_rep{100};
const int n_rep{1};
Bench b1(n_rep);
std::cout << "Benchmarking updatePaths\n";
dynamics.updatePaths();
b1.benchmark([&dynamics]() -> void { dynamics.updatePaths(); });
std::cout << "Time elapsed (ms):\n";
b1.print<sb::milliseconds>();
}
7 changes: 5 additions & 2 deletions benchmark/Dynamics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(TBB REQUIRED CONFIG)

# Set the C++ flags
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra -O3 -g")
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra -O3")

# Set the folder for the executable
set(EXECUTABLE_OUTPUT_PATH ../../)

include_directories(../../src/dsm/headers)
include_directories(../../src/dsm/utility/)

file(GLOB SOURCES "../../src/dsm/sources/*.cpp", "../../src/dsm/utility/*.cpp")
file(GLOB SOURCES "../../src/dsm/sources/*.cpp" "../../src/dsm/utility/*.cpp")

# Compile
add_executable(bench_dynamics.out BenchDynamics.cpp ${SOURCES})
target_link_libraries(bench_dynamics.out PRIVATE TBB::tbb)
5 changes: 4 additions & 1 deletion benchmark/Graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(TBB REQUIRED CONFIG)

# Set the C++ flags
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra -O3 -g")
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra -O3")

# Set the folder for the executable
set(EXECUTABLE_OUTPUT_PATH ../../)
Expand All @@ -18,3 +20,4 @@ file(GLOB SOURCES "../../src/dsm/sources/*.cpp", "../../src/dsm/utility/*.cpp")

# Compile
add_executable(bench_graph.out BenchGraph.cpp ${SOURCES})
target_link_libraries(bench_graph.out PRIVATE TBB::tbb)
5 changes: 4 additions & 1 deletion benchmark/Street/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(TBB REQUIRED CONFIG)

# Set the C++ flags
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra -O3 -g")
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra -O3")

# Set the folder for the executable
set(EXECUTABLE_OUTPUT_PATH ../../)
Expand All @@ -18,3 +20,4 @@ file(GLOB SOURCES "../../src/dsm/sources/*.cpp", "../../src/dsm/utility/*.cpp")

# Compile
add_executable(bench_street.out BenchStreet.cpp ${SOURCES})
target_link_libraries(bench_street.out PRIVATE TBB::tbb)
5 changes: 4 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ cmake_minimum_required(VERSION 3.16.0)
project(dsm_examples VERSION 1.3.10 LANGUAGES CXX)

# Set the C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(TBB REQUIRED CONFIG)

# Set the C++ flags
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra -O0 -g")
Expand All @@ -26,4 +28,5 @@ foreach(SOURCE ${SOURCES})
get_filename_component(EXE_NAME ${SOURCE} NAME_WE)
add_executable(${EXE_NAME}.out ${SOURCE} ${SRC_SOURCES})
target_include_directories(${EXE_NAME}.out PRIVATE ../src/dsm/headers/ ../src/dsm/utility/TypeTraits/)
target_link_libraries(${EXE_NAME}.out PRIVATE TBB::tbb)
endforeach()
4 changes: 4 additions & 0 deletions profiling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(TBB REQUIRED CONFIG)

# Set the C++ flags
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra -Os")

Expand All @@ -18,8 +20,10 @@ file(GLOB SOURCES "../src/dsm/sources/*.cpp" "../src/dsm/utility/*.cpp")
# Define the executable
add_executable(prof.out main.cpp ${SOURCES})
target_include_directories(prof.out PRIVATE ../src/)
target_link_libraries(prof.out PRIVATE TBB::tbb)
target_compile_options(prof.out PRIVATE -pg)
target_link_options(prof.out PRIVATE -pg)
add_executable(mem.out main.cpp ${SOURCES})
target_include_directories(mem.out PRIVATE ../src/)
target_link_libraries(mem.out PRIVATE TBB::tbb)
add_executable(parse_massif.out parse_massif.cpp)
2 changes: 1 addition & 1 deletion src/dsm/dsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

static constexpr uint8_t DSM_VERSION_MAJOR = 2;
static constexpr uint8_t DSM_VERSION_MINOR = 3;
static constexpr uint8_t DSM_VERSION_PATCH = 24;
static constexpr uint8_t DSM_VERSION_PATCH = 25;

static auto const DSM_VERSION =
std::format("{}.{}.{}", DSM_VERSION_MAJOR, DSM_VERSION_MINOR, DSM_VERSION_PATCH);
Expand Down
Loading
Loading