-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/develop' into featu…
…re/resize # Conflicts: # src/solver/optimisation/opt_construction_matrice_des_contraintes_outils.cpp
- Loading branch information
Showing
113 changed files
with
2,565 additions
and
1,196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Check cpp formatting | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- feature/* | ||
- features/* | ||
- fix/* | ||
|
||
jobs: | ||
build: | ||
name: clang-format | ||
|
||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Print version | ||
run: clang-format --version | ||
|
||
- name: clang-format | ||
run: cd src && ./format-code.sh | ||
|
||
- name: git diff | ||
run: | | ||
DIFF=`git status --porcelain` | ||
if [[ $DIFF ]]; then | ||
echo "The following files are not well formatted" | ||
echo "$DIFF" | ||
exit 1 | ||
else | ||
echo "Code is well formatted, congrats !" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
docs/Architecture_Decision_Records/separate_install_exe_api.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.