Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f98e5f0
dev-ortools-integration_master_rebased commits
bongrainmat Mar 1, 2022
f08826f
use ortools as third party
bongrainmat Mar 1, 2022
5331676
choose solver option in metrix
bongrainmat Mar 1, 2022
3eeff2f
Feature/ortools dev ls (#56)
bongrainmat Oct 7, 2022
6dadd28
Added random group lists to TNR data
ARnDOSrte Apr 3, 2023
e12bcff
Add Xpress for Tests
ARnDOSrte Jul 12, 2023
43d9681
Corrected CMakeLists
ARnDOSrte Jul 12, 2023
588732c
Add CI for centos7
ARnDOSrte Dec 13, 2023
0c5241c
Remove ci_centos7.yml (already dropped on main)
lamoletoscar May 12, 2026
694c9d0
Fixes problems that occurred during the rebase
lamoletoscar May 13, 2026
809c86d
chore: cosmetic cleanups
lamoletoscar May 19, 2026
e7c3da3
refactor(solver): RAII for compute::Solver
lamoletoscar May 19, 2026
fd14a25
refactor(metrix): simplify Calculer lifecycle, route SIRIUS via compu…
lamoletoscar May 19, 2026
8b61dca
refactor(ortools): tidy wrapper, drop SIRIUS backend, fix bugs, align…
lamoletoscar May 19, 2026
bb823e9
feat(config): validate XPRESS at config-load time; simplify SPECIFICS…
lamoletoscar May 19, 2026
dbb0c71
build: build OR-Tools v9.13 and Sirius from source via ExternalProject
lamoletoscar May 19, 2026
96147dc
docs: document OR-Tools/Xpress integration
lamoletoscar May 19, 2026
26230b6
Lighten the build of ortools
lamoletoscar May 20, 2026
9a3d92d
Removal of harmful OR-Tools settings
lamoletoscar May 29, 2026
0ac8c9f
Removal of tests with Cbc as only Xpress is affected
lamoletoscar May 29, 2026
76611f6
Update of reference files for Xpress tests
lamoletoscar Jun 10, 2026
6729053
Merge branch 'main' into ortools-xpress-integration
lamoletoscar Jun 10, 2026
88372c6
fix(ortools): align VARIABLE_FIXE valuation with Sirius semantics
lamoletoscar Jun 10, 2026
5726f46
fix(log): move incident/parade message separator from dictionary to code
lamoletoscar Jun 10, 2026
997b277
fix(tests): realigns reference files with main
lamoletoscar Jun 10, 2026
689e64a
fix(ortools): fail gracefully when the selected solver backend is una…
lamoletoscar Jun 12, 2026
f90819e
Merge branch 'main' into ortools-xpress-integration
lamoletoscar Jun 12, 2026
b55b4a0
docs(simulator): document solver selection options and OR-Tools build…
lamoletoscar Jun 12, 2026
c06e342
test(config): add negative tests for solver choice validation
lamoletoscar Jun 12, 2026
e39244e
fix(build): make the OR-Tools third party opt-in
lamoletoscar Jun 15, 2026
eb76ef2
Merge remote-tracking branch 'upstream/main' into ortools-xpress-inte…
lamoletoscar Jul 6, 2026
a89eec9
Merge remote-tracking branch 'upstream/main' into ortools-xpress-inte…
lamoletoscar Jul 6, 2026
333be4e
test(xpress): gate the Xpress test suite behind METRIX_RUN_XPRESS_TESTS
lamoletoscar Jul 6, 2026
c87b1e3
chore(ortools): add missing MPL headers and tidy the wrapper
lamoletoscar Jul 6, 2026
16ef575
ci(sonar): exclude the licensed-only OR-Tools wrapper from coverage
lamoletoscar Jul 6, 2026
8785cc0
ci(coverage): exclude compiler-generated branches from the gcovr report
lamoletoscar Jul 7, 2026
f1a6022
test(xpress): drop tests that provably never reach a solve
lamoletoscar Jul 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ $> cd powsybl-metrix/metrix-simulator
```

2 - Build the project, with 3rd parties
First build the 3rd parties
First build the 3rd parties. This step downloads and compiles SuiteSparse,
Sirius and OR-Tools. OR-Tools is built unconditionally; its Xpress backend
is enabled automatically if `XPRESS_ROOT` is set (environment variable or
`-D` flag), otherwise OR-Tools is built without Xpress.
```
$> mkdir build
$> mkdir build/external
Expand All @@ -241,9 +244,13 @@ $> cmake .. -DCMAKE_INSTALL_PREFIX=<PREFIX> -DCMAKE_BUILD_TYPE=<BUILD_TYPE>
$> cmake --build . --target install
```

The following CMAKE options can be set for the executable configuration:
- USE_SIRIUS_SHARED (default = OFF): If active, projects will link using the shared library of sirius solver instead of the static library
- METRIX_RUN_ALL_TESTS (default = ON): If inactive, projects will execute a reduced scope of tests
The following CMake options can be set for the executable configuration:
- `USE_ORTOOLS` (default = OFF): enable multi-solver support via OR-Tools. When OFF, the binary is Sirius-only, identical to the legacy production version.
- `USE_XPRESS` (default = OFF, requires `USE_ORTOOLS=ON`): authorize `SOLVERCH=6` at runtime. Must reflect whether OR-Tools was built with the Xpress backend.
- `USE_SIRIUS_SHARED` (default = OFF): if active, link Sirius as a shared library instead of static.
- `METRIX_RUN_ALL_TESTS` (default = ON): if inactive, projects will execute a reduced scope of tests.

Refer to `metrix-simulator/README.md` for runtime solver selection (`SOLVERCH`/`PCSOLVERCH`) and the full build documentation.

##### Contributing

Expand Down
2 changes: 2 additions & 0 deletions docs/simulator/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ $> cmake --build . --target install

The following CMAKE options can be set for the executable configuration:
- `USE_SIRIUS_SHARED` (default = OFF): If active, the project will link using the shared library of sirius solver instead of the static library
- `USE_ORTOOLS` (default = OFF): If active, enables multi-solver support through [OR-Tools](https://developers.google.com/optimization). The solver used at runtime is then selected with the `SOLVERCH` / `PCSOLVERCH` input options (see [Inputs and outputs](io)). The third parties must have been built with `-DUSE_ORTOOLS=ON` as well, so that OR-Tools is available. When inactive, the binary is Sirius-only, identical to the legacy behavior
- `USE_XPRESS` (default = OFF): If active, authorizes the Xpress solver (`SOLVERCH=6`) at runtime. Requires `USE_ORTOOLS=ON`, and OR-Tools must have been built with the Xpress backend: set `XPRESS_ROOT` to the Xpress SDK path (environment variable or `-D` flag) when building the third parties in `external/`. See `metrix-simulator/README.md` for the detailed multi-solver build matrix
- `METRIX_RUN_ALL_TESTS` (default = ON): If inactive, the project will execute a reduced scope of tests

## Extras
Expand Down
3 changes: 3 additions & 0 deletions docs/simulator/io_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ N.B. : Les types de données sont définis par une lettre comme suit <a id="type
| LIMCURGR | I | 1 | Limite de redispatching curatif<br>= curativeRedispatchingLimit(-1) |
| ADEQUAOF | I | 1 | Offset des coûts de groupes et de délestage dans la phase d’équilibrage<br>= adequacyCostOffset(0) |
| REDISPOF | I | 1 | Offset des coûts de groupes et de délestage dans la phase de redispatching<br>= redispatchingCostOffset(0) |
| SOLVERCH | I | 1 | Choix du solveur pour l'optimisation principale (LP/MIP) : 0 GLPK, 1 CBC, 2 SCIP_GLOP, 3 GUROBI, 4 CPLEX, 5 SIRIUS, 6 XPRESS. Toute valeur différente de 5 nécessite un binaire compilé avec `USE_ORTOOLS` (et `USE_XPRESS` pour la valeur 6), faute de quoi la configuration est rejetée ; un solveur accepté à la compilation mais indisponible à l'exécution (backend absent du build OR-Tools, licence manquante) provoque une erreur `ERRSolveurIndisponible` à la première résolution.<br>= solverChoice (5) |
| PCSOLVERCH | I | 1 | Choix du solveur pour la phase d'empilement économique. Mêmes valeurs et mêmes contraintes que SOLVERCH.<br>= pcSolverChoice (5) |
| SPECIFICSOLVERPARAMS | C | 1 | Paramètres spécifiques transmis tels quels au solveur via OR-Tools (par exemple `"THREADS 1"` pour Xpress, format natif du solveur). Ignoré lorsque le solveur est SIRIUS.<br>= specificSolverParams (vide) |

(io-results-options)=
### Options de résultats
Expand Down
17 changes: 9 additions & 8 deletions metrix-simulator/.gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#
#
# Copyright (c) 2021, RTE (http://www.rte-france.com)
# See AUTHORS.txt
# All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
#
#

.idea
install
coverage
/tests/*/*/out_s*
/tests/*/*/metrixOut.txt
tests/*/*/metrix*.log
tests/*/*/result.txt
/tests/**/out_s*
/tests/**/metrixOut.txt
/tests/**/metrix*.log
/tests/**/result.txt
/tests/**/LODF_matrix.csv
/tests/**/PTDF_matrix.csv
!tests/*_reference/**/*
out/**
/tests/*/*/LODF_matrix.csv
/tests/*/*/PTDF_matrix.csv

docs/doc/**

Expand Down
119 changes: 91 additions & 28 deletions metrix-simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,56 @@
#
#
# Copyright (c) 2021, RTE (http://www.rte-france.com)
# See AUTHORS.txt
# All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
#
#

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

include(CMakePackageConfigHelpers)

project(MetrixSimulator
project(MetrixSimulator
VERSION 7.4.0
LANGUAGES C CXX)

cmake_policy(SET CMP0028 NEW) # Fatal error if "::" link is not imported / alias target
cmake_policy(SET CMP0074 NEW) # Use <package>_ROOT variables to find package

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(INSTALL_CMAKE_DIR cmake CACHE PATH "Installation directory for cmake files")

include(CMakeDependentOption)
include(InstallLib)

message("Build directory : ${CMAKE_BINARY_DIR}")
message("Source directory : ${CMAKE_SOURCE_DIR}")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED true)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(INSTALL_CMAKE_DIR cmake CACHE PATH "Installation directory for cmake files")
option(USE_ORTOOLS "Toggle or-tools usage" OFF) # disable by default
cmake_dependent_option(USE_XPRESS "Use XPress solver (must be same as 3rd party compilation)" OFF "USE_ORTOOLS" OFF) # not using xpress without ortools
option(USE_SIRIUS_SHARED "Use shared library for sirius solver" OFF)

if(USE_ORTOOLS)
message(VERBOSE "Use ortools")
if(USE_XPRESS)
message(VERBOSE "Use xpress with ortools")
else()
message(VERBOSE "Not using xpress")
endif()
else()
message(VERBOSE "Not using ortools")
endif()

if(USE_SIRIUS_SHARED)
message(VERBOSE "Use shared library for sirius solver")
else()
message(VERBOSE "Use static library for sirius solver")
endif()

if(MSVC)
add_definitions(-D_WIN32_WINNT=0x0A00)
Expand All @@ -46,11 +71,12 @@ else()
set(CMAKE_C_FLAGS_RELEASE "-O3")
endif(MSVC)

# Boost
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options log filesystem)

option(USE_SIRIUS_SHARED "Use shared library for sirius solver" OFF)
# Sirius
if (USE_SIRIUS_SHARED)
set(SIRIUS_NAME sirius_solver)
else()
Expand All @@ -60,6 +86,13 @@ endif()
set(${SIRIUS_NAME}_ROOT ${CMAKE_CURRENT_BINARY_DIR}/external/sirius_solver CACHE PATH "Path where a Sirius installation already exists")
find_package(${SIRIUS_NAME} REQUIRED)

# Ortools
set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
if(USE_ORTOOLS)
set(ortools_ROOT ${CMAKE_CURRENT_BINARY_DIR}/external/ortools CACHE PATH "Path where an OR-Tools installation already exists")
find_package(ortools CONFIG REQUIRED)
endif()

# SUITESPARSE
set(SUITESPARSE_HOME ${CMAKE_CURRENT_BINARY_DIR}/external/suitesparse CACHE PATH "Path where an SuiteSparse installation already exists")
find_package(SuiteSparse REQUIRED)
Expand All @@ -68,7 +101,7 @@ add_subdirectory(log)

message(STATUS "METRIX")

set(METRIX_HEADERS
set(METRIX_HEADERS
src/calcul.h
src/err/error.h
src/parametres.h
Expand All @@ -92,17 +125,17 @@ set(METRIX_HEADERS
src/margin_variations_compute.h
)

set(METRIX_SOURCES
set(METRIX_SOURCES
src/calculmacrofonctions.cpp
src/err/error.cpp
src/reseau.cpp
src/calculrepports.cpp
src/calculecrirecontraintesdodu.cpp
src/connexite.cpp
src/err/IoDico.cpp
src/err/error.cpp
src/reseau.cpp
src/calculrepports.cpp
src/calculecrirecontraintesdodu.cpp
src/connexite.cpp
src/err/IoDico.cpp
src/calculeEmpilementGroupes.cpp
src/metrix.cpp
src/metrix2assess.cpp
src/metrix2assess.cpp
src/config/configuration.cpp
src/config/input_configuration.cpp
src/config/variant_configuration.cpp
Expand All @@ -115,17 +148,27 @@ set(METRIX_SOURCES
src/margin_variations_compute.cpp
)

if(USE_ORTOOLS)
list(APPEND METRIX_SOURCES
src/ortools/solver.cpp
)
list(APPEND METRIX_HEADERS
src/ortools/solver.h
)
endif()

set(target "metrix-simulator")

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config/version.h)

add_executable(${target}
add_executable(${target}
${METRIX_HEADERS} ${METRIX_SOURCES})

target_include_directories(${target}
PRIVATE
metrix::log
src

${SIRIUS_NAME}
SuiteSparse::SuiteSparse_KLU
SuiteSparse::SuiteSparse_AMD
Expand All @@ -137,6 +180,7 @@ target_include_directories(${target}
target_link_libraries(${target}
PRIVATE
metrix::log

${SIRIUS_NAME}
SuiteSparse::SuiteSparse_KLU
SuiteSparse::SuiteSparse_AMD
Expand All @@ -147,25 +191,43 @@ target_link_libraries(${target}
$<$<BOOL:${MSVC}>:msvcrt.lib>
)

if(USE_ORTOOLS)
target_compile_definitions(${target}
PRIVATE
USE_ORTOOLS
)
target_include_directories(${target}
PRIVATE
ortools::ortools
)
target_link_libraries(${target}
PRIVATE
ortools::ortools
)
install_lib(ortools::ortools)
endif()

if(USE_XPRESS)
# XPRESS is consumed transitively through ortools::ortools, which was built
# against libxprs at its own link step. metrix-simulator does not need to
# link libxprs directly; this compile definition only signals to the C++
# configuration validation layer that the OR-Tools build supports XPRESS.
# libxprs.so must be reachable at runtime (LD_LIBRARY_PATH).
target_compile_definitions(${target}
PRIVATE
USE_XPRESS
)
endif()

if (USE_SIRIUS_SHARED)
# Export sirius library if using shared
get_target_property(sirius_PATH_LIB_RELEASE sirius_solver IMPORTED_LOCATION_RELEASE)
get_target_property(sirius_PATH_LIB_DEBUG sirius_solver IMPORTED_LOCATION_DEBUG)
if (EXISTS ${sirius_PATH_LIB_RELEASE})
set(sirius_PATH_LIB ${sirius_PATH_LIB_RELEASE})
elseif(EXISTS ${sirius_PATH_LIB_DEBUG})
set(sirius_PATH_LIB ${sirius_PATH_LIB_DEBUG})
else()
# shouldn't happen if find_package worked
message(FATAL_ERROR "sirius_solver imported location for debug or release was not found: check external installation")
endif()
install(FILES ${sirius_PATH_LIB} DESTINATION lib)
install_lib(sirius_solver)
endif()

set(CODE_COVERAGE FALSE CACHE BOOL "Enable code coverage")
if (CODE_COVERAGE)
message(STATUS "CODE COVERAGE")
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_BUILD_TYPE "Debug")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
include(cmake/CodeCoverage)
CODE_COVERAGE(NAME code-coverage
Expand All @@ -184,6 +246,7 @@ install(EXPORT targets
install(DIRECTORY ${PROJECT_SOURCE_DIR}/etc DESTINATION .)

option(METRIX_RUN_ALL_TESTS "Run reduced scope of tests" ON)
option(METRIX_RUN_XPRESS_TESTS "Enable the Xpress TNR test suite (requires a licensed FICO Xpress installation)" OFF)

enable_testing()
add_subdirectory(tests)
Expand Down
Loading
Loading