Skip to content

Commit

Permalink
Add Pre-Commit Job & Badge (#66)
Browse files Browse the repository at this point in the history
* Add badge for pr-commit check to readme
* Remove the argument from pretty-format-json
* [pre-commit.ci] auto fixes from pre-commit.com hooks, for more information, see https://pre-commit.ci
* Add autofix flag
* [pre-commit.ci] auto fixes from pre-commit.com hooks, for more information, see https://pre-commit.ci
  • Loading branch information
franziska-wegner committed Dec 30, 2023
1 parent 591bccb commit f7b1e08
Show file tree
Hide file tree
Showing 148 changed files with 6,155 additions and 6,087 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ jobs:
message(FATAL_ERROR "Building documentation failed")
endif()
# See https://github.com/marketplace/actions/github-pages-action#%EF%B8%8F-deploy-to-external-repository-external_repository
# See https://github.com/marketplace/actions/github-pages-action#%EF%B8%8F-deploy-to-external-repository-external_repository
# for more information on the parameters.
- name: Publish Documentation to Github Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/synopsys-security-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ jobs:
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=g++
-DCMAKE_C_COMPILER=gcc
-DEGOA_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=Release
-DEGOA_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=Release
-DBoost_NO_SYSTEM_PATHS=TRUE
-DEGOA_DOWNLOAD_CPPAD=OFF
-DEGOA_DOWNLOAD_EIGEN=OFF
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: no-commit-to-branch
args: [--branch, staging, --branch, main]
- id: pretty-format-json
args: [--autofix, --indent, 4]
args: [--autofix] # , --indent, 4
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
Expand Down
28 changes: 14 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# CMakeLists.txt
#
#
# Created on: 30.01.2019
# Author: Franziska Wegner
#
#
# Main cmake configuration file.
#
#

cmake_minimum_required ( VERSION 3.13.1 )
# Required for CMAKE_MSVC_RUNTIME_LIBRARY
cmake_minimum_required ( VERSION 3.13.1 )
# Required for CMAKE_MSVC_RUNTIME_LIBRARY
# https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html#variable:CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)

Expand Down Expand Up @@ -85,7 +85,7 @@ set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)

####################################################################
# Find external libraries ##########################################
####################################################################
####################################################################

# Initial Configuration
include ( SetEnvironmentVariables )
Expand Down Expand Up @@ -147,12 +147,12 @@ if ( EGOA_ENABLE_TESTS )
# find_package ( GoogleTestFramework )
# endif ()

# Add test coverage
# Add test coverage
# -coverage includes -fprofile-arcs -ftest-coverage while compiling and
# -lgcov while linking -coverage
#
#
# brew install lcov || gcovr (https://gcovr.com/en/stable/)
#
#
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EGOA_COVERAGE_COMPILE_FLAGS}")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EGOA_COVERAGE_LINK_FLAGS}")
endif(EGOA_ENABLE_TESTS)
Expand All @@ -176,17 +176,17 @@ elseif ( COIN_FOUND )
include_directories(SYSTEM ${COIN_INCLUDE_DIRS} ${GUROBI_INCLUDE_DIRS} ${CPLEX_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include)
link_directories(${COIN_LIBRARY_DIR})
else()
else()
message( STATUS "Neither OGDF nor COIN include directory and library are added to the project.")
include_directories(SYSTEM ${GUROBI_INCLUDE_DIRS} ${CPLEX_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include)
endif()

####################################################################
# Add files, libraries and sources #################################
####################################################################
####################################################################
file ( GLOB_RECURSE HEADERS ${PROJECT_INCLUDE_DIR} include/*.hpp )
file ( GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp )
file ( GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp )
file ( GLOB_RECURSE SOURCES_REMOVE ${PROJECT_SOURCE_DIR}/src/Runnables/*.cpp )
list ( FILTER SOURCES EXCLUDE REGEX ".*Runnables.*" )

Expand All @@ -201,7 +201,7 @@ add_subdirectory ( src )

####################################################################
# Testing ##########################################################
####################################################################
####################################################################
if ( EGOA_ENABLE_TESTS )
add_subdirectory ( tests )
enable_testing()
Expand Down Expand Up @@ -305,7 +305,7 @@ endif ( )
# Define a macro to get number of configured threads
target_compile_definitions ( EGOA PUBLIC EGOA_USER_DEFINED_THREAD_LIMIT=$ENV{OMP_NUM_THREADS} )

#
#
target_compile_definitions ( EGOA PUBLIC EGOA_ENABLE_STATISTIC_DTP )
target_compile_definitions ( EGOA PUBLIC EGOA_ENABLE_STATISTIC_BETWEENNESS_CENTRALITY )

Expand Down
2 changes: 1 addition & 1 deletion DoxyfileConfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ EXTRA_PACKAGES = {${PROJECT_INCLUDE_DIR}/documentation/includes/EGOA_Doc
# to HTML_HEADER.
# This tag requires that the tag GENERATE_LATEX is set to YES.

LATEX_HEADER =
LATEX_HEADER =

# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
# generated LaTeX document. The footer should contain everything after the last
Expand Down
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0) [![CMake on multiple platforms](https://github.com/franziska-wegner/egoa/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=master)](https://github.com/franziska-wegner/egoa/actions/workflows/cmake-multi-platform.yml) [![CodeQL](https://github.com/franziska-wegner/egoa/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/franziska-wegner/egoa/actions/workflows/codeql.yml) <a href="https://scan.coverity.com/projects/franziska-wegner-egoa"><img alt="Coverity Scan Build Status" src="https://scan.coverity.com/projects/29511/badge.svg"/></a> [![codecov](https://codecov.io/gh/franziska-wegner/egoa/graph/badge.svg?token=OL0N2WXV4I)](https://codecov.io/gh/franziska-wegner/egoa) [![cpp-linter](https://github.com/franziska-wegner/egoa/actions/workflows/cpp-linter.yml/badge.svg)](https://github.com/franziska-wegner/egoa/actions/workflows/cpp-linter.yml)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0) [![CMake on multiple platforms](https://github.com/franziska-wegner/egoa/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=master)](https://github.com/franziska-wegner/egoa/actions/workflows/cmake-multi-platform.yml) [![CodeQL](https://github.com/franziska-wegner/egoa/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/franziska-wegner/egoa/actions/workflows/codeql.yml) <a href="https://scan.coverity.com/projects/franziska-wegner-egoa"><img alt="Coverity Scan Build Status" src="https://scan.coverity.com/projects/29511/badge.svg"/></a> [![codecov](https://codecov.io/gh/franziska-wegner/egoa/graph/badge.svg?token=OL0N2WXV4I)](https://codecov.io/gh/franziska-wegner/egoa) [![cpp-linter](https://github.com/franziska-wegner/egoa/actions/workflows/cpp-linter.yml/badge.svg)](https://github.com/franziska-wegner/egoa/actions/workflows/cpp-linter.yml) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/franziska-wegner/egoa/main.svg)](https://results.pre-commit.ci/latest/github/franziska-wegner/egoa/main)


<h1 align="center">EGOA - Energy Grid Optimization and Analysis</h1>

Energy Grid Optimization and Analysis (EGOA) is a framework for energy grid analysis and planning. This framework is based on the PhD thesis <a href="http://dx.doi.org/10.5445/IR/1000120612">"Combinatorial Problems in Energy Networks -- Graph Theoretic Models and Algorithms"</a>. The Git repository of the PhD thesis is available under <a href="https://github.com/franziska-wegner/PhD_Thesis--Combinatorial_Problems_in_Energy_Networks--Graph_Theoretic_Models_and_Algorithms">Combinatorial_Problems_in_Energy_Networks</a>.
Energy Grid Optimization and Analysis (EGOA) is a framework for energy grid analysis and planning. This framework is based on the PhD thesis <a href="http://dx.doi.org/10.5445/IR/1000120612">"Combinatorial Problems in Energy Networks -- Graph Theoretic Models and Algorithms"</a>. The Git repository of the PhD thesis is available under <a href="https://github.com/franziska-wegner/PhD_Thesis--Combinatorial_Problems_in_Energy_Networks--Graph_Theoretic_Models_and_Algorithms">Combinatorial_Problems_in_Energy_Networks</a>.

<img height=275 alt="Swiss Power Grid Branch with Parameters" src="https://github.com/franziska-wegner/egoa/assets/57569315/514cd0d2-6fac-416a-bf8d-31d97565fed8"/> <img height=275 alt="Swiss Power Grid Bus with Parameters" src="https://github.com/franziska-wegner/egoa/assets/57569315/aad67a45-a656-4c42-9c74-e7d82eedc6fb"/>

Expand Down Expand Up @@ -57,7 +57,7 @@ At the moment this is limited to PyPSA, the IEEE cases, and the windfarm cases;
```
IEEE
+ 00-Matpower-Data
(+) 02-gml
(+) 02-gml
+ 03-IEEE-Power_Flow_Test_Cases
+ 04-IEEE-Dynamic_Test_Cases
+ 05-IEEE-Reliability_Test_Systems-RTS
Expand Down Expand Up @@ -167,13 +167,13 @@ The Qt project can be installed on a Mac using
brew install qt
```

and on Ubuntu using
and on Ubuntu using

```
sudo apt-get install qt
```

The compiler clang and gcc can be installed on a Mac using the following command or you use the Apple clang compiler if necessary.
The compiler clang and gcc can be installed on a Mac using the following command or you use the Apple clang compiler if necessary.

```
brew install llvm
Expand All @@ -191,7 +191,7 @@ If the tests are enabled `"EGOA_TEST_FRAMEWORK": "OfflineGoogleTestFramework"` t
<h3>CMake Parameter Overrides</h3>

The repository provides an intial set of parameters in the sublimetext project file that can be found under `egoa.sublime-project`. In addition, there are scripts that support with server and local runs that have a initial CMake parameter configuration and can be adapted to the particular needs under [egoa/scripts/Build](https://github.com/franziska-wegner/egoa/tree/master/scripts/Build) and monitoring scripts under [egoa/scripts/Experiments](https://github.com/franziska-wegner/egoa/tree/master/scripts/Experiments).
An essential CMake setting parameter is the build directory that should be changed according to your file system, e.g., `"build_folder": "/Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug"`.
An essential CMake setting parameter is the build directory that should be changed according to your file system, e.g., `"build_folder": "/Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug"`.

<details>
<summary>Example CMake Configuration for SublimeText</summary>
Expand Down Expand Up @@ -249,63 +249,63 @@ An essential CMake setting parameter is the build directory that should be chang

Most parameters represent flags and can be enabled with `ON` if available and `OFF` if not available. Dependent on the flag the required path to the framework or tool has to be set accordingly (see above). There are flags that enable downloads for data sets and frameworks, and start with `EGOA_DOWNLOAD_<framework|dataset>`. The recommendation is to start with a minimum of enabled tools and extend if necessary.

This framework provides a set of unittests that uses the Google Test Framework as base. The CMake files allow two different setups of the test framework that are known by online and offline configuration. The CMake parameter for the online version are `"EGOA_TEST_FRAMEWORK": "OnlineGoogleTestFramework"` OR `"EGOA_TEST_FRAMEWORK": "OfflineGoogleTestFramework"` with the pointer to the installation directory of the Google test framework repository, e.g., `"EGOA_TEST_FRAMEWORK_LOCATION": "external/GoogleTestFramework"`.
This framework provides a set of unittests that uses the Google Test Framework as base. The CMake files allow two different setups of the test framework that are known by online and offline configuration. The CMake parameter for the online version are `"EGOA_TEST_FRAMEWORK": "OnlineGoogleTestFramework"` OR `"EGOA_TEST_FRAMEWORK": "OfflineGoogleTestFramework"` with the pointer to the installation directory of the Google test framework repository, e.g., `"EGOA_TEST_FRAMEWORK_LOCATION": "external/GoogleTestFramework"`.

<details>
<summary>Successful Initial CMake Run</summary>

```
--
--
-- /Users/fwegner/Documents/Repositories/Public/EGOA/egoa
--
--
-- /Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug
-- Set OpenMP variables
-- OMP_WAIT_POLICY: ACTIVE
-- OMP_STACKSIZE:
-- OMP_SCHEDULE:
-- OMP_STACKSIZE:
-- OMP_SCHEDULE:
-- OMP_PROC_BIND: TRUE
-- OMP_THREAD_LIMIT: 0
-- Number of processors: 8
-- OMP_NUM_THREADS: 8
--
-- Compiler extra flags: -pedantic -Werror -Wall -Wextra -Wunused-result -Wno-error=unused-but-set-variable -Wno-error=conversion -Wshadow -Wno-error=zero-length-array
--
--
-- Compiler extra flags: -pedantic -Werror -Wall -Wextra -Wunused-result -Wno-error=unused-but-set-variable -Wno-error=conversion -Wshadow -Wno-error=zero-length-array
--
-- Download of data sets:
-- Download PyPSA Europe data from https://github.com/PyPSA/pypsa-eur.git into /Users/fwegner/Documents/Repositories/Public/EGOA/egoa/data/PowerGrids/PyPSA/pypsa-eur.
-- Download PyPSA ITI Collaboration data from https://git.scc.kit.edu/FN/iti-collaboration.git into /Users/fwegner/Documents/Repositories/Public/EGOA/egoa/data/PowerGrids/PyPSA/pypsa-iti-collaboration.
-- Download IEEE Power Grid data.
--
--
-- Looking for Qt6
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Found Qt6 Core module in "/opt/homebrew/lib/QtCore.framework/Versions/A/QtCore"
-- Found Qt6 Quick module in "/opt/homebrew/lib/QtQuick.framework/Versions/A/QtQuick"
-- Found Qt6 Widgets module in "/opt/homebrew/lib/QtWidgets.framework/Versions/A/QtWidgets"
-- Found Qt6 Concurrent module in "/opt/homebrew/lib/QtConcurrent.framework/Versions/A/QtConcurrent"
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Found Qt6 Core module in "/opt/homebrew/lib/QtCore.framework/Versions/A/QtCore"
-- Found Qt6 Quick module in "/opt/homebrew/lib/QtQuick.framework/Versions/A/QtQuick"
-- Found Qt6 Widgets module in "/opt/homebrew/lib/QtWidgets.framework/Versions/A/QtWidgets"
-- Found Qt6 Concurrent module in "/opt/homebrew/lib/QtConcurrent.framework/Versions/A/QtConcurrent"
SRC=/Users/fwegner/Documents/Repositories/Public/EGOA/egoa and Binary=/Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug
-- Doxygen: /opt/homebrew/bin/doxygen
-- Google Test Framework
-- EGOA_ENABLE_TESTS: ON
--
--
-- Neither OGDF nor COIN include directory and library are added to the project.
--
--
-- Compiler:
-- CMAKE_C_COMPILER: /opt/homebrew/opt/llvm/bin/clang
-- CMAKE_CXX_COMPILER: /opt/homebrew/opt/llvm/bin/clang++
-- make VERBOSE = 1? : TRUE
--
--
-- Other important targets:
-- qt6: add libraries of QT6
-- doc: build doxygen documentation
-- EGOA Exceptions: ON
-- EGOA Assertions: ON
--
--
-- Build type is set to: Debug
-- Build files have been written to: /Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug
-- Runtime output directory: /Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug/bin
-- Archive output directory: /Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug/lib
-- Library output directory: /Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug/lib
--
--
-- Configuring done (3.2s)
-- Generating done (0.1s)
-- Build files have been written to: /Users/fwegner/Documents/Repositories/Public/EGOA/egoa/build-debug
Expand All @@ -319,7 +319,7 @@ A general recommendation is CLION and Sublimetext. However, Visual Studio and ot

<h2>Documentation</h2>

The repository's public code documentation is available under [Code Documentation by Doxygen](https://franziska-wegner.github.io/egoa). For the purpose of code documentation, the <a href="https://www.doxygen.nl">Doxygen</a> framework is used. It provides a simple and well formed way of code documentation for C++. Run
The repository's public code documentation is available under [Code Documentation by Doxygen](https://franziska-wegner.github.io/egoa). For the purpose of code documentation, the <a href="https://www.doxygen.nl">Doxygen</a> framework is used. It provides a simple and well formed way of code documentation for C++. Run

make doc

Expand Down
10 changes: 5 additions & 5 deletions cmake/Boost.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Boost.cmake
#
#
# Created on: Nov 04, 2019
# Author: Franziska Wegner
#
#
# Find the Boost library.
#
#

####################################################################
# Reset variables ##################################################
Expand All @@ -21,7 +21,7 @@ set( Boost_DIRECTORIES "/usr/local/Cellar/boost/1.71.0/" CACHE STRING
set( Boost_LIBRARY_DIRS "" )
set( Boost_INCLUDE_DIRS "" )
set( BOOST_ROOT "" CACHE PATH "Boost library path" )
# https://stackoverflow.com/questions/58081084/target-boostlibrary-already-has-an-imported-location-link-errors
# https://stackoverflow.com/questions/58081084/target-boostlibrary-already-has-an-imported-location-link-errors
# https://stackoverflow.com/questions/3016448/how-can-i-get-cmake-to-find-my-alternative-boost-installation/51904185
set( Boost_NO_SYSTEM_PATHS on CACHE BOOL "Do not search system for Boost" )
set( Boost_NO_BOOST_CMAKE on CACHE INTERNAL "" )
Expand All @@ -38,4 +38,4 @@ include_directories(${Boost_INCLUDE_DIRS})
# Output ###########################################################
####################################################################
message(STATUS "${MY_SPACE}Boost_LIBRARY_DIRS:\t\t\t${Boost_LIBRARY_DIRS}")
message(STATUS "${MY_SPACE}Boost_INCLUDE_DIRS:\t\t\t${Boost_INCLUDE_DIRS}")
message(STATUS "${MY_SPACE}Boost_INCLUDE_DIRS:\t\t\t${Boost_INCLUDE_DIRS}")
16 changes: 8 additions & 8 deletions cmake/CompilerConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# Compiler specific configurations.
#

# -ggdb Produce debugging information for use by GDB. This means
# to use the most expressive format available (DWARF, stabs, or
# the native format if neither of those are supported), including
# -ggdb Produce debugging information for use by GDB. This means
# to use the most expressive format available (DWARF, stabs, or
# the native format if neither of those are supported), including
# GDB extensions if at all possible.
#
# - Wall This enables all the warnings about constructions that
# some users consider questionable, and that are easy to avoid
#
# - Wall This enables all the warnings about constructions that
# some users consider questionable, and that are easy to avoid
# (or modify to prevent the warning), even in conjunction with macros
if (CMAKE_BUILD_TYPE MATCHES "Debug" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -coverage")
Expand Down Expand Up @@ -80,7 +80,7 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug)
else()
set(extra_flags "${extra_flags} ${EGOA_WARNING_FLAGS_RELEASE}")
endif()
# Warning and error
# Warning and error
if(EGOA_WARNINGS_AS_ERRORS)
set(extra_flags "${EGOA_WARNINGS_AS_ERRORS_FLAG} ${extra_flags}")
endif()
Expand All @@ -92,6 +92,6 @@ if(EGOA_PEDANTIC_MODE)
set(extra_flags "${EGOA_PEDANTIC_WARNING_FLAG} ${extra_flags}")
endif()
endif()
#
#
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS " ${extra_flags} ")
message(STATUS "${MY_SPACE}Compiler extra flags:\t\t\t${TARGET_NAME} ${extra_flags}")
Loading

0 comments on commit f7b1e08

Please sign in to comment.