Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose API [ANT-1158] #1993

Merged
merged 250 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
250 commits
Select commit Hold shift + click to select a range
2842a82
Remove usage of fetch_content for runtime dependencies
JasonMarechal25 Apr 8, 2024
c191ccc
install minizip in ci
JasonMarechal25 Apr 9, 2024
d1b03f0
cREATE TEST
JasonMarechal25 Mar 12, 2024
aebd7ea
return simulation path
JasonMarechal25 Mar 12, 2024
1f16174
WIP API
JasonMarechal25 Mar 14, 2024
fbcbb12
Introduce study loader
JasonMarechal25 Mar 14, 2024
265a749
WIP
JasonMarechal25 Mar 15, 2024
edb3b93
FileTreeLoader encapsulate application
JasonMarechal25 Mar 15, 2024
1e78356
Revert application
JasonMarechal25 Mar 15, 2024
0328321
delete test
JasonMarechal25 Mar 15, 2024
c353737
Rename "utils" as "in-memory-study" and expose for all tests
JasonMarechal25 Mar 15, 2024
b18fda4
Use study loader in API
JasonMarechal25 Mar 15, 2024
aeff46c
Test API test internal
JasonMarechal25 Mar 15, 2024
294b76c
Simplify the code by not renaming the running process (#1798)
JasonMarechal25 Mar 13, 2024
bd96042
Refactor
JasonMarechal25 Mar 13, 2024
6f2bc9f
WIP
JasonMarechal25 Mar 15, 2024
7723965
Extract RunIn<Mode>Mode in free function
JasonMarechal25 Mar 18, 2024
700698c
Initialize runtime info
JasonMarechal25 Mar 18, 2024
1cc695b
Fix rebase
JasonMarechal25 Mar 18, 2024
13bdfdf
Output folder path is filled
JasonMarechal25 Mar 18, 2024
3bfa72a
Introduce translator
JasonMarechal25 Mar 19, 2024
de6285b
Basic data ok
JasonMarechal25 Mar 19, 2024
8afaa82
Sens de contrainte
JasonMarechal25 Mar 19, 2024
849ee24
Common data
JasonMarechal25 Mar 19, 2024
aa082e8
Complete tests for translator
JasonMarechal25 Mar 20, 2024
ecd6ef2
Enrich LPsFromAntaresInterface
JasonMarechal25 Mar 20, 2024
ba24ce7
Update runWeeklyOptimization
JasonMarechal25 Mar 20, 2024
ff04d62
Fix compil
JasonMarechal25 Mar 20, 2024
31c53e8
Pass observer along
JasonMarechal25 Mar 21, 2024
3d5d584
Notify problem hebdo
JasonMarechal25 Mar 21, 2024
55ef1c0
API expose results
JasonMarechal25 Mar 22, 2024
ac91e86
Install API
JasonMarechal25 Mar 22, 2024
473e2e4
Graphviz options
JasonMarechal25 Mar 27, 2024
91aa4ec
Make ortools private dependency of infeasible_problem_analysis
JasonMarechal25 Mar 27, 2024
9ced8f8
remove utils dependency in infeasible_problem_analysis
JasonMarechal25 Mar 27, 2024
ea56f08
Remove usage of fetch_content for runtime dependencies
JasonMarechal25 Apr 8, 2024
684a78e
Fix post rebase
JasonMarechal25 Apr 8, 2024
10897fb
Fix build tests
JasonMarechal25 Apr 9, 2024
8c20034
Remove boost dependency
JasonMarechal25 Apr 9, 2024
7b59706
Better error handling for API
JasonMarechal25 Apr 10, 2024
ab30c15
Add test client
JasonMarechal25 Apr 10, 2024
d870163
Add test API on CI
JasonMarechal25 Apr 10, 2024
09e5dd0
disable some tests
JasonMarechal25 Apr 10, 2024
698f339
Log for tests
JasonMarechal25 Apr 10, 2024
a31773a
Change dummy folder
JasonMarechal25 Apr 10, 2024
2a2fb8a
ADR for different targets EXE/API
JasonMarechal25 Apr 11, 2024
fd83e7e
Fix sonar issues
JasonMarechal25 Apr 11, 2024
f9a98e1
Fix build
JasonMarechal25 Apr 11, 2024
d6afa4e
Fix windows build
JasonMarechal25 Apr 11, 2024
8c370dc
Improve memory management for argc/argv in FileTreeStudyLoader::load
JasonMarechal25 Apr 11, 2024
2f553d6
Fix sonar issue
JasonMarechal25 Apr 11, 2024
4d60f64
Fix useless extra parameter
JasonMarechal25 Apr 11, 2024
145e331
disable tests
JasonMarechal25 Apr 12, 2024
c06abaa
Improve documentation
JasonMarechal25 Apr 12, 2024
0b73ed8
Disable external libs in graphviz
JasonMarechal25 Apr 12, 2024
b6d80ad
Formatting
JasonMarechal25 Apr 12, 2024
41becae
Document FileTreeStudyLoader
JasonMarechal25 Apr 12, 2024
88aec4b
Document FileTreeStudyLoader
JasonMarechal25 Apr 12, 2024
183b56e
Document HebdoProblemToLpsTranslator
JasonMarechal25 Apr 12, 2024
a277c90
Document HebdoProblemToLpsTranslator
JasonMarechal25 Apr 12, 2024
d7c0da5
Document APIInternal
JasonMarechal25 Apr 12, 2024
19cc0cd
Document API
JasonMarechal25 Apr 12, 2024
a5604e0
Document ISimulationObserver
JasonMarechal25 Apr 12, 2024
5190394
Add doc
JasonMarechal25 Apr 12, 2024
af94490
Add doc
JasonMarechal25 Apr 12, 2024
cbcee44
Improve lps encapsulation
JasonMarechal25 Apr 12, 2024
1ab7a89
Fix build
JasonMarechal25 Apr 12, 2024
55b5a1f
Remove need to build concrete file to access private implementation i…
JasonMarechal25 Apr 12, 2024
c6d9295
Accept reference instead of pointer to signal only not-null
JasonMarechal25 Apr 12, 2024
95f0177
Fix header in yuni file
JasonMarechal25 Apr 16, 2024
00a87be
Study loader return unique_ptr
JasonMarechal25 Apr 16, 2024
7d670c9
Use english for LpsFromAntares
JasonMarechal25 Apr 16, 2024
d32f3a8
Make SimulationObserver thread safe
JasonMarechal25 Apr 16, 2024
3122fcb
Fix string copy in FileTreeStudyLoader
JasonMarechal25 Apr 16, 2024
b929021
Improve ownership model on ISimulationObserver usage
JasonMarechal25 Apr 17, 2024
b12ddbe
Rename API_client as API_client_exemple
JasonMarechal25 Apr 17, 2024
9b2fc6c
Fix
JasonMarechal25 Apr 17, 2024
40e6c88
Download ortools for releases
JasonMarechal25 Apr 18, 2024
e64efdf
fix
JasonMarechal25 Apr 18, 2024
dd34ba7
fix
JasonMarechal25 Apr 18, 2024
5c8238c
fix?
JasonMarechal25 Apr 18, 2024
5b8ce3b
te
JasonMarechal25 Apr 18, 2024
0d42162
te
JasonMarechal25 Apr 18, 2024
1a9bf15
fix
JasonMarechal25 Apr 18, 2024
ce3d37b
API
JasonMarechal25 Apr 18, 2024
b31cd41
f
JasonMarechal25 Apr 18, 2024
206c59e
f
JasonMarechal25 Apr 19, 2024
3890a76
f
JasonMarechal25 Apr 19, 2024
813f9a0
try
JasonMarechal25 Apr 19, 2024
71f7bfa
try
JasonMarechal25 Apr 19, 2024
058fd70
API change
JasonMarechal25 Apr 19, 2024
983c4e8
Expose rvalue api
JasonMarechal25 Apr 19, 2024
157a11a
Fix deleted code
JasonMarechal25 Apr 23, 2024
d0b70d8
Add dependencies
JasonMarechal25 Apr 24, 2024
9e43b98
Fix missing files
JasonMarechal25 Apr 26, 2024
3c96764
Fix run_mode rebase
JasonMarechal25 Apr 26, 2024
819791b
Fix rebase
JasonMarechal25 Apr 26, 2024
ea4f661
Revert some work on CI
JasonMarechal25 Apr 26, 2024
08aefe0
Remove deleted file
JasonMarechal25 Apr 26, 2024
f115765
Revert doc change
JasonMarechal25 Apr 26, 2024
10859f0
Keep fetch content
JasonMarechal25 Apr 26, 2024
87f139e
Remove preset
JasonMarechal25 Apr 26, 2024
f87af95
Remove usage of fetch_content for runtime dependencies
JasonMarechal25 Apr 8, 2024
1a7d156
install minizip in ci
JasonMarechal25 Apr 9, 2024
0f0bc51
cREATE TEST
JasonMarechal25 Mar 12, 2024
421bf0b
return simulation path
JasonMarechal25 Mar 12, 2024
e7d8bd3
WIP API
JasonMarechal25 Mar 14, 2024
326d635
Introduce study loader
JasonMarechal25 Mar 14, 2024
2fc6010
delete test
JasonMarechal25 Mar 15, 2024
b99b20d
Rename "utils" as "in-memory-study" and expose for all tests
JasonMarechal25 Mar 15, 2024
a3a294e
Use study loader in API
JasonMarechal25 Mar 15, 2024
893c9f2
Test API test internal
JasonMarechal25 Mar 15, 2024
10ad34a
Simplify the code by not renaming the running process (#1798)
JasonMarechal25 Mar 13, 2024
bd52dae
Refactor
JasonMarechal25 Mar 13, 2024
f1c878d
Extract RunIn<Mode>Mode in free function
JasonMarechal25 Mar 18, 2024
4aeb010
Initialize runtime info
JasonMarechal25 Mar 18, 2024
5d8cfcd
Output folder path is filled
JasonMarechal25 Mar 18, 2024
6b09a70
Introduce translator
JasonMarechal25 Mar 19, 2024
e1ecd60
Basic data ok
JasonMarechal25 Mar 19, 2024
474703b
Sens de contrainte
JasonMarechal25 Mar 19, 2024
ebecd88
Common data
JasonMarechal25 Mar 19, 2024
17772f8
Complete tests for translator
JasonMarechal25 Mar 20, 2024
c373217
Enrich LPsFromAntaresInterface
JasonMarechal25 Mar 20, 2024
b9f08b6
Update runWeeklyOptimization
JasonMarechal25 Mar 20, 2024
c8ef29e
Fix compil
JasonMarechal25 Mar 20, 2024
bc7df31
Pass observer along
JasonMarechal25 Mar 21, 2024
0bdac96
Notify problem hebdo
JasonMarechal25 Mar 21, 2024
05b5bf5
API expose results
JasonMarechal25 Mar 22, 2024
eeeb3dc
Install API
JasonMarechal25 Mar 22, 2024
fe0d068
Make ortools private dependency of infeasible_problem_analysis
JasonMarechal25 Mar 27, 2024
87f8e80
remove utils dependency in infeasible_problem_analysis
JasonMarechal25 Mar 27, 2024
566383f
Remove usage of fetch_content for runtime dependencies
JasonMarechal25 Apr 8, 2024
165a057
Fix post rebase
JasonMarechal25 Apr 8, 2024
508c1b8
Fix build tests
JasonMarechal25 Apr 9, 2024
52c4de5
Remove boost dependency
JasonMarechal25 Apr 9, 2024
2800487
Better error handling for API
JasonMarechal25 Apr 10, 2024
fdedc77
Add test client
JasonMarechal25 Apr 10, 2024
a8d8c81
Add test API on CI
JasonMarechal25 Apr 10, 2024
df8acd6
disable some tests
JasonMarechal25 Apr 10, 2024
0680d6c
Log for tests
JasonMarechal25 Apr 10, 2024
8485b47
Change dummy folder
JasonMarechal25 Apr 10, 2024
303791b
ADR for different targets EXE/API
JasonMarechal25 Apr 11, 2024
8308912
Fix sonar issues
JasonMarechal25 Apr 11, 2024
c600e3a
Fix rebase
JasonMarechal25 May 13, 2024
5a718f6
Fix windows build
JasonMarechal25 Apr 11, 2024
8dba95b
Fix sonar issue
JasonMarechal25 Apr 11, 2024
6b1194e
Fix useless extra parameter
JasonMarechal25 Apr 11, 2024
5d735cd
disable tests
JasonMarechal25 Apr 12, 2024
742bce2
Improve documentation
JasonMarechal25 Apr 12, 2024
735c44f
Formatting
JasonMarechal25 Apr 12, 2024
e16f8e6
Document FileTreeStudyLoader
JasonMarechal25 Apr 12, 2024
7857b7d
Document HebdoProblemToLpsTranslator
JasonMarechal25 Apr 12, 2024
3a281dd
Document HebdoProblemToLpsTranslator
JasonMarechal25 Apr 12, 2024
52ad009
Document APIInternal
JasonMarechal25 Apr 12, 2024
e9c9679
Document API
JasonMarechal25 Apr 12, 2024
5e859b4
Document ISimulationObserver
JasonMarechal25 Apr 12, 2024
e05b6ca
Improve lps encapsulation
JasonMarechal25 Apr 12, 2024
8c3fb9f
Fix build
JasonMarechal25 Apr 12, 2024
33cc107
Remove need to build concrete file to access private implementation i…
JasonMarechal25 Apr 12, 2024
1dc48a0
Fix header in yuni file
JasonMarechal25 Apr 16, 2024
7ecdea0
Study loader return unique_ptr
JasonMarechal25 Apr 16, 2024
5e43b16
Use english for LpsFromAntares
JasonMarechal25 Apr 16, 2024
36b4266
Make SimulationObserver thread safe
JasonMarechal25 Apr 16, 2024
a9b2932
Improve ownership model on ISimulationObserver usage
JasonMarechal25 Apr 17, 2024
127c195
Rename API_client as API_client_exemple
JasonMarechal25 Apr 17, 2024
e373921
Fix
JasonMarechal25 Apr 17, 2024
274ef33
Download ortools for releases
JasonMarechal25 Apr 18, 2024
25b0aea
fix
JasonMarechal25 Apr 18, 2024
7013108
fix
JasonMarechal25 Apr 18, 2024
9ffc373
fix?
JasonMarechal25 Apr 18, 2024
feda04d
te
JasonMarechal25 Apr 18, 2024
05b9426
te
JasonMarechal25 Apr 18, 2024
d86b7a1
fix
JasonMarechal25 Apr 18, 2024
f17a72e
API
JasonMarechal25 Apr 18, 2024
b5ff166
f
JasonMarechal25 Apr 18, 2024
17e1fe6
f
JasonMarechal25 Apr 19, 2024
101d8b5
f
JasonMarechal25 Apr 19, 2024
081e47f
try
JasonMarechal25 Apr 19, 2024
f91ff81
try
JasonMarechal25 Apr 19, 2024
86c4da4
API change
JasonMarechal25 Apr 19, 2024
5674efc
Expose rvalue api
JasonMarechal25 Apr 19, 2024
ac7b9cb
Add dependencies
JasonMarechal25 Apr 24, 2024
e390b02
Fix run_mode rebase
JasonMarechal25 Apr 26, 2024
142906d
Fix rebase
JasonMarechal25 Apr 26, 2024
8e951ff
Revert some work on CI
JasonMarechal25 Apr 26, 2024
502b5fc
Remove deleted file
JasonMarechal25 Apr 26, 2024
785c401
Revert doc change
JasonMarechal25 Apr 26, 2024
70f50e7
Keep fetch content
JasonMarechal25 Apr 26, 2024
87bc865
Remove preset
JasonMarechal25 Apr 26, 2024
ce52ecf
Remove deprecated file
JasonMarechal25 May 13, 2024
dcfbeaa
lps cmake project
JasonMarechal25 May 13, 2024
034bf67
Fix rebase
JasonMarechal25 May 13, 2024
5de1fc7
Fix
JasonMarechal25 May 13, 2024
f4740d6
Fix namespacing
JasonMarechal25 May 13, 2024
c92a921
Merge remote-tracking branch 'refs/remotes/origin/feature/expose-api'…
JasonMarechal25 May 13, 2024
806b09c
Merge remote-tracking branch 'origin/develop' into feature/expose-api
JasonMarechal25 May 15, 2024
6e4faf3
Remove false ADR
JasonMarechal25 May 15, 2024
a4cc949
Reduce operation time during lock
JasonMarechal25 May 17, 2024
3557331
Namespace local function
JasonMarechal25 May 21, 2024
b5b83ab
Remove dynamique allocations
JasonMarechal25 May 21, 2024
dd0042f
Add test info
JasonMarechal25 May 21, 2024
ff5b207
Qualifier order
JasonMarechal25 May 24, 2024
7379b04
Remove dynamique allocation
JasonMarechal25 May 24, 2024
3f98747
Update comment
JasonMarechal25 May 24, 2024
2cef96a
Prefer reference over pointer
JasonMarechal25 May 24, 2024
6d4dc71
Update src/api_client_example/tests/test.cpp
JasonMarechal25 May 24, 2024
7c4eb52
Use caret for header
JasonMarechal25 May 24, 2024
1328822
Forward declare study
JasonMarechal25 May 24, 2024
0f7e631
Merge remote-tracking branch 'refs/remotes/origin/develop' into featu…
JasonMarechal25 May 24, 2024
da2200a
Update doc
JasonMarechal25 May 24, 2024
ef136fa
Merge branch 'develop' into feature/expose-api
JasonMarechal25 May 28, 2024
a2f7855
Remove unused functions
JasonMarechal25 May 28, 2024
8e05a20
Remove unused functions
JasonMarechal25 May 28, 2024
75dec38
Update src/solver/misc/options.cpp
JasonMarechal25 May 29, 2024
7a0d4c0
Merge branch 'develop' into feature/expose-api
JasonMarechal25 May 29, 2024
5227764
Fix missing deps
JasonMarechal25 May 29, 2024
945f63c
revert
JasonMarechal25 May 29, 2024
5e2154d
Merge remote-tracking branch 'refs/remotes/origin/develop' into featu…
JasonMarechal25 May 30, 2024
90f4a43
Fix ci
JasonMarechal25 May 30, 2024
3811672
Fix deps
JasonMarechal25 May 30, 2024
31fd8c3
Fix vcpkg
JasonMarechal25 May 30, 2024
8a80892
Fix build
JasonMarechal25 May 30, 2024
239ab61
Fix build
JasonMarechal25 May 30, 2024
cf088b2
fIX?
JasonMarechal25 May 30, 2024
4a08005
Try fix
JasonMarechal25 May 30, 2024
eb342ad
Revert "fIX?"
JasonMarechal25 May 30, 2024
376a887
Fix
JasonMarechal25 May 30, 2024
58a48f8
Fix
JasonMarechal25 May 30, 2024
b2f8aef
Fix
JasonMarechal25 May 30, 2024
ed51ea5
Fix
JasonMarechal25 May 31, 2024
fe91dc3
Fix
JasonMarechal25 May 31, 2024
8187ef1
Fix
JasonMarechal25 May 31, 2024
be66a73
Fix
JasonMarechal25 May 31, 2024
33d975b
Merge branch 'develop' into feature/expose-api
JasonMarechal25 May 31, 2024
2c3684a
Merge branch 'develop' into feature/expose-api
JasonMarechal25 Jun 3, 2024
9ff7e73
Fix sonar
JasonMarechal25 May 31, 2024
5ce4518
Fix memory issue
JasonMarechal25 May 31, 2024
a71e9f2
Fix merge
JasonMarechal25 Jun 3, 2024
f79397a
Format
JasonMarechal25 Jun 3, 2024
a9cc04c
Fix merge
JasonMarechal25 Jun 3, 2024
240b8f9
Fix build
JasonMarechal25 Jun 3, 2024
9b7ab35
Fix build
JasonMarechal25 Jun 3, 2024
3cf7aee
Fix build
JasonMarechal25 Jun 4, 2024
a37a33c
Merge remote-tracking branch 'origin/develop' into feature/expose-api
JasonMarechal25 Jun 17, 2024
c0f3388
Merge branch 'develop' into feature/expose-api
flomnes Jun 21, 2024
55fd528
Merge remote-tracking branch 'github/develop' into feature/expose-api
flomnes Jun 21, 2024
81a92de
Revert new_release.yml
flomnes Jun 21, 2024
182b0c8
Update src/solver/optimisation/HebdoProblemToLpsTranslator.cpp
flomnes Jun 21, 2024
01352c4
Remove unused inclusion
flomnes Jun 21, 2024
a6e22cb
Fix segfault
flomnes Jun 21, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/install-cmake-328/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Install cmake 3.28 using devtoolset 10"
name: "Install cmake 3.28 using devtoolset 10 if possible"
description: "Download and install system wide cmake 3.28"

runs:
Expand All @@ -7,7 +7,7 @@ runs:
- name: Build cmake
shell: bash
run: |
source /opt/rh/devtoolset-10/enable
source /opt/rh/devtoolset-10/enable || true # Ignore error if devtoolset-10 is not available
yum -y install openssl-devel
wget https://github.com/Kitware/CMake/releases/download/v3.28.2/cmake-3.28.2.tar.gz
tar -xvf cmake-3.28.2.tar.gz
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ env:
RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule' || inputs.run-tests == 'true' }}
REF: ${{ inputs.target_branch =='' && github.ref || inputs.target_branch}}
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
vcpkgPackages: yaml-cpp antlr4 boost-test
triplet: x64-linux
WX_CONFIG: /usr/bin/wx-config

Expand Down Expand Up @@ -115,6 +114,24 @@ jobs:
run: |
cmake --build _build -j$(nproc)

- name: Run API tests
run: |
cmake --install _build --prefix antares_install
cd src/api_client_example
cmake -B _build -S . \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=/usr/bin/gcc-10 \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
-DCMAKE_PREFIX_PATH="${{github.workspace}}/rte-antares-deps-Release;${{github.workspace}}/install;${{ env.ORTOOLS_DIR }}/install;${{github.workspace}}/antares_install;${{github.workspace}}/rte-antares-deps-Release;${{github.workspace}}/_build/vcpkg_installed/x64-linux-release"
cmake --build _build -j$(nproc)
cd _build
ctest -C Release --output-on-failure

# simtest
- name: Read simtest version
id: simtest-version
Expand Down
10 changes: 5 additions & 5 deletions docs/Architecture_Decision_Records/Expose_cpp_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

## Context

Some clients (e.g. Xpansion) would prefer to use a library than a CLI tool. Exposing a library require exposing a public API.
The API can be exposed either as pure C or as C++.
A C API can always be developped as a facade on top of a C++ API.
C++ API will not have to care about ABI compatibility because Simulator lib will be provided as static, meaning a client
upgrading would need to be recompiled and relink with the new lib version.
Several clients, such as Xpansion, express a preference for utilizing a library over a command-line interface (CLI) tool. Exposing a library necessitates the exposure of a public API.

This API can be presented in either pure C or C++. It's worth noting that a C API can always serve as a facade atop a C++ API.

In the case of a C++ API, concerns regarding ABI compatibility are alleviated, as the Simulator library is provided in a static form. Consequently, when a client upgrades, they would simply need to recompile and relink with the new version of the library.

## Decision

Expand Down
25 changes: 25 additions & 0 deletions docs/Architecture_Decision_Records/separate_install_exe_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Expose public C++ API

## Status: Rejected [2024/04/11]

## Context

Originally, there exists a single install target designated to deploy the diverse Antares executables, predominantly packaged within the release assets. However, there's a rationale behind avoiding the creation of a unified package containing both executables and libraries, given that they cater to distinct user demographics. This mirrors the flexibility offered by package managers such as apt, where users can opt to install binary packages and separate development (devel) packages according to their requirements.

## Decision

Split installation into two targets

Produce different assets/packages for each install targets.


## Consequences

* Mutltiplication of assets
* Two install targets to manage
* Users of executable not "polluted" by libraries

## Reason for rejection

The decision was rejected because it was deemed unnecessary to split the installation targets. It adds
some difficulties for few benefits at the moment
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ message(STATUS "OR-Tools tag ${ORTOOLS_TAG}")
FetchContent_MakeAvailable(ortools)
endif()

find_package(minizip-ng)
find_package(minizip-ng QUIET)
if (minizip-ng_FOUND)
add_library(MINIZIP::minizip ALIAS MINIZIP::minizip-ng)
else ()
Expand Down Expand Up @@ -267,6 +267,7 @@ add_subdirectory("ext/yuni/src")
OMESSAGE("") # empty line

# Sub Directories
add_subdirectory(api)
add_subdirectory(libs) #antares-core fswalker

if(BUILD_UI)
Expand Down
116 changes: 116 additions & 0 deletions src/api/API.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "API.h"
#include "antares/solver/simulation/economy_mode.h"
#include "antares/solver/simulation/adequacy_mode.h"
#include "antares/solver/misc/options.h"
#include "antares/infoCollection/StudyInfoCollector.h"
#include "antares/benchmarking/DurationCollector.h"
#include "antares/exception/LoadingError.hpp"
#include <antares/writer/writer_factory.h>
#include <SimulationObserver.h>

namespace Antares::API
{
SimulationResults APIInternal::run(const IStudyLoader& study_loader)
{
try {
study_ = study_loader.load();
} catch (const ::Antares::Error::StudyFolderDoesNotExist& e) {
Antares::API::Error err{.reason = e.what()};
return {
.simulationPath = "",
.antares_problems = {},
.error = err
};
}
return execute();
}

/**
* @brief The execute method is used to execute the simulation.
* @return SimulationResults object which contains the results of the simulation.
*
* This method is initialy a copy of Application::execute with some modifications hence the apparent dupllication
*/
SimulationResults APIInternal::execute() const
{
// study_ == nullptr e.g when the -h flag is given
if (!study_)
{
using namespace std::string_literals;
Antares::API::Error err{.reason = "Couldn't create study"s};
return {.simulationPath{}, .antares_problems{}, .error = err};
}

study_->computePThetaInfForThermalClusters();

// Only those two fields are used un simulation
Settings settings;
settings.tsGeneratorsOnly = false;
settings.noOutput = false;

Benchmarking::DurationCollector durationCollector;
Benchmarking::OptimizationInfo optimizationInfo;
auto ioQueueService = std::make_shared<Yuni::Job::QueueService>();
ioQueueService->maximumThreadCount(1);
ioQueueService->start();
auto resultWriter = Solver::resultWriterFactory(
study_->parameters.resultFormat, study_->folderOutput, ioQueueService, durationCollector);
SimulationObserver simulationObserver;
// Run the simulation
switch (study_->runtime->mode)
{
case Data::SimulationMode::Economy:
case Data::SimulationMode::Expansion:
Solver::runSimulationInEconomicMode(*study_,
settings,
durationCollector,
*resultWriter,
optimizationInfo,
simulationObserver);
break;
case Data::SimulationMode::Adequacy:
Solver::runSimulationInAdequacyMode(*study_,
settings,
durationCollector,
*resultWriter,
optimizationInfo,
simulationObserver);
break;
default:
break;
}

// Importing Time-Series if asked
study_->importTimeseriesIntoInput();

// Stop the display of the progression
study_->progression.stop();
return
{
.simulationPath = study_->folderOutput.c_str(),
.antares_problems = simulationObserver.acquireLps(),
.error{}
};
}
} // namespace Antares::API
42 changes: 42 additions & 0 deletions src/api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
add_library(solver_api)
add_library(Antares::solver_api ALIAS solver_api)

set(PUBLIC_HEADERS
include/antares/api/SimulationResults.h
include/antares/api/solver.h
)

set(PRIVATE_HEADERS
private/API.h
private/SimulationObserver.h
)

target_sources(solver_api
PRIVATE
solver.cpp
API.cpp
SimulationObserver.cpp
SimulationResults.cpp
${PUBLIC_HEADERS}
${PRIVATE_HEADERS}
)

target_include_directories(solver_api
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/private>
)

target_link_libraries(solver_api
PRIVATE
Antares::study
Antares::study-loader
Antares::file-tree-study-loader
antares-solver-simulation
PUBLIC
Antares::lps
)
install(DIRECTORY include/antares
DESTINATION "include"
)
73 changes: 73 additions & 0 deletions src/api/SimulationObserver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

/*
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "SimulationObserver.h"

#include "antares/solver/optimisation/HebdoProblemToLpsTranslator.h"

namespace Antares::API
{
namespace
{
auto translate(const PROBLEME_HEBDO& problemeHebdo,
std::string_view name,
const Solver::HebdoProblemToLpsTranslator& translator,
const unsigned int year,
const unsigned int week)
{
auto weekly_data = translator.translate(problemeHebdo.ProblemeAResoudre.get(), name);
Solver::ConstantDataFromAntares common_data;
if (year == 1 && week == 1)
{
common_data = translator.commonProblemData(problemeHebdo.ProblemeAResoudre.get());
}
return std::make_pair(common_data, weekly_data);
}
} // namespace

void SimulationObserver::notifyHebdoProblem(const PROBLEME_HEBDO& problemeHebdo,
int optimizationNumber,
std::string_view name)
{
if (optimizationNumber != 1)
{
return; // We only care about first optimization
}
Solver::HebdoProblemToLpsTranslator translator;
const unsigned int year = problemeHebdo.year + 1;
const unsigned int week = problemeHebdo.weekInTheYear + 1;
// common_data and weekly_data computed before the mutex lock to prevent blocking the thread
auto [common_data, weekly_data] = translate(problemeHebdo, name, translator, year, week);
std::lock_guard lock(mutex_);
if (year == 1 && week == 1)
{
lps_.setConstantData(common_data);
}
lps_.addWeeklyData({year, week}, weekly_data);
}

Solver::LpsFromAntares&& SimulationObserver::acquireLps() noexcept
{
std::lock_guard lock(mutex_);
return std::move(lps_);
}
} // namespace Antares::API
22 changes: 22 additions & 0 deletions src/api/SimulationResults.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "antares/api/SimulationResults.h"
Loading
Loading