From 3ca9107d14a94f4d898c0df2acea9e049870bde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Wed, 26 Jun 2024 11:19:28 +0200 Subject: [PATCH] Check formatting as part of the CI (#2193) Succeed if all source files are well formated. Fail otherwise, and display ill-formatted files. --------- Co-authored-by: Abdoulbari Zaher <32519851+a-zakir@users.noreply.github.com> --- .github/workflows/clang-format.yml | 36 + .../antlr-interface/ExprBaseVisitor.cpp | 3 - .../antares/antlr-interface/ExprBaseVisitor.h | 144 +- .../antares/antlr-interface/ExprLexer.cpp | 323 ++-- src/libs/antares/antlr-interface/ExprLexer.h | 67 +- .../antares/antlr-interface/ExprParser.cpp | 1590 ++++++++++------- src/libs/antares/antlr-interface/ExprParser.h | 392 ++-- .../antares/antlr-interface/ExprVisitor.cpp | 3 - .../antares/antlr-interface/ExprVisitor.h | 48 +- .../antares/checks/checkLoadedInputData.h | 1 - .../antares/exception/LoadingError.hpp | 7 +- .../FileTreeStudyLoader.h | 1 + .../include/antares/inifile/inifile.hxx | 3 +- src/libs/antares/inifile/inifile.cpp | 12 +- src/libs/antares/io/file.cpp | 2 +- src/libs/antares/io/include/antares/io/file.h | 4 +- .../antares/study-loader/IStudyLoader.h | 1 + src/libs/antares/study/area/area.cpp | 7 +- src/libs/antares/study/area/links.cpp | 27 +- src/libs/antares/study/area/list.cpp | 21 +- .../BindingConstraintGroupRepository.cpp | 18 +- .../antares/study/cleaner/cleaner-v20.cpp | 1 - .../study/include/antares/study/parameters.h | 3 +- .../antares/study/parts/hydro/container.h | 5 +- .../study/scenario-builder/hydroLevelsData.h | 3 +- .../study/include/antares/study/sets.hxx | 4 +- src/libs/antares/study/parameters.cpp | 17 +- .../study/parts/common/cluster_list.cpp | 5 +- .../antares/study/parts/hydro/allocation.cpp | 32 +- .../antares/study/parts/hydro/container.cpp | 256 +-- .../study/parts/hydro/finalLevelValidator.cpp | 46 +- src/libs/antares/study/parts/hydro/prepro.cpp | 8 +- src/libs/antares/study/parts/hydro/series.cpp | 2 +- .../study/parts/renewable/cluster_list.cpp | 2 +- .../parts/short-term-storage/container.cpp | 24 +- .../study/parts/thermal/cluster_list.cpp | 45 +- src/libs/antares/study/runtime/runtime.cpp | 6 +- .../BindingConstraintsTSNumbersData.cpp | 10 +- .../scenario-builder/hydroLevelsData.cpp | 6 +- .../antares/study/scenario-builder/rules.cpp | 5 +- src/libs/antares/study/study.cpp | 21 +- src/libs/antares/study/study.importprepro.cpp | 10 +- src/libs/antares/study/xcast/xcast.cpp | 3 +- src/libs/antares/writer/in_memory_writer.cpp | 2 +- src/libs/antares/writer/zip_writer.cpp | 1 - src/solver/application/application.cpp | 6 +- src/solver/constraints-builder/cbuilder.cpp | 3 +- .../solver/hydro/management/management.h | 3 +- src/solver/hydro/management/daily.cpp | 6 +- src/solver/hydro/management/management.cpp | 38 +- src/solver/hydro/management/monthly.cpp | 30 +- .../include/antares/solver/misc/options.h | 2 +- src/solver/misc/options.cpp | 2 +- src/solver/simulation/adequacy.cpp | 5 +- src/solver/simulation/common-eco-adq.cpp | 22 +- src/solver/simulation/common-hydro-levels.cpp | 22 +- src/solver/simulation/common-hydro-remix.cpp | 3 +- src/solver/simulation/economy.cpp | 5 +- .../hydro-final-reservoir-level-functions.cpp | 62 +- .../antares/solver/simulation/solver.hxx | 64 +- .../simulation/sim_calcul_economique.cpp | 10 +- src/solver/simulation/timeseries-numbers.cpp | 3 +- src/solver/ts-generator/availability.cpp | 22 +- src/solver/ts-generator/xcast/xcast.cpp | 3 +- src/solver/utils/ortools_utils.cpp | 8 +- .../antares/solver/variable/economy/all.h | 4 +- .../bindingConstraintsMarginalCost.h | 7 +- .../antares/solver/variable/endoflist.h | 1 - .../end-to-end/simple_study/simple-study.cpp | 2 +- src/tests/end-to-end/utils/utils.cpp | 3 +- src/tests/end-to-end/utils/utils.h | 3 + .../antlr4-interface/test_antlr_interface.cpp | 8 +- .../test-sc-builder-file-read-line.cpp | 80 +- .../test-sc-builder-file-save.cpp | 4 +- src/tests/src/libs/antares/test_utils.cpp | 9 +- .../antares/yaml-parser/test_yaml_parser.cpp | 16 +- ...-hydro-final-reservoir-level-functions.cpp | 18 +- 77 files changed, 2117 insertions(+), 1584 deletions(-) create mode 100644 .github/workflows/clang-format.yml diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000000..9e00892851 --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -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 diff --git a/src/libs/antares/antlr-interface/ExprBaseVisitor.cpp b/src/libs/antares/antlr-interface/ExprBaseVisitor.cpp index 42d6fef5d3..ec45c3a47e 100644 --- a/src/libs/antares/antlr-interface/ExprBaseVisitor.cpp +++ b/src/libs/antares/antlr-interface/ExprBaseVisitor.cpp @@ -1,7 +1,4 @@ // Generated from Expr.g4 by ANTLR 4.13.1 - #include "ExprBaseVisitor.h" - - diff --git a/src/libs/antares/antlr-interface/ExprBaseVisitor.h b/src/libs/antares/antlr-interface/ExprBaseVisitor.h index a8af3c573f..7ff7be623d 100644 --- a/src/libs/antares/antlr-interface/ExprBaseVisitor.h +++ b/src/libs/antares/antlr-interface/ExprBaseVisitor.h @@ -3,78 +3,88 @@ #pragma once - -#include "antlr4-runtime.h" #include "ExprVisitor.h" - +#include "antlr4-runtime.h" /** * This class provides an empty implementation of ExprVisitor, which can be * extended to create a visitor which only needs to handle a subset of the available methods. */ -class ExprBaseVisitor : public ExprVisitor { +class ExprBaseVisitor: public ExprVisitor +{ public: - - virtual std::any visitFullexpr(ExprParser::FullexprContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitShift(ExprParser::ShiftContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitIdentifier(ExprParser::IdentifierContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitNegation(ExprParser::NegationContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitExpression(ExprParser::ExpressionContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitComparison(ExprParser::ComparisonContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitAddsub(ExprParser::AddsubContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitPortField(ExprParser::PortFieldContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitMuldiv(ExprParser::MuldivContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitNumber(ExprParser::NumberContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitTimeIndex(ExprParser::TimeIndexContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitTimeShift(ExprParser::TimeShiftContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitFunction(ExprParser::FunctionContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitTimeShiftRange(ExprParser::TimeShiftRangeContext *ctx) override { - return visitChildren(ctx); - } - - virtual std::any visitTimeRange(ExprParser::TimeRangeContext *ctx) override { - return visitChildren(ctx); - } - - + virtual std::any visitFullexpr(ExprParser::FullexprContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitShift(ExprParser::ShiftContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitIdentifier(ExprParser::IdentifierContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitNegation(ExprParser::NegationContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitExpression(ExprParser::ExpressionContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitComparison(ExprParser::ComparisonContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitAddsub(ExprParser::AddsubContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitPortField(ExprParser::PortFieldContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitMuldiv(ExprParser::MuldivContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitNumber(ExprParser::NumberContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitTimeIndex(ExprParser::TimeIndexContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitTimeShift(ExprParser::TimeShiftContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitFunction(ExprParser::FunctionContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitTimeShiftRange(ExprParser::TimeShiftRangeContext* ctx) override + { + return visitChildren(ctx); + } + + virtual std::any visitTimeRange(ExprParser::TimeRangeContext* ctx) override + { + return visitChildren(ctx); + } }; - diff --git a/src/libs/antares/antlr-interface/ExprLexer.cpp b/src/libs/antares/antlr-interface/ExprLexer.cpp index a645fcddd0..9250294cf8 100644 --- a/src/libs/antares/antlr-interface/ExprLexer.cpp +++ b/src/libs/antares/antlr-interface/ExprLexer.cpp @@ -1,177 +1,238 @@ // Generated from Expr.g4 by ANTLR 4.13.1 - #include "ExprLexer.h" - using namespace antlr4; - - using namespace antlr4; -namespace { - -struct ExprLexerStaticData final { - ExprLexerStaticData(std::vector ruleNames, - std::vector channelNames, - std::vector modeNames, - std::vector literalNames, - std::vector symbolicNames) - : ruleNames(std::move(ruleNames)), channelNames(std::move(channelNames)), - modeNames(std::move(modeNames)), literalNames(std::move(literalNames)), +namespace +{ + +struct ExprLexerStaticData final +{ + ExprLexerStaticData(std::vector ruleNames, + std::vector channelNames, + std::vector modeNames, + std::vector literalNames, + std::vector symbolicNames): + ruleNames(std::move(ruleNames)), + channelNames(std::move(channelNames)), + modeNames(std::move(modeNames)), + literalNames(std::move(literalNames)), symbolicNames(std::move(symbolicNames)), - vocabulary(this->literalNames, this->symbolicNames) {} - - ExprLexerStaticData(const ExprLexerStaticData&) = delete; - ExprLexerStaticData(ExprLexerStaticData&&) = delete; - ExprLexerStaticData& operator=(const ExprLexerStaticData&) = delete; - ExprLexerStaticData& operator=(ExprLexerStaticData&&) = delete; - - std::vector decisionToDFA; - antlr4::atn::PredictionContextCache sharedContextCache; - const std::vector ruleNames; - const std::vector channelNames; - const std::vector modeNames; - const std::vector literalNames; - const std::vector symbolicNames; - const antlr4::dfa::Vocabulary vocabulary; - antlr4::atn::SerializedATNView serializedATN; - std::unique_ptr atn; + vocabulary(this->literalNames, this->symbolicNames) + { + } + + ExprLexerStaticData(const ExprLexerStaticData&) = delete; + ExprLexerStaticData(ExprLexerStaticData&&) = delete; + ExprLexerStaticData& operator=(const ExprLexerStaticData&) = delete; + ExprLexerStaticData& operator=(ExprLexerStaticData&&) = delete; + + std::vector decisionToDFA; + antlr4::atn::PredictionContextCache sharedContextCache; + const std::vector ruleNames; + const std::vector channelNames; + const std::vector modeNames; + const std::vector literalNames; + const std::vector symbolicNames; + const antlr4::dfa::Vocabulary vocabulary; + antlr4::atn::SerializedATNView serializedATN; + std::unique_ptr atn; }; ::antlr4::internal::OnceFlag exprlexerLexerOnceFlag; #if ANTLR4_USE_THREAD_LOCAL_CACHE static thread_local #endif -ExprLexerStaticData *exprlexerLexerStaticData = nullptr; + ExprLexerStaticData* exprlexerLexerStaticData + = nullptr; -void exprlexerLexerInitialize() { +void exprlexerLexerInitialize() +{ #if ANTLR4_USE_THREAD_LOCAL_CACHE - if (exprlexerLexerStaticData != nullptr) { - return; - } + if (exprlexerLexerStaticData != nullptr) + { + return; + } #else - assert(exprlexerLexerStaticData == nullptr); + assert(exprlexerLexerStaticData == nullptr); #endif - auto staticData = std::make_unique( - std::vector{ - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "DIGIT", "CHAR", "CHAR_OR_DIGIT", "NUMBER", "TIME", "IDENTIFIER", - "COMPARISON", "ADDSUB", "MULDIV", "LBRACKET", "RBRACKET", "WS" - }, - std::vector{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }, - std::vector{ - "DEFAULT_MODE" - }, - std::vector{ - "", "'+'", "'-'", "'/'", "'*'", "'.'", "'('", "')'", "','", "'..'", - "", "'t'", "", "", "", "", "'['", "']'" - }, - std::vector{ - "", "", "", "", "", "", "", "", "", "", "NUMBER", "TIME", "IDENTIFIER", - "COMPARISON", "ADDSUB", "MULDIV", "LBRACKET", "RBRACKET", "WS" + auto staticData = std::make_unique( + std::vector{"T__0", "T__1", "T__2", "T__3", "T__4", + "T__5", "T__6", "T__7", "T__8", "DIGIT", + "CHAR", "CHAR_OR_DIGIT", "NUMBER", "TIME", "IDENTIFIER", + "COMPARISON", "ADDSUB", "MULDIV", "LBRACKET", "RBRACKET", + "WS"}, + std::vector{"DEFAULT_TOKEN_CHANNEL", "HIDDEN"}, + std::vector{"DEFAULT_MODE"}, + std::vector{"", + "'+'", + "'-'", + "'/'", + "'*'", + "'.'", + "'('", + "')'", + "','", + "'..'", + "", + "'t'", + "", + "", + "", + "", + "'['", + "']'"}, + std::vector{"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "NUMBER", + "TIME", + "IDENTIFIER", + "COMPARISON", + "ADDSUB", + "MULDIV", + "LBRACKET", + "RBRACKET", + "WS"}); + static const int32_t serializedATNSegment[] = { + 4, 0, 18, 111, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, + 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, + 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, + 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, + 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 1, + 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, + 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, + 10, 1, 10, 1, 11, 1, 11, 3, 11, 69, 8, 11, 1, 12, 4, 12, 72, 8, 12, + 11, 12, 12, 12, 73, 1, 12, 1, 12, 4, 12, 78, 8, 12, 11, 12, 12, 12, 79, + 3, 12, 82, 8, 12, 1, 13, 1, 13, 1, 14, 1, 14, 5, 14, 88, 8, 14, 10, + 14, 12, 14, 91, 9, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 98, + 8, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, + 20, 1, 20, 1, 20, 1, 20, 0, 0, 21, 1, 1, 3, 2, 5, 3, 7, 4, 9, + 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 0, 21, 0, 23, 0, 25, 10, 27, 11, + 29, 12, 31, 13, 33, 14, 35, 15, 37, 16, 39, 17, 41, 18, 1, 0, 5, 1, 0, + 48, 57, 3, 0, 65, 90, 95, 95, 97, 122, 2, 0, 43, 43, 45, 45, 2, 0, 42, + 42, 47, 47, 3, 0, 9, 10, 13, 13, 32, 32, 114, 0, 1, 1, 0, 0, 0, 0, + 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, + 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, + 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, + 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, + 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, + 0, 41, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 45, 1, 0, 0, 0, 5, + 47, 1, 0, 0, 0, 7, 49, 1, 0, 0, 0, 9, 51, 1, 0, 0, 0, 11, 53, + 1, 0, 0, 0, 13, 55, 1, 0, 0, 0, 15, 57, 1, 0, 0, 0, 17, 59, 1, + 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 64, 1, 0, 0, 0, 23, 68, 1, 0, + 0, 0, 25, 71, 1, 0, 0, 0, 27, 83, 1, 0, 0, 0, 29, 85, 1, 0, 0, + 0, 31, 97, 1, 0, 0, 0, 33, 99, 1, 0, 0, 0, 35, 101, 1, 0, 0, 0, + 37, 103, 1, 0, 0, 0, 39, 105, 1, 0, 0, 0, 41, 107, 1, 0, 0, 0, 43, + 44, 5, 43, 0, 0, 44, 2, 1, 0, 0, 0, 45, 46, 5, 45, 0, 0, 46, 4, + 1, 0, 0, 0, 47, 48, 5, 47, 0, 0, 48, 6, 1, 0, 0, 0, 49, 50, 5, + 42, 0, 0, 50, 8, 1, 0, 0, 0, 51, 52, 5, 46, 0, 0, 52, 10, 1, 0, + 0, 0, 53, 54, 5, 40, 0, 0, 54, 12, 1, 0, 0, 0, 55, 56, 5, 41, 0, + 0, 56, 14, 1, 0, 0, 0, 57, 58, 5, 44, 0, 0, 58, 16, 1, 0, 0, 0, + 59, 60, 5, 46, 0, 0, 60, 61, 5, 46, 0, 0, 61, 18, 1, 0, 0, 0, 62, + 63, 7, 0, 0, 0, 63, 20, 1, 0, 0, 0, 64, 65, 7, 1, 0, 0, 65, 22, + 1, 0, 0, 0, 66, 69, 3, 21, 10, 0, 67, 69, 3, 19, 9, 0, 68, 66, 1, + 0, 0, 0, 68, 67, 1, 0, 0, 0, 69, 24, 1, 0, 0, 0, 70, 72, 3, 19, + 9, 0, 71, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 71, 1, 0, 0, + 0, 73, 74, 1, 0, 0, 0, 74, 81, 1, 0, 0, 0, 75, 77, 5, 46, 0, 0, + 76, 78, 3, 19, 9, 0, 77, 76, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, + 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 82, 1, 0, 0, 0, 81, 75, + 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 26, 1, 0, 0, 0, 83, 84, 5, + 116, 0, 0, 84, 28, 1, 0, 0, 0, 85, 89, 3, 21, 10, 0, 86, 88, 3, 23, + 11, 0, 87, 86, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, + 0, 89, 90, 1, 0, 0, 0, 90, 30, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, + 92, 98, 5, 61, 0, 0, 93, 94, 5, 62, 0, 0, 94, 98, 5, 61, 0, 0, 95, + 96, 5, 60, 0, 0, 96, 98, 5, 61, 0, 0, 97, 92, 1, 0, 0, 0, 97, 93, + 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 32, 1, 0, 0, 0, 99, 100, 7, + 2, 0, 0, 100, 34, 1, 0, 0, 0, 101, 102, 7, 3, 0, 0, 102, 36, 1, 0, + 0, 0, 103, 104, 5, 91, 0, 0, 104, 38, 1, 0, 0, 0, 105, 106, 5, 93, 0, + 0, 106, 40, 1, 0, 0, 0, 107, 108, 7, 4, 0, 0, 108, 109, 1, 0, 0, 0, + 109, 110, 6, 20, 0, 0, 110, 42, 1, 0, 0, 0, 7, 0, 68, 73, 79, 81, 89, + 97, 1, 6, 0, 0}; + staticData->serializedATN = antlr4::atn::SerializedATNView(serializedATNSegment, + sizeof(serializedATNSegment) + / sizeof(serializedATNSegment[0])); + + antlr4::atn::ATNDeserializer deserializer; + staticData->atn = deserializer.deserialize(staticData->serializedATN); + + const size_t count = staticData->atn->getNumberOfDecisions(); + staticData->decisionToDFA.reserve(count); + for (size_t i = 0; i < count; i++) + { + staticData->decisionToDFA.emplace_back(staticData->atn->getDecisionState(i), i); } - ); - static const int32_t serializedATNSegment[] = { - 4,0,18,111,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, - 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14, - 7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,1,0, - 1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1, - 8,1,9,1,9,1,10,1,10,1,11,1,11,3,11,69,8,11,1,12,4,12,72,8,12,11,12,12, - 12,73,1,12,1,12,4,12,78,8,12,11,12,12,12,79,3,12,82,8,12,1,13,1,13,1, - 14,1,14,5,14,88,8,14,10,14,12,14,91,9,14,1,15,1,15,1,15,1,15,1,15,3,15, - 98,8,15,1,16,1,16,1,17,1,17,1,18,1,18,1,19,1,19,1,20,1,20,1,20,1,20,0, - 0,21,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,0,21,0,23,0,25,10,27, - 11,29,12,31,13,33,14,35,15,37,16,39,17,41,18,1,0,5,1,0,48,57,3,0,65,90, - 95,95,97,122,2,0,43,43,45,45,2,0,42,42,47,47,3,0,9,10,13,13,32,32,114, - 0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0, - 0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0, - 0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39, - 1,0,0,0,0,41,1,0,0,0,1,43,1,0,0,0,3,45,1,0,0,0,5,47,1,0,0,0,7,49,1,0, - 0,0,9,51,1,0,0,0,11,53,1,0,0,0,13,55,1,0,0,0,15,57,1,0,0,0,17,59,1,0, - 0,0,19,62,1,0,0,0,21,64,1,0,0,0,23,68,1,0,0,0,25,71,1,0,0,0,27,83,1,0, - 0,0,29,85,1,0,0,0,31,97,1,0,0,0,33,99,1,0,0,0,35,101,1,0,0,0,37,103,1, - 0,0,0,39,105,1,0,0,0,41,107,1,0,0,0,43,44,5,43,0,0,44,2,1,0,0,0,45,46, - 5,45,0,0,46,4,1,0,0,0,47,48,5,47,0,0,48,6,1,0,0,0,49,50,5,42,0,0,50,8, - 1,0,0,0,51,52,5,46,0,0,52,10,1,0,0,0,53,54,5,40,0,0,54,12,1,0,0,0,55, - 56,5,41,0,0,56,14,1,0,0,0,57,58,5,44,0,0,58,16,1,0,0,0,59,60,5,46,0,0, - 60,61,5,46,0,0,61,18,1,0,0,0,62,63,7,0,0,0,63,20,1,0,0,0,64,65,7,1,0, - 0,65,22,1,0,0,0,66,69,3,21,10,0,67,69,3,19,9,0,68,66,1,0,0,0,68,67,1, - 0,0,0,69,24,1,0,0,0,70,72,3,19,9,0,71,70,1,0,0,0,72,73,1,0,0,0,73,71, - 1,0,0,0,73,74,1,0,0,0,74,81,1,0,0,0,75,77,5,46,0,0,76,78,3,19,9,0,77, - 76,1,0,0,0,78,79,1,0,0,0,79,77,1,0,0,0,79,80,1,0,0,0,80,82,1,0,0,0,81, - 75,1,0,0,0,81,82,1,0,0,0,82,26,1,0,0,0,83,84,5,116,0,0,84,28,1,0,0,0, - 85,89,3,21,10,0,86,88,3,23,11,0,87,86,1,0,0,0,88,91,1,0,0,0,89,87,1,0, - 0,0,89,90,1,0,0,0,90,30,1,0,0,0,91,89,1,0,0,0,92,98,5,61,0,0,93,94,5, - 62,0,0,94,98,5,61,0,0,95,96,5,60,0,0,96,98,5,61,0,0,97,92,1,0,0,0,97, - 93,1,0,0,0,97,95,1,0,0,0,98,32,1,0,0,0,99,100,7,2,0,0,100,34,1,0,0,0, - 101,102,7,3,0,0,102,36,1,0,0,0,103,104,5,91,0,0,104,38,1,0,0,0,105,106, - 5,93,0,0,106,40,1,0,0,0,107,108,7,4,0,0,108,109,1,0,0,0,109,110,6,20, - 0,0,110,42,1,0,0,0,7,0,68,73,79,81,89,97,1,6,0,0 - }; - staticData->serializedATN = antlr4::atn::SerializedATNView(serializedATNSegment, sizeof(serializedATNSegment) / sizeof(serializedATNSegment[0])); - - antlr4::atn::ATNDeserializer deserializer; - staticData->atn = deserializer.deserialize(staticData->serializedATN); - - const size_t count = staticData->atn->getNumberOfDecisions(); - staticData->decisionToDFA.reserve(count); - for (size_t i = 0; i < count; i++) { - staticData->decisionToDFA.emplace_back(staticData->atn->getDecisionState(i), i); - } - exprlexerLexerStaticData = staticData.release(); + exprlexerLexerStaticData = staticData.release(); } -} +} // namespace -ExprLexer::ExprLexer(CharStream *input) : Lexer(input) { - ExprLexer::initialize(); - _interpreter = new atn::LexerATNSimulator(this, *exprlexerLexerStaticData->atn, exprlexerLexerStaticData->decisionToDFA, exprlexerLexerStaticData->sharedContextCache); +ExprLexer::ExprLexer(CharStream* input): + Lexer(input) +{ + ExprLexer::initialize(); + _interpreter = new atn::LexerATNSimulator(this, + *exprlexerLexerStaticData->atn, + exprlexerLexerStaticData->decisionToDFA, + exprlexerLexerStaticData->sharedContextCache); } -ExprLexer::~ExprLexer() { - delete _interpreter; +ExprLexer::~ExprLexer() +{ + delete _interpreter; } -std::string ExprLexer::getGrammarFileName() const { - return "Expr.g4"; +std::string ExprLexer::getGrammarFileName() const +{ + return "Expr.g4"; } -const std::vector& ExprLexer::getRuleNames() const { - return exprlexerLexerStaticData->ruleNames; +const std::vector& ExprLexer::getRuleNames() const +{ + return exprlexerLexerStaticData->ruleNames; } -const std::vector& ExprLexer::getChannelNames() const { - return exprlexerLexerStaticData->channelNames; +const std::vector& ExprLexer::getChannelNames() const +{ + return exprlexerLexerStaticData->channelNames; } -const std::vector& ExprLexer::getModeNames() const { - return exprlexerLexerStaticData->modeNames; +const std::vector& ExprLexer::getModeNames() const +{ + return exprlexerLexerStaticData->modeNames; } -const dfa::Vocabulary& ExprLexer::getVocabulary() const { - return exprlexerLexerStaticData->vocabulary; +const dfa::Vocabulary& ExprLexer::getVocabulary() const +{ + return exprlexerLexerStaticData->vocabulary; } -antlr4::atn::SerializedATNView ExprLexer::getSerializedATN() const { - return exprlexerLexerStaticData->serializedATN; +antlr4::atn::SerializedATNView ExprLexer::getSerializedATN() const +{ + return exprlexerLexerStaticData->serializedATN; } -const atn::ATN& ExprLexer::getATN() const { - return *exprlexerLexerStaticData->atn; +const atn::ATN& ExprLexer::getATN() const +{ + return *exprlexerLexerStaticData->atn; } - - - -void ExprLexer::initialize() { +void ExprLexer::initialize() +{ #if ANTLR4_USE_THREAD_LOCAL_CACHE - exprlexerLexerInitialize(); + exprlexerLexerInitialize(); #else - ::antlr4::internal::call_once(exprlexerLexerOnceFlag, exprlexerLexerInitialize); + ::antlr4::internal::call_once(exprlexerLexerOnceFlag, exprlexerLexerInitialize); #endif } diff --git a/src/libs/antares/antlr-interface/ExprLexer.h b/src/libs/antares/antlr-interface/ExprLexer.h index c7db2c5f77..a569ec8d21 100644 --- a/src/libs/antares/antlr-interface/ExprLexer.h +++ b/src/libs/antares/antlr-interface/ExprLexer.h @@ -3,49 +3,58 @@ #pragma once - #include "antlr4-runtime.h" - - - -class ExprLexer : public antlr4::Lexer { +class ExprLexer: public antlr4::Lexer +{ public: - enum { - T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7, - T__7 = 8, T__8 = 9, NUMBER = 10, TIME = 11, IDENTIFIER = 12, COMPARISON = 13, - ADDSUB = 14, MULDIV = 15, LBRACKET = 16, RBRACKET = 17, WS = 18 - }; + enum + { + T__0 = 1, + T__1 = 2, + T__2 = 3, + T__3 = 4, + T__4 = 5, + T__5 = 6, + T__6 = 7, + T__7 = 8, + T__8 = 9, + NUMBER = 10, + TIME = 11, + IDENTIFIER = 12, + COMPARISON = 13, + ADDSUB = 14, + MULDIV = 15, + LBRACKET = 16, + RBRACKET = 17, + WS = 18 + }; - explicit ExprLexer(antlr4::CharStream *input); + explicit ExprLexer(antlr4::CharStream* input); - ~ExprLexer() override; + ~ExprLexer() override; + std::string getGrammarFileName() const override; - std::string getGrammarFileName() const override; + const std::vector& getRuleNames() const override; - const std::vector& getRuleNames() const override; + const std::vector& getChannelNames() const override; - const std::vector& getChannelNames() const override; + const std::vector& getModeNames() const override; - const std::vector& getModeNames() const override; + const antlr4::dfa::Vocabulary& getVocabulary() const override; - const antlr4::dfa::Vocabulary& getVocabulary() const override; + antlr4::atn::SerializedATNView getSerializedATN() const override; - antlr4::atn::SerializedATNView getSerializedATN() const override; + const antlr4::atn::ATN& getATN() const override; - const antlr4::atn::ATN& getATN() const override; - - // By default the static state used to implement the lexer is lazily initialized during the first - // call to the constructor. You can call this function if you wish to initialize the static state - // ahead of time. - static void initialize(); + // By default the static state used to implement the lexer is lazily initialized during the + // first call to the constructor. You can call this function if you wish to initialize the + // static state ahead of time. + static void initialize(); private: + // Individual action functions triggered by action() above. - // Individual action functions triggered by action() above. - - // Individual semantic predicate functions triggered by sempred() above. - + // Individual semantic predicate functions triggered by sempred() above. }; - diff --git a/src/libs/antares/antlr-interface/ExprParser.cpp b/src/libs/antares/antlr-interface/ExprParser.cpp index 3c688d96d3..64335f4d82 100644 --- a/src/libs/antares/antlr-interface/ExprParser.cpp +++ b/src/libs/antares/antlr-interface/ExprParser.cpp @@ -1,884 +1,1176 @@ // Generated from Expr.g4 by ANTLR 4.13.1 - -#include "ExprVisitor.h" - #include "ExprParser.h" +#include "ExprVisitor.h" using namespace antlrcpp; using namespace antlr4; -namespace { +namespace +{ -struct ExprParserStaticData final { - ExprParserStaticData(std::vector ruleNames, - std::vector literalNames, - std::vector symbolicNames) - : ruleNames(std::move(ruleNames)), literalNames(std::move(literalNames)), +struct ExprParserStaticData final +{ + ExprParserStaticData(std::vector ruleNames, + std::vector literalNames, + std::vector symbolicNames): + ruleNames(std::move(ruleNames)), + literalNames(std::move(literalNames)), symbolicNames(std::move(symbolicNames)), - vocabulary(this->literalNames, this->symbolicNames) {} - - ExprParserStaticData(const ExprParserStaticData&) = delete; - ExprParserStaticData(ExprParserStaticData&&) = delete; - ExprParserStaticData& operator=(const ExprParserStaticData&) = delete; - ExprParserStaticData& operator=(ExprParserStaticData&&) = delete; - - std::vector decisionToDFA; - antlr4::atn::PredictionContextCache sharedContextCache; - const std::vector ruleNames; - const std::vector literalNames; - const std::vector symbolicNames; - const antlr4::dfa::Vocabulary vocabulary; - antlr4::atn::SerializedATNView serializedATN; - std::unique_ptr atn; + vocabulary(this->literalNames, this->symbolicNames) + { + } + + ExprParserStaticData(const ExprParserStaticData&) = delete; + ExprParserStaticData(ExprParserStaticData&&) = delete; + ExprParserStaticData& operator=(const ExprParserStaticData&) = delete; + ExprParserStaticData& operator=(ExprParserStaticData&&) = delete; + + std::vector decisionToDFA; + antlr4::atn::PredictionContextCache sharedContextCache; + const std::vector ruleNames; + const std::vector literalNames; + const std::vector symbolicNames; + const antlr4::dfa::Vocabulary vocabulary; + antlr4::atn::SerializedATNView serializedATN; + std::unique_ptr atn; }; ::antlr4::internal::OnceFlag exprParserOnceFlag; #if ANTLR4_USE_THREAD_LOCAL_CACHE static thread_local #endif -ExprParserStaticData *exprParserStaticData = nullptr; + ExprParserStaticData* exprParserStaticData + = nullptr; -void exprParserInitialize() { +void exprParserInitialize() +{ #if ANTLR4_USE_THREAD_LOCAL_CACHE - if (exprParserStaticData != nullptr) { - return; - } + if (exprParserStaticData != nullptr) + { + return; + } #else - assert(exprParserStaticData == nullptr); + assert(exprParserStaticData == nullptr); #endif - auto staticData = std::make_unique( - std::vector{ - "fullexpr", "shift", "expr" - }, - std::vector{ - "", "'+'", "'-'", "'/'", "'*'", "'.'", "'('", "')'", "','", "'..'", - "", "'t'", "", "", "", "", "'['", "']'" - }, - std::vector{ - "", "", "", "", "", "", "", "", "", "", "NUMBER", "TIME", "IDENTIFIER", - "COMPARISON", "ADDSUB", "MULDIV", "LBRACKET", "RBRACKET", "WS" + auto staticData = std::make_unique(std::vector{"fullexpr", + "shift", + "expr"}, + std::vector{"", + "'+'", + "'-'", + "'/'", + "'*'", + "'.'", + "'('", + "')'", + "','", + "'..'", + "", + "'t'", + "", + "", + "", + "", + "'['", + "']'"}, + std::vector{"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "NUMBER", + "TIME", + "IDENTIFIER", + "COMPARISON", + "ADDSUB", + "MULDIV", + "LBRACKET", + "RBRACKET", + "WS"}); + static const int32_t serializedATNSegment[] = { + 4, 1, 18, 86, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 1, 0, 1, 0, 1, 0, 1, 1, + 1, 1, 1, 1, 3, 1, 13, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, + 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, + 2, 1, 2, 1, 2, 5, 2, 37, 8, 2, 10, 2, 12, 2, 40, 9, 2, 1, 2, 1, 2, 1, 2, 1, + 2, 1, 2, 1, 2, 1, 2, 5, 2, 49, 8, 2, 10, 2, 12, 2, 52, 9, 2, 1, 2, 1, 2, 1, + 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, + 2, 1, 2, 3, 2, 70, 8, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, + 1, 2, 5, 2, 81, 8, 2, 10, 2, 12, 2, 84, 9, 2, 1, 2, 0, 1, 4, 3, 0, 2, 4, 0, + 2, 1, 0, 1, 2, 1, 0, 3, 4, 97, 0, 6, 1, 0, 0, 0, 2, 9, 1, 0, 0, 0, 4, 69, + 1, 0, 0, 0, 6, 7, 3, 4, 2, 0, 7, 8, 5, 0, 0, 1, 8, 1, 1, 0, 0, 0, 9, 12, + 5, 11, 0, 0, 10, 11, 7, 0, 0, 0, 11, 13, 3, 4, 2, 0, 12, 10, 1, 0, 0, 0, 12, 13, + 1, 0, 0, 0, 13, 3, 1, 0, 0, 0, 14, 15, 6, 2, -1, 0, 15, 16, 5, 2, 0, 0, 16, 70, + 3, 4, 2, 13, 17, 70, 5, 12, 0, 0, 18, 19, 5, 12, 0, 0, 19, 20, 5, 5, 0, 0, 20, 70, + 5, 12, 0, 0, 21, 70, 5, 10, 0, 0, 22, 23, 5, 6, 0, 0, 23, 24, 3, 4, 2, 0, 24, 25, + 5, 7, 0, 0, 25, 70, 1, 0, 0, 0, 26, 27, 5, 12, 0, 0, 27, 28, 5, 6, 0, 0, 28, 29, + 3, 4, 2, 0, 29, 30, 5, 7, 0, 0, 30, 70, 1, 0, 0, 0, 31, 32, 5, 12, 0, 0, 32, 33, + 5, 16, 0, 0, 33, 38, 3, 2, 1, 0, 34, 35, 5, 8, 0, 0, 35, 37, 3, 2, 1, 0, 36, 34, + 1, 0, 0, 0, 37, 40, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 41, + 1, 0, 0, 0, 40, 38, 1, 0, 0, 0, 41, 42, 5, 17, 0, 0, 42, 70, 1, 0, 0, 0, 43, 44, + 5, 12, 0, 0, 44, 45, 5, 16, 0, 0, 45, 50, 3, 4, 2, 0, 46, 47, 5, 8, 0, 0, 47, 49, + 3, 4, 2, 0, 48, 46, 1, 0, 0, 0, 49, 52, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, + 1, 0, 0, 0, 51, 53, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 53, 54, 5, 17, 0, 0, 54, 70, + 1, 0, 0, 0, 55, 56, 5, 12, 0, 0, 56, 57, 5, 16, 0, 0, 57, 58, 3, 2, 1, 0, 58, 59, + 5, 9, 0, 0, 59, 60, 3, 2, 1, 0, 60, 61, 5, 17, 0, 0, 61, 70, 1, 0, 0, 0, 62, 63, + 5, 12, 0, 0, 63, 64, 5, 16, 0, 0, 64, 65, 3, 4, 2, 0, 65, 66, 5, 9, 0, 0, 66, 67, + 3, 4, 2, 0, 67, 68, 5, 17, 0, 0, 68, 70, 1, 0, 0, 0, 69, 14, 1, 0, 0, 0, 69, 17, + 1, 0, 0, 0, 69, 18, 1, 0, 0, 0, 69, 21, 1, 0, 0, 0, 69, 22, 1, 0, 0, 0, 69, 26, + 1, 0, 0, 0, 69, 31, 1, 0, 0, 0, 69, 43, 1, 0, 0, 0, 69, 55, 1, 0, 0, 0, 69, 62, + 1, 0, 0, 0, 70, 82, 1, 0, 0, 0, 71, 72, 10, 12, 0, 0, 72, 73, 7, 1, 0, 0, 73, 81, + 3, 4, 2, 13, 74, 75, 10, 11, 0, 0, 75, 76, 7, 0, 0, 0, 76, 81, 3, 4, 2, 12, 77, 78, + 10, 10, 0, 0, 78, 79, 5, 13, 0, 0, 79, 81, 3, 4, 2, 11, 80, 71, 1, 0, 0, 0, 80, 74, + 1, 0, 0, 0, 80, 77, 1, 0, 0, 0, 81, 84, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 82, 83, + 1, 0, 0, 0, 83, 5, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 6, 12, 38, 50, 69, 80, 82}; + staticData->serializedATN = antlr4::atn::SerializedATNView(serializedATNSegment, + sizeof(serializedATNSegment) + / sizeof(serializedATNSegment[0])); + + antlr4::atn::ATNDeserializer deserializer; + staticData->atn = deserializer.deserialize(staticData->serializedATN); + + const size_t count = staticData->atn->getNumberOfDecisions(); + staticData->decisionToDFA.reserve(count); + for (size_t i = 0; i < count; i++) + { + staticData->decisionToDFA.emplace_back(staticData->atn->getDecisionState(i), i); } - ); - static const int32_t serializedATNSegment[] = { - 4,1,18,86,2,0,7,0,2,1,7,1,2,2,7,2,1,0,1,0,1,0,1,1,1,1,1,1,3,1,13,8,1, - 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1, - 2,1,2,1,2,1,2,1,2,5,2,37,8,2,10,2,12,2,40,9,2,1,2,1,2,1,2,1,2,1,2,1,2, - 1,2,5,2,49,8,2,10,2,12,2,52,9,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1, - 2,1,2,1,2,1,2,1,2,1,2,1,2,3,2,70,8,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2, - 1,2,5,2,81,8,2,10,2,12,2,84,9,2,1,2,0,1,4,3,0,2,4,0,2,1,0,1,2,1,0,3,4, - 97,0,6,1,0,0,0,2,9,1,0,0,0,4,69,1,0,0,0,6,7,3,4,2,0,7,8,5,0,0,1,8,1,1, - 0,0,0,9,12,5,11,0,0,10,11,7,0,0,0,11,13,3,4,2,0,12,10,1,0,0,0,12,13,1, - 0,0,0,13,3,1,0,0,0,14,15,6,2,-1,0,15,16,5,2,0,0,16,70,3,4,2,13,17,70, - 5,12,0,0,18,19,5,12,0,0,19,20,5,5,0,0,20,70,5,12,0,0,21,70,5,10,0,0,22, - 23,5,6,0,0,23,24,3,4,2,0,24,25,5,7,0,0,25,70,1,0,0,0,26,27,5,12,0,0,27, - 28,5,6,0,0,28,29,3,4,2,0,29,30,5,7,0,0,30,70,1,0,0,0,31,32,5,12,0,0,32, - 33,5,16,0,0,33,38,3,2,1,0,34,35,5,8,0,0,35,37,3,2,1,0,36,34,1,0,0,0,37, - 40,1,0,0,0,38,36,1,0,0,0,38,39,1,0,0,0,39,41,1,0,0,0,40,38,1,0,0,0,41, - 42,5,17,0,0,42,70,1,0,0,0,43,44,5,12,0,0,44,45,5,16,0,0,45,50,3,4,2,0, - 46,47,5,8,0,0,47,49,3,4,2,0,48,46,1,0,0,0,49,52,1,0,0,0,50,48,1,0,0,0, - 50,51,1,0,0,0,51,53,1,0,0,0,52,50,1,0,0,0,53,54,5,17,0,0,54,70,1,0,0, - 0,55,56,5,12,0,0,56,57,5,16,0,0,57,58,3,2,1,0,58,59,5,9,0,0,59,60,3,2, - 1,0,60,61,5,17,0,0,61,70,1,0,0,0,62,63,5,12,0,0,63,64,5,16,0,0,64,65, - 3,4,2,0,65,66,5,9,0,0,66,67,3,4,2,0,67,68,5,17,0,0,68,70,1,0,0,0,69,14, - 1,0,0,0,69,17,1,0,0,0,69,18,1,0,0,0,69,21,1,0,0,0,69,22,1,0,0,0,69,26, - 1,0,0,0,69,31,1,0,0,0,69,43,1,0,0,0,69,55,1,0,0,0,69,62,1,0,0,0,70,82, - 1,0,0,0,71,72,10,12,0,0,72,73,7,1,0,0,73,81,3,4,2,13,74,75,10,11,0,0, - 75,76,7,0,0,0,76,81,3,4,2,12,77,78,10,10,0,0,78,79,5,13,0,0,79,81,3,4, - 2,11,80,71,1,0,0,0,80,74,1,0,0,0,80,77,1,0,0,0,81,84,1,0,0,0,82,80,1, - 0,0,0,82,83,1,0,0,0,83,5,1,0,0,0,84,82,1,0,0,0,6,12,38,50,69,80,82 - }; - staticData->serializedATN = antlr4::atn::SerializedATNView(serializedATNSegment, sizeof(serializedATNSegment) / sizeof(serializedATNSegment[0])); - - antlr4::atn::ATNDeserializer deserializer; - staticData->atn = deserializer.deserialize(staticData->serializedATN); - - const size_t count = staticData->atn->getNumberOfDecisions(); - staticData->decisionToDFA.reserve(count); - for (size_t i = 0; i < count; i++) { - staticData->decisionToDFA.emplace_back(staticData->atn->getDecisionState(i), i); - } - exprParserStaticData = staticData.release(); -} - + exprParserStaticData = staticData.release(); } -ExprParser::ExprParser(TokenStream *input) : ExprParser(input, antlr4::atn::ParserATNSimulatorOptions()) {} +} // namespace -ExprParser::ExprParser(TokenStream *input, const antlr4::atn::ParserATNSimulatorOptions &options) : Parser(input) { - ExprParser::initialize(); - _interpreter = new atn::ParserATNSimulator(this, *exprParserStaticData->atn, exprParserStaticData->decisionToDFA, exprParserStaticData->sharedContextCache, options); +ExprParser::ExprParser(TokenStream* input): + ExprParser(input, antlr4::atn::ParserATNSimulatorOptions()) +{ } -ExprParser::~ExprParser() { - delete _interpreter; +ExprParser::ExprParser(TokenStream* input, const antlr4::atn::ParserATNSimulatorOptions& options): + Parser(input) +{ + ExprParser::initialize(); + _interpreter = new atn::ParserATNSimulator(this, + *exprParserStaticData->atn, + exprParserStaticData->decisionToDFA, + exprParserStaticData->sharedContextCache, + options); } -const atn::ATN& ExprParser::getATN() const { - return *exprParserStaticData->atn; +ExprParser::~ExprParser() +{ + delete _interpreter; } -std::string ExprParser::getGrammarFileName() const { - return "Expr.g4"; +const atn::ATN& ExprParser::getATN() const +{ + return *exprParserStaticData->atn; } -const std::vector& ExprParser::getRuleNames() const { - return exprParserStaticData->ruleNames; +std::string ExprParser::getGrammarFileName() const +{ + return "Expr.g4"; } -const dfa::Vocabulary& ExprParser::getVocabulary() const { - return exprParserStaticData->vocabulary; +const std::vector& ExprParser::getRuleNames() const +{ + return exprParserStaticData->ruleNames; } -antlr4::atn::SerializedATNView ExprParser::getSerializedATN() const { - return exprParserStaticData->serializedATN; +const dfa::Vocabulary& ExprParser::getVocabulary() const +{ + return exprParserStaticData->vocabulary; } +antlr4::atn::SerializedATNView ExprParser::getSerializedATN() const +{ + return exprParserStaticData->serializedATN; +} -//----------------- FullexprContext ------------------------------------------------------------------ +//----------------- FullexprContext +//------------------------------------------------------------------ -ExprParser::FullexprContext::FullexprContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { +ExprParser::FullexprContext::FullexprContext(ParserRuleContext* parent, size_t invokingState): + ParserRuleContext(parent, invokingState) +{ } -ExprParser::ExprContext* ExprParser::FullexprContext::expr() { - return getRuleContext(0); +ExprParser::ExprContext* ExprParser::FullexprContext::expr() +{ + return getRuleContext(0); } -tree::TerminalNode* ExprParser::FullexprContext::EOF() { - return getToken(ExprParser::EOF, 0); +tree::TerminalNode* ExprParser::FullexprContext::EOF() +{ + return getToken(ExprParser::EOF, 0); } - -size_t ExprParser::FullexprContext::getRuleIndex() const { - return ExprParser::RuleFullexpr; +size_t ExprParser::FullexprContext::getRuleIndex() const +{ + return ExprParser::RuleFullexpr; } - -std::any ExprParser::FullexprContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitFullexpr(this); - else - return visitor->visitChildren(this); +std::any ExprParser::FullexprContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitFullexpr(this); + } + else + { + return visitor->visitChildren(this); + } } -ExprParser::FullexprContext* ExprParser::fullexpr() { - FullexprContext *_localctx = _tracker.createInstance(_ctx, getState()); - enterRule(_localctx, 0, ExprParser::RuleFullexpr); +ExprParser::FullexprContext* ExprParser::fullexpr() +{ + FullexprContext* _localctx = _tracker.createInstance(_ctx, getState()); + enterRule(_localctx, 0, ExprParser::RuleFullexpr); #if __cplusplus > 201703L - auto onExit = finally([=, this] { + auto onExit = finally( + [=, this] + { #else - auto onExit = finally([=] { + auto onExit = finally( + [=] + { #endif - exitRule(); - }); - try { - enterOuterAlt(_localctx, 1); - setState(6); - expr(0); - setState(7); - match(ExprParser::EOF); - - } - catch (RecognitionException &e) { - _errHandler->reportError(this, e); - _localctx->exception = std::current_exception(); - _errHandler->recover(this, _localctx->exception); - } - - return _localctx; + exitRule(); + }); + try + { + enterOuterAlt(_localctx, 1); + setState(6); + expr(0); + setState(7); + match(ExprParser::EOF); + } + catch (RecognitionException& e) + { + _errHandler->reportError(this, e); + _localctx->exception = std::current_exception(); + _errHandler->recover(this, _localctx->exception); + } + + return _localctx; } //----------------- ShiftContext ------------------------------------------------------------------ -ExprParser::ShiftContext::ShiftContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { +ExprParser::ShiftContext::ShiftContext(ParserRuleContext* parent, size_t invokingState): + ParserRuleContext(parent, invokingState) +{ } -tree::TerminalNode* ExprParser::ShiftContext::TIME() { - return getToken(ExprParser::TIME, 0); +tree::TerminalNode* ExprParser::ShiftContext::TIME() +{ + return getToken(ExprParser::TIME, 0); } -ExprParser::ExprContext* ExprParser::ShiftContext::expr() { - return getRuleContext(0); +ExprParser::ExprContext* ExprParser::ShiftContext::expr() +{ + return getRuleContext(0); } - -size_t ExprParser::ShiftContext::getRuleIndex() const { - return ExprParser::RuleShift; +size_t ExprParser::ShiftContext::getRuleIndex() const +{ + return ExprParser::RuleShift; } - -std::any ExprParser::ShiftContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitShift(this); - else - return visitor->visitChildren(this); +std::any ExprParser::ShiftContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitShift(this); + } + else + { + return visitor->visitChildren(this); + } } -ExprParser::ShiftContext* ExprParser::shift() { - ShiftContext *_localctx = _tracker.createInstance(_ctx, getState()); - enterRule(_localctx, 2, ExprParser::RuleShift); - size_t _la = 0; +ExprParser::ShiftContext* ExprParser::shift() +{ + ShiftContext* _localctx = _tracker.createInstance(_ctx, getState()); + enterRule(_localctx, 2, ExprParser::RuleShift); + size_t _la = 0; #if __cplusplus > 201703L - auto onExit = finally([=, this] { + auto onExit = finally( + [=, this] + { #else - auto onExit = finally([=] { + auto onExit = finally( + [=] + { #endif - exitRule(); - }); - try { - enterOuterAlt(_localctx, 1); - setState(9); - match(ExprParser::TIME); - setState(12); - _errHandler->sync(this); - - _la = _input->LA(1); - if (_la == ExprParser::T__0 - - || _la == ExprParser::T__1) { - setState(10); - antlrcpp::downCast(_localctx)->op = _input->LT(1); - _la = _input->LA(1); - if (!(_la == ExprParser::T__0 - - || _la == ExprParser::T__1)) { - antlrcpp::downCast(_localctx)->op = _errHandler->recoverInline(this); - } - else { - _errHandler->reportMatch(this); - consume(); - } - setState(11); - expr(0); - } - - } - catch (RecognitionException &e) { - _errHandler->reportError(this, e); - _localctx->exception = std::current_exception(); - _errHandler->recover(this, _localctx->exception); - } - - return _localctx; + exitRule(); + }); + try + { + enterOuterAlt(_localctx, 1); + setState(9); + match(ExprParser::TIME); + setState(12); + _errHandler->sync(this); + + _la = _input->LA(1); + if (_la == ExprParser::T__0 + + || _la == ExprParser::T__1) + { + setState(10); + antlrcpp::downCast(_localctx)->op = _input->LT(1); + _la = _input->LA(1); + if (!(_la == ExprParser::T__0 + + || _la == ExprParser::T__1)) + { + antlrcpp::downCast(_localctx)->op = _errHandler->recoverInline(this); + } + else + { + _errHandler->reportMatch(this); + consume(); + } + setState(11); + expr(0); + } + } + catch (RecognitionException& e) + { + _errHandler->reportError(this, e); + _localctx->exception = std::current_exception(); + _errHandler->recover(this, _localctx->exception); + } + + return _localctx; } //----------------- ExprContext ------------------------------------------------------------------ -ExprParser::ExprContext::ExprContext(ParserRuleContext *parent, size_t invokingState) - : ParserRuleContext(parent, invokingState) { +ExprParser::ExprContext::ExprContext(ParserRuleContext* parent, size_t invokingState): + ParserRuleContext(parent, invokingState) +{ } - -size_t ExprParser::ExprContext::getRuleIndex() const { - return ExprParser::RuleExpr; +size_t ExprParser::ExprContext::getRuleIndex() const +{ + return ExprParser::RuleExpr; } -void ExprParser::ExprContext::copyFrom(ExprContext *ctx) { - ParserRuleContext::copyFrom(ctx); +void ExprParser::ExprContext::copyFrom(ExprContext* ctx) +{ + ParserRuleContext::copyFrom(ctx); } -//----------------- IdentifierContext ------------------------------------------------------------------ +//----------------- IdentifierContext +//------------------------------------------------------------------ + +tree::TerminalNode* ExprParser::IdentifierContext::IDENTIFIER() +{ + return getToken(ExprParser::IDENTIFIER, 0); +} -tree::TerminalNode* ExprParser::IdentifierContext::IDENTIFIER() { - return getToken(ExprParser::IDENTIFIER, 0); +ExprParser::IdentifierContext::IdentifierContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::IdentifierContext::IdentifierContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::IdentifierContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitIdentifier(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- NegationContext +//------------------------------------------------------------------ -std::any ExprParser::IdentifierContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitIdentifier(this); - else - return visitor->visitChildren(this); +ExprParser::ExprContext* ExprParser::NegationContext::expr() +{ + return getRuleContext(0); } -//----------------- NegationContext ------------------------------------------------------------------ -ExprParser::ExprContext* ExprParser::NegationContext::expr() { - return getRuleContext(0); +ExprParser::NegationContext::NegationContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::NegationContext::NegationContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::NegationContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitNegation(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- ExpressionContext +//------------------------------------------------------------------ -std::any ExprParser::NegationContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitNegation(this); - else - return visitor->visitChildren(this); +ExprParser::ExprContext* ExprParser::ExpressionContext::expr() +{ + return getRuleContext(0); } -//----------------- ExpressionContext ------------------------------------------------------------------ -ExprParser::ExprContext* ExprParser::ExpressionContext::expr() { - return getRuleContext(0); +ExprParser::ExpressionContext::ExpressionContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::ExpressionContext::ExpressionContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::ExpressionContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitExpression(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- ComparisonContext +//------------------------------------------------------------------ -std::any ExprParser::ExpressionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitExpression(this); - else - return visitor->visitChildren(this); +std::vector ExprParser::ComparisonContext::expr() +{ + return getRuleContexts(); } -//----------------- ComparisonContext ------------------------------------------------------------------ -std::vector ExprParser::ComparisonContext::expr() { - return getRuleContexts(); +ExprParser::ExprContext* ExprParser::ComparisonContext::expr(size_t i) +{ + return getRuleContext(i); } -ExprParser::ExprContext* ExprParser::ComparisonContext::expr(size_t i) { - return getRuleContext(i); +tree::TerminalNode* ExprParser::ComparisonContext::COMPARISON() +{ + return getToken(ExprParser::COMPARISON, 0); } -tree::TerminalNode* ExprParser::ComparisonContext::COMPARISON() { - return getToken(ExprParser::COMPARISON, 0); +ExprParser::ComparisonContext::ComparisonContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::ComparisonContext::ComparisonContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::ComparisonContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitComparison(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- AddsubContext ------------------------------------------------------------------ -std::any ExprParser::ComparisonContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitComparison(this); - else - return visitor->visitChildren(this); +std::vector ExprParser::AddsubContext::expr() +{ + return getRuleContexts(); } -//----------------- AddsubContext ------------------------------------------------------------------ -std::vector ExprParser::AddsubContext::expr() { - return getRuleContexts(); +ExprParser::ExprContext* ExprParser::AddsubContext::expr(size_t i) +{ + return getRuleContext(i); } -ExprParser::ExprContext* ExprParser::AddsubContext::expr(size_t i) { - return getRuleContext(i); +ExprParser::AddsubContext::AddsubContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::AddsubContext::AddsubContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::AddsubContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitAddsub(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- PortFieldContext +//------------------------------------------------------------------ -std::any ExprParser::AddsubContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitAddsub(this); - else - return visitor->visitChildren(this); +std::vector ExprParser::PortFieldContext::IDENTIFIER() +{ + return getTokens(ExprParser::IDENTIFIER); } -//----------------- PortFieldContext ------------------------------------------------------------------ -std::vector ExprParser::PortFieldContext::IDENTIFIER() { - return getTokens(ExprParser::IDENTIFIER); +tree::TerminalNode* ExprParser::PortFieldContext::IDENTIFIER(size_t i) +{ + return getToken(ExprParser::IDENTIFIER, i); } -tree::TerminalNode* ExprParser::PortFieldContext::IDENTIFIER(size_t i) { - return getToken(ExprParser::IDENTIFIER, i); +ExprParser::PortFieldContext::PortFieldContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::PortFieldContext::PortFieldContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::PortFieldContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitPortField(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- MuldivContext ------------------------------------------------------------------ -std::any ExprParser::PortFieldContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitPortField(this); - else - return visitor->visitChildren(this); +std::vector ExprParser::MuldivContext::expr() +{ + return getRuleContexts(); } -//----------------- MuldivContext ------------------------------------------------------------------ -std::vector ExprParser::MuldivContext::expr() { - return getRuleContexts(); +ExprParser::ExprContext* ExprParser::MuldivContext::expr(size_t i) +{ + return getRuleContext(i); } -ExprParser::ExprContext* ExprParser::MuldivContext::expr(size_t i) { - return getRuleContext(i); +ExprParser::MuldivContext::MuldivContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::MuldivContext::MuldivContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::MuldivContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitMuldiv(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- NumberContext ------------------------------------------------------------------ -std::any ExprParser::MuldivContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitMuldiv(this); - else - return visitor->visitChildren(this); +tree::TerminalNode* ExprParser::NumberContext::NUMBER() +{ + return getToken(ExprParser::NUMBER, 0); } -//----------------- NumberContext ------------------------------------------------------------------ -tree::TerminalNode* ExprParser::NumberContext::NUMBER() { - return getToken(ExprParser::NUMBER, 0); +ExprParser::NumberContext::NumberContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::NumberContext::NumberContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::NumberContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitNumber(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- TimeIndexContext +//------------------------------------------------------------------ -std::any ExprParser::NumberContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitNumber(this); - else - return visitor->visitChildren(this); +tree::TerminalNode* ExprParser::TimeIndexContext::IDENTIFIER() +{ + return getToken(ExprParser::IDENTIFIER, 0); } -//----------------- TimeIndexContext ------------------------------------------------------------------ -tree::TerminalNode* ExprParser::TimeIndexContext::IDENTIFIER() { - return getToken(ExprParser::IDENTIFIER, 0); +tree::TerminalNode* ExprParser::TimeIndexContext::LBRACKET() +{ + return getToken(ExprParser::LBRACKET, 0); } -tree::TerminalNode* ExprParser::TimeIndexContext::LBRACKET() { - return getToken(ExprParser::LBRACKET, 0); +std::vector ExprParser::TimeIndexContext::expr() +{ + return getRuleContexts(); } -std::vector ExprParser::TimeIndexContext::expr() { - return getRuleContexts(); +ExprParser::ExprContext* ExprParser::TimeIndexContext::expr(size_t i) +{ + return getRuleContext(i); } -ExprParser::ExprContext* ExprParser::TimeIndexContext::expr(size_t i) { - return getRuleContext(i); +tree::TerminalNode* ExprParser::TimeIndexContext::RBRACKET() +{ + return getToken(ExprParser::RBRACKET, 0); } -tree::TerminalNode* ExprParser::TimeIndexContext::RBRACKET() { - return getToken(ExprParser::RBRACKET, 0); +ExprParser::TimeIndexContext::TimeIndexContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::TimeIndexContext::TimeIndexContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::TimeIndexContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitTimeIndex(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- TimeShiftContext +//------------------------------------------------------------------ -std::any ExprParser::TimeIndexContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitTimeIndex(this); - else - return visitor->visitChildren(this); +tree::TerminalNode* ExprParser::TimeShiftContext::IDENTIFIER() +{ + return getToken(ExprParser::IDENTIFIER, 0); } -//----------------- TimeShiftContext ------------------------------------------------------------------ -tree::TerminalNode* ExprParser::TimeShiftContext::IDENTIFIER() { - return getToken(ExprParser::IDENTIFIER, 0); +tree::TerminalNode* ExprParser::TimeShiftContext::LBRACKET() +{ + return getToken(ExprParser::LBRACKET, 0); } -tree::TerminalNode* ExprParser::TimeShiftContext::LBRACKET() { - return getToken(ExprParser::LBRACKET, 0); +std::vector ExprParser::TimeShiftContext::shift() +{ + return getRuleContexts(); } -std::vector ExprParser::TimeShiftContext::shift() { - return getRuleContexts(); +ExprParser::ShiftContext* ExprParser::TimeShiftContext::shift(size_t i) +{ + return getRuleContext(i); } -ExprParser::ShiftContext* ExprParser::TimeShiftContext::shift(size_t i) { - return getRuleContext(i); +tree::TerminalNode* ExprParser::TimeShiftContext::RBRACKET() +{ + return getToken(ExprParser::RBRACKET, 0); } -tree::TerminalNode* ExprParser::TimeShiftContext::RBRACKET() { - return getToken(ExprParser::RBRACKET, 0); +ExprParser::TimeShiftContext::TimeShiftContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::TimeShiftContext::TimeShiftContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::TimeShiftContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitTimeShift(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- FunctionContext +//------------------------------------------------------------------ -std::any ExprParser::TimeShiftContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitTimeShift(this); - else - return visitor->visitChildren(this); +tree::TerminalNode* ExprParser::FunctionContext::IDENTIFIER() +{ + return getToken(ExprParser::IDENTIFIER, 0); } -//----------------- FunctionContext ------------------------------------------------------------------ -tree::TerminalNode* ExprParser::FunctionContext::IDENTIFIER() { - return getToken(ExprParser::IDENTIFIER, 0); +ExprParser::ExprContext* ExprParser::FunctionContext::expr() +{ + return getRuleContext(0); } -ExprParser::ExprContext* ExprParser::FunctionContext::expr() { - return getRuleContext(0); +ExprParser::FunctionContext::FunctionContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::FunctionContext::FunctionContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::FunctionContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitFunction(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- TimeShiftRangeContext +//------------------------------------------------------------------ -std::any ExprParser::FunctionContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitFunction(this); - else - return visitor->visitChildren(this); +tree::TerminalNode* ExprParser::TimeShiftRangeContext::IDENTIFIER() +{ + return getToken(ExprParser::IDENTIFIER, 0); } -//----------------- TimeShiftRangeContext ------------------------------------------------------------------ -tree::TerminalNode* ExprParser::TimeShiftRangeContext::IDENTIFIER() { - return getToken(ExprParser::IDENTIFIER, 0); +tree::TerminalNode* ExprParser::TimeShiftRangeContext::LBRACKET() +{ + return getToken(ExprParser::LBRACKET, 0); } -tree::TerminalNode* ExprParser::TimeShiftRangeContext::LBRACKET() { - return getToken(ExprParser::LBRACKET, 0); +tree::TerminalNode* ExprParser::TimeShiftRangeContext::RBRACKET() +{ + return getToken(ExprParser::RBRACKET, 0); } -tree::TerminalNode* ExprParser::TimeShiftRangeContext::RBRACKET() { - return getToken(ExprParser::RBRACKET, 0); +std::vector ExprParser::TimeShiftRangeContext::shift() +{ + return getRuleContexts(); } -std::vector ExprParser::TimeShiftRangeContext::shift() { - return getRuleContexts(); +ExprParser::ShiftContext* ExprParser::TimeShiftRangeContext::shift(size_t i) +{ + return getRuleContext(i); } -ExprParser::ShiftContext* ExprParser::TimeShiftRangeContext::shift(size_t i) { - return getRuleContext(i); +ExprParser::TimeShiftRangeContext::TimeShiftRangeContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::TimeShiftRangeContext::TimeShiftRangeContext(ExprContext *ctx) { copyFrom(ctx); } +std::any ExprParser::TimeShiftRangeContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitTimeShiftRange(this); + } + else + { + return visitor->visitChildren(this); + } +} +//----------------- TimeRangeContext +//------------------------------------------------------------------ -std::any ExprParser::TimeShiftRangeContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitTimeShiftRange(this); - else - return visitor->visitChildren(this); +tree::TerminalNode* ExprParser::TimeRangeContext::IDENTIFIER() +{ + return getToken(ExprParser::IDENTIFIER, 0); } -//----------------- TimeRangeContext ------------------------------------------------------------------ -tree::TerminalNode* ExprParser::TimeRangeContext::IDENTIFIER() { - return getToken(ExprParser::IDENTIFIER, 0); +tree::TerminalNode* ExprParser::TimeRangeContext::LBRACKET() +{ + return getToken(ExprParser::LBRACKET, 0); } -tree::TerminalNode* ExprParser::TimeRangeContext::LBRACKET() { - return getToken(ExprParser::LBRACKET, 0); +std::vector ExprParser::TimeRangeContext::expr() +{ + return getRuleContexts(); } -std::vector ExprParser::TimeRangeContext::expr() { - return getRuleContexts(); +ExprParser::ExprContext* ExprParser::TimeRangeContext::expr(size_t i) +{ + return getRuleContext(i); } -ExprParser::ExprContext* ExprParser::TimeRangeContext::expr(size_t i) { - return getRuleContext(i); +tree::TerminalNode* ExprParser::TimeRangeContext::RBRACKET() +{ + return getToken(ExprParser::RBRACKET, 0); } -tree::TerminalNode* ExprParser::TimeRangeContext::RBRACKET() { - return getToken(ExprParser::RBRACKET, 0); +ExprParser::TimeRangeContext::TimeRangeContext(ExprContext* ctx) +{ + copyFrom(ctx); } -ExprParser::TimeRangeContext::TimeRangeContext(ExprContext *ctx) { copyFrom(ctx); } - - -std::any ExprParser::TimeRangeContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) - return parserVisitor->visitTimeRange(this); - else - return visitor->visitChildren(this); +std::any ExprParser::TimeRangeContext::accept(tree::ParseTreeVisitor* visitor) +{ + if (auto parserVisitor = dynamic_cast(visitor)) + { + return parserVisitor->visitTimeRange(this); + } + else + { + return visitor->visitChildren(this); + } } -ExprParser::ExprContext* ExprParser::expr() { - return expr(0); +ExprParser::ExprContext* ExprParser::expr() +{ + return expr(0); } -ExprParser::ExprContext* ExprParser::expr(int precedence) { - ParserRuleContext *parentContext = _ctx; - size_t parentState = getState(); - ExprParser::ExprContext *_localctx = _tracker.createInstance(_ctx, parentState); - ExprParser::ExprContext *previousContext = _localctx; - (void)previousContext; // Silence compiler, in case the context is not used by generated code. - size_t startState = 4; - enterRecursionRule(_localctx, 4, ExprParser::RuleExpr, precedence); +ExprParser::ExprContext* ExprParser::expr(int precedence) +{ + ParserRuleContext* parentContext = _ctx; + size_t parentState = getState(); + ExprParser::ExprContext* _localctx = _tracker.createInstance(_ctx, parentState); + ExprParser::ExprContext* previousContext = _localctx; + (void)previousContext; // Silence compiler, in case the context is not used by generated code. + size_t startState = 4; + enterRecursionRule(_localctx, 4, ExprParser::RuleExpr, precedence); size_t _la = 0; #if __cplusplus > 201703L - auto onExit = finally([=, this] { + auto onExit = finally( + [=, this] + { #else - auto onExit = finally([=] { + auto onExit = finally( + [=] + { #endif - unrollRecursionContexts(parentContext); - }); - try { - size_t alt; - enterOuterAlt(_localctx, 1); - setState(69); - _errHandler->sync(this); - switch (getInterpreter()->adaptivePredict(_input, 3, _ctx)) { - case 1: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - - setState(15); - match(ExprParser::T__1); - setState(16); - expr(13); - break; - } - - case 2: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(17); - match(ExprParser::IDENTIFIER); - break; - } - - case 3: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(18); - match(ExprParser::IDENTIFIER); - setState(19); - match(ExprParser::T__4); - setState(20); - match(ExprParser::IDENTIFIER); - break; - } - - case 4: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(21); - match(ExprParser::NUMBER); - break; - } - - case 5: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(22); - match(ExprParser::T__5); - setState(23); - expr(0); - setState(24); - match(ExprParser::T__6); - break; - } - - case 6: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(26); - match(ExprParser::IDENTIFIER); - setState(27); - match(ExprParser::T__5); - setState(28); - expr(0); - setState(29); - match(ExprParser::T__6); - break; - } - - case 7: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(31); - match(ExprParser::IDENTIFIER); - setState(32); - match(ExprParser::LBRACKET); - setState(33); - shift(); - setState(38); - _errHandler->sync(this); - _la = _input->LA(1); - while (_la == ExprParser::T__7) { - setState(34); - match(ExprParser::T__7); - setState(35); - shift(); - setState(40); - _errHandler->sync(this); - _la = _input->LA(1); - } - setState(41); - match(ExprParser::RBRACKET); - break; - } - - case 8: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(43); - match(ExprParser::IDENTIFIER); - setState(44); - match(ExprParser::LBRACKET); - setState(45); - expr(0); - setState(50); - _errHandler->sync(this); - _la = _input->LA(1); - while (_la == ExprParser::T__7) { - setState(46); - match(ExprParser::T__7); - setState(47); - expr(0); - setState(52); + unrollRecursionContexts(parentContext); + }); + try + { + size_t alt; + enterOuterAlt(_localctx, 1); + setState(69); _errHandler->sync(this); - _la = _input->LA(1); - } - setState(53); - match(ExprParser::RBRACKET); - break; - } - - case 9: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(55); - match(ExprParser::IDENTIFIER); - setState(56); - match(ExprParser::LBRACKET); - setState(57); - antlrcpp::downCast(_localctx)->shift1 = shift(); - setState(58); - match(ExprParser::T__8); - setState(59); - antlrcpp::downCast(_localctx)->shift2 = shift(); - setState(60); - match(ExprParser::RBRACKET); - break; - } - - case 10: { - _localctx = _tracker.createInstance(_localctx); - _ctx = _localctx; - previousContext = _localctx; - setState(62); - match(ExprParser::IDENTIFIER); - setState(63); - match(ExprParser::LBRACKET); - setState(64); - expr(0); - setState(65); - match(ExprParser::T__8); - setState(66); - expr(0); - setState(67); - match(ExprParser::RBRACKET); - break; - } + switch (getInterpreter()->adaptivePredict(_input, 3, _ctx)) + { + case 1: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + + setState(15); + match(ExprParser::T__1); + setState(16); + expr(13); + break; + } - default: - break; - } - _ctx->stop = _input->LT(-1); - setState(82); - _errHandler->sync(this); - alt = getInterpreter()->adaptivePredict(_input, 5, _ctx); - while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) { - if (alt == 1) { - if (!_parseListeners.empty()) - triggerExitRuleEvent(); - previousContext = _localctx; - setState(80); - _errHandler->sync(this); - switch (getInterpreter()->adaptivePredict(_input, 4, _ctx)) { - case 1: { - auto newContext = _tracker.createInstance(_tracker.createInstance(parentContext, parentState)); - _localctx = newContext; - pushNewRecursionContext(newContext, startState, RuleExpr); - setState(71); - - if (!(precpred(_ctx, 12))) throw FailedPredicateException(this, "precpred(_ctx, 12)"); - setState(72); - antlrcpp::downCast(_localctx)->op = _input->LT(1); - _la = _input->LA(1); - if (!(_la == ExprParser::T__2 - - || _la == ExprParser::T__3)) { - antlrcpp::downCast(_localctx)->op = _errHandler->recoverInline(this); - } - else { - _errHandler->reportMatch(this); - consume(); - } - setState(73); - expr(13); - break; + case 2: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(17); + match(ExprParser::IDENTIFIER); + break; } - case 2: { - auto newContext = _tracker.createInstance(_tracker.createInstance(parentContext, parentState)); - _localctx = newContext; - pushNewRecursionContext(newContext, startState, RuleExpr); - setState(74); - - if (!(precpred(_ctx, 11))) throw FailedPredicateException(this, "precpred(_ctx, 11)"); - setState(75); - antlrcpp::downCast(_localctx)->op = _input->LT(1); - _la = _input->LA(1); - if (!(_la == ExprParser::T__0 - - || _la == ExprParser::T__1)) { - antlrcpp::downCast(_localctx)->op = _errHandler->recoverInline(this); - } - else { - _errHandler->reportMatch(this); - consume(); - } - setState(76); - expr(12); - break; + case 3: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(18); + match(ExprParser::IDENTIFIER); + setState(19); + match(ExprParser::T__4); + setState(20); + match(ExprParser::IDENTIFIER); + break; } - case 3: { - auto newContext = _tracker.createInstance(_tracker.createInstance(parentContext, parentState)); - _localctx = newContext; - pushNewRecursionContext(newContext, startState, RuleExpr); - setState(77); - - if (!(precpred(_ctx, 10))) throw FailedPredicateException(this, "precpred(_ctx, 10)"); - setState(78); - match(ExprParser::COMPARISON); - setState(79); - expr(11); - break; + case 4: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(21); + match(ExprParser::NUMBER); + break; + } + + case 5: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(22); + match(ExprParser::T__5); + setState(23); + expr(0); + setState(24); + match(ExprParser::T__6); + break; + } + + case 6: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(26); + match(ExprParser::IDENTIFIER); + setState(27); + match(ExprParser::T__5); + setState(28); + expr(0); + setState(29); + match(ExprParser::T__6); + break; + } + + case 7: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(31); + match(ExprParser::IDENTIFIER); + setState(32); + match(ExprParser::LBRACKET); + setState(33); + shift(); + setState(38); + _errHandler->sync(this); + _la = _input->LA(1); + while (_la == ExprParser::T__7) + { + setState(34); + match(ExprParser::T__7); + setState(35); + shift(); + setState(40); + _errHandler->sync(this); + _la = _input->LA(1); + } + setState(41); + match(ExprParser::RBRACKET); + break; + } + + case 8: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(43); + match(ExprParser::IDENTIFIER); + setState(44); + match(ExprParser::LBRACKET); + setState(45); + expr(0); + setState(50); + _errHandler->sync(this); + _la = _input->LA(1); + while (_la == ExprParser::T__7) + { + setState(46); + match(ExprParser::T__7); + setState(47); + expr(0); + setState(52); + _errHandler->sync(this); + _la = _input->LA(1); + } + setState(53); + match(ExprParser::RBRACKET); + break; + } + + case 9: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(55); + match(ExprParser::IDENTIFIER); + setState(56); + match(ExprParser::LBRACKET); + setState(57); + antlrcpp::downCast(_localctx)->shift1 = shift(); + setState(58); + match(ExprParser::T__8); + setState(59); + antlrcpp::downCast(_localctx)->shift2 = shift(); + setState(60); + match(ExprParser::RBRACKET); + break; + } + + case 10: + { + _localctx = _tracker.createInstance(_localctx); + _ctx = _localctx; + previousContext = _localctx; + setState(62); + match(ExprParser::IDENTIFIER); + setState(63); + match(ExprParser::LBRACKET); + setState(64); + expr(0); + setState(65); + match(ExprParser::T__8); + setState(66); + expr(0); + setState(67); + match(ExprParser::RBRACKET); + break; } default: - break; - } - } - setState(84); - _errHandler->sync(this); - alt = getInterpreter()->adaptivePredict(_input, 5, _ctx); + break; + } + _ctx->stop = _input->LT(-1); + setState(82); + _errHandler->sync(this); + alt = getInterpreter()->adaptivePredict(_input, 5, _ctx); + while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) + { + if (alt == 1) + { + if (!_parseListeners.empty()) + { + triggerExitRuleEvent(); + } + previousContext = _localctx; + setState(80); + _errHandler->sync(this); + switch (getInterpreter()->adaptivePredict(_input, 4, _ctx)) + { + case 1: + { + auto newContext = _tracker.createInstance( + _tracker.createInstance(parentContext, parentState)); + _localctx = newContext; + pushNewRecursionContext(newContext, startState, RuleExpr); + setState(71); + + if (!(precpred(_ctx, 12))) + { + throw FailedPredicateException(this, "precpred(_ctx, 12)"); + } + setState(72); + antlrcpp::downCast(_localctx)->op = _input->LT(1); + _la = _input->LA(1); + if (!(_la == ExprParser::T__2 + + || _la == ExprParser::T__3)) + { + antlrcpp::downCast(_localctx)->op = _errHandler + ->recoverInline(this); + } + else + { + _errHandler->reportMatch(this); + consume(); + } + setState(73); + expr(13); + break; + } + + case 2: + { + auto newContext = _tracker.createInstance( + _tracker.createInstance(parentContext, parentState)); + _localctx = newContext; + pushNewRecursionContext(newContext, startState, RuleExpr); + setState(74); + + if (!(precpred(_ctx, 11))) + { + throw FailedPredicateException(this, "precpred(_ctx, 11)"); + } + setState(75); + antlrcpp::downCast(_localctx)->op = _input->LT(1); + _la = _input->LA(1); + if (!(_la == ExprParser::T__0 + + || _la == ExprParser::T__1)) + { + antlrcpp::downCast(_localctx)->op = _errHandler + ->recoverInline(this); + } + else + { + _errHandler->reportMatch(this); + consume(); + } + setState(76); + expr(12); + break; + } + + case 3: + { + auto newContext = _tracker.createInstance( + _tracker.createInstance(parentContext, parentState)); + _localctx = newContext; + pushNewRecursionContext(newContext, startState, RuleExpr); + setState(77); + + if (!(precpred(_ctx, 10))) + { + throw FailedPredicateException(this, "precpred(_ctx, 10)"); + } + setState(78); + match(ExprParser::COMPARISON); + setState(79); + expr(11); + break; + } + + default: + break; + } + } + setState(84); + _errHandler->sync(this); + alt = getInterpreter()->adaptivePredict(_input, 5, _ctx); + } + } + catch (RecognitionException& e) + { + _errHandler->reportError(this, e); + _localctx->exception = std::current_exception(); + _errHandler->recover(this, _localctx->exception); } - } - catch (RecognitionException &e) { - _errHandler->reportError(this, e); - _localctx->exception = std::current_exception(); - _errHandler->recover(this, _localctx->exception); - } - return _localctx; + return _localctx; } -bool ExprParser::sempred(RuleContext *context, size_t ruleIndex, size_t predicateIndex) { - switch (ruleIndex) { - case 2: return exprSempred(antlrcpp::downCast(context), predicateIndex); +bool ExprParser::sempred(RuleContext* context, size_t ruleIndex, size_t predicateIndex) +{ + switch (ruleIndex) + { + case 2: + return exprSempred(antlrcpp::downCast(context), predicateIndex); - default: - break; - } - return true; + default: + break; + } + return true; } -bool ExprParser::exprSempred(ExprContext *_localctx, size_t predicateIndex) { - switch (predicateIndex) { - case 0: return precpred(_ctx, 12); - case 1: return precpred(_ctx, 11); - case 2: return precpred(_ctx, 10); +bool ExprParser::exprSempred(ExprContext* _localctx, size_t predicateIndex) +{ + switch (predicateIndex) + { + case 0: + return precpred(_ctx, 12); + case 1: + return precpred(_ctx, 11); + case 2: + return precpred(_ctx, 10); - default: - break; - } - return true; + default: + break; + } + return true; } -void ExprParser::initialize() { +void ExprParser::initialize() +{ #if ANTLR4_USE_THREAD_LOCAL_CACHE - exprParserInitialize(); + exprParserInitialize(); #else - ::antlr4::internal::call_once(exprParserOnceFlag, exprParserInitialize); + ::antlr4::internal::call_once(exprParserOnceFlag, exprParserInitialize); #endif } diff --git a/src/libs/antares/antlr-interface/ExprParser.h b/src/libs/antares/antlr-interface/ExprParser.h index aa1c8b6f09..6573ea2b2d 100644 --- a/src/libs/antares/antlr-interface/ExprParser.h +++ b/src/libs/antares/antlr-interface/ExprParser.h @@ -3,242 +3,266 @@ #pragma once - #include "antlr4-runtime.h" - - - -class ExprParser : public antlr4::Parser { +class ExprParser: public antlr4::Parser +{ public: - enum { - T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7, - T__7 = 8, T__8 = 9, NUMBER = 10, TIME = 11, IDENTIFIER = 12, COMPARISON = 13, - ADDSUB = 14, MULDIV = 15, LBRACKET = 16, RBRACKET = 17, WS = 18 - }; - - enum { - RuleFullexpr = 0, RuleShift = 1, RuleExpr = 2 - }; - - explicit ExprParser(antlr4::TokenStream *input); - - ExprParser(antlr4::TokenStream *input, const antlr4::atn::ParserATNSimulatorOptions &options); - - ~ExprParser() override; - - std::string getGrammarFileName() const override; - - const antlr4::atn::ATN& getATN() const override; - - const std::vector& getRuleNames() const override; + enum + { + T__0 = 1, + T__1 = 2, + T__2 = 3, + T__3 = 4, + T__4 = 5, + T__5 = 6, + T__6 = 7, + T__7 = 8, + T__8 = 9, + NUMBER = 10, + TIME = 11, + IDENTIFIER = 12, + COMPARISON = 13, + ADDSUB = 14, + MULDIV = 15, + LBRACKET = 16, + RBRACKET = 17, + WS = 18 + }; + + enum + { + RuleFullexpr = 0, + RuleShift = 1, + RuleExpr = 2 + }; + + explicit ExprParser(antlr4::TokenStream* input); - const antlr4::dfa::Vocabulary& getVocabulary() const override; + ExprParser(antlr4::TokenStream* input, const antlr4::atn::ParserATNSimulatorOptions& options); + + ~ExprParser() override; - antlr4::atn::SerializedATNView getSerializedATN() const override; + std::string getGrammarFileName() const override; + + const antlr4::atn::ATN& getATN() const override; + const std::vector& getRuleNames() const override; + + const antlr4::dfa::Vocabulary& getVocabulary() const override; - class FullexprContext; - class ShiftContext; - class ExprContext; + antlr4::atn::SerializedATNView getSerializedATN() const override; + + class FullexprContext; + class ShiftContext; + class ExprContext; + + class FullexprContext: public antlr4::ParserRuleContext + { + public: + FullexprContext(antlr4::ParserRuleContext* parent, size_t invokingState); + virtual size_t getRuleIndex() const override; + ExprContext* expr(); + antlr4::tree::TerminalNode* EOF(); + + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; + + FullexprContext* fullexpr(); - class FullexprContext : public antlr4::ParserRuleContext { - public: - FullexprContext(antlr4::ParserRuleContext *parent, size_t invokingState); - virtual size_t getRuleIndex() const override; - ExprContext *expr(); - antlr4::tree::TerminalNode *EOF(); + class ShiftContext: public antlr4::ParserRuleContext + { + public: + antlr4::Token* op = nullptr; + ShiftContext(antlr4::ParserRuleContext* parent, size_t invokingState); + virtual size_t getRuleIndex() const override; + antlr4::tree::TerminalNode* TIME(); + ExprContext* expr(); + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - - }; + ShiftContext* shift(); - FullexprContext* fullexpr(); + class ExprContext: public antlr4::ParserRuleContext + { + public: + ExprContext(antlr4::ParserRuleContext* parent, size_t invokingState); - class ShiftContext : public antlr4::ParserRuleContext { - public: - antlr4::Token *op = nullptr; - ShiftContext(antlr4::ParserRuleContext *parent, size_t invokingState); - virtual size_t getRuleIndex() const override; - antlr4::tree::TerminalNode *TIME(); - ExprContext *expr(); + ExprContext() = default; + void copyFrom(ExprContext* context); + using antlr4::ParserRuleContext::copyFrom; + + virtual size_t getRuleIndex() const override; + }; + + class IdentifierContext: public ExprContext + { + public: + IdentifierContext(ExprContext* ctx); + + antlr4::tree::TerminalNode* IDENTIFIER(); + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; + + class NegationContext: public ExprContext + { + public: + NegationContext(ExprContext* ctx); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - - }; + ExprContext* expr(); - ShiftContext* shift(); + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class ExprContext : public antlr4::ParserRuleContext { - public: - ExprContext(antlr4::ParserRuleContext *parent, size_t invokingState); - - ExprContext() = default; - void copyFrom(ExprContext *context); - using antlr4::ParserRuleContext::copyFrom; + class ExpressionContext: public ExprContext + { + public: + ExpressionContext(ExprContext* ctx); - virtual size_t getRuleIndex() const override; + ExprContext* expr(); - - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class IdentifierContext : public ExprContext { - public: - IdentifierContext(ExprContext *ctx); + class ComparisonContext: public ExprContext + { + public: + ComparisonContext(ExprContext* ctx); - antlr4::tree::TerminalNode *IDENTIFIER(); + std::vector expr(); + ExprContext* expr(size_t i); + antlr4::tree::TerminalNode* COMPARISON(); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class NegationContext : public ExprContext { - public: - NegationContext(ExprContext *ctx); + class AddsubContext: public ExprContext + { + public: + AddsubContext(ExprContext* ctx); - ExprContext *expr(); + antlr4::Token* op = nullptr; + std::vector expr(); + ExprContext* expr(size_t i); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class ExpressionContext : public ExprContext { - public: - ExpressionContext(ExprContext *ctx); + class PortFieldContext: public ExprContext + { + public: + PortFieldContext(ExprContext* ctx); - ExprContext *expr(); + std::vector IDENTIFIER(); + antlr4::tree::TerminalNode* IDENTIFIER(size_t i); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class ComparisonContext : public ExprContext { - public: - ComparisonContext(ExprContext *ctx); + class MuldivContext: public ExprContext + { + public: + MuldivContext(ExprContext* ctx); - std::vector expr(); - ExprContext* expr(size_t i); - antlr4::tree::TerminalNode *COMPARISON(); + antlr4::Token* op = nullptr; + std::vector expr(); + ExprContext* expr(size_t i); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class AddsubContext : public ExprContext { - public: - AddsubContext(ExprContext *ctx); + class NumberContext: public ExprContext + { + public: + NumberContext(ExprContext* ctx); - antlr4::Token *op = nullptr; - std::vector expr(); - ExprContext* expr(size_t i); + antlr4::tree::TerminalNode* NUMBER(); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class PortFieldContext : public ExprContext { - public: - PortFieldContext(ExprContext *ctx); + class TimeIndexContext: public ExprContext + { + public: + TimeIndexContext(ExprContext* ctx); - std::vector IDENTIFIER(); - antlr4::tree::TerminalNode* IDENTIFIER(size_t i); + antlr4::tree::TerminalNode* IDENTIFIER(); + antlr4::tree::TerminalNode* LBRACKET(); + std::vector expr(); + ExprContext* expr(size_t i); + antlr4::tree::TerminalNode* RBRACKET(); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class MuldivContext : public ExprContext { - public: - MuldivContext(ExprContext *ctx); + class TimeShiftContext: public ExprContext + { + public: + TimeShiftContext(ExprContext* ctx); - antlr4::Token *op = nullptr; - std::vector expr(); - ExprContext* expr(size_t i); + antlr4::tree::TerminalNode* IDENTIFIER(); + antlr4::tree::TerminalNode* LBRACKET(); + std::vector shift(); + ShiftContext* shift(size_t i); + antlr4::tree::TerminalNode* RBRACKET(); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class NumberContext : public ExprContext { - public: - NumberContext(ExprContext *ctx); + class FunctionContext: public ExprContext + { + public: + FunctionContext(ExprContext* ctx); - antlr4::tree::TerminalNode *NUMBER(); + antlr4::tree::TerminalNode* IDENTIFIER(); + ExprContext* expr(); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class TimeIndexContext : public ExprContext { - public: - TimeIndexContext(ExprContext *ctx); + class TimeShiftRangeContext: public ExprContext + { + public: + TimeShiftRangeContext(ExprContext* ctx); - antlr4::tree::TerminalNode *IDENTIFIER(); - antlr4::tree::TerminalNode *LBRACKET(); - std::vector expr(); - ExprContext* expr(size_t i); - antlr4::tree::TerminalNode *RBRACKET(); + ExprParser::ShiftContext* shift1 = nullptr; + ExprParser::ShiftContext* shift2 = nullptr; + antlr4::tree::TerminalNode* IDENTIFIER(); + antlr4::tree::TerminalNode* LBRACKET(); + antlr4::tree::TerminalNode* RBRACKET(); + std::vector shift(); + ShiftContext* shift(size_t i); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class TimeShiftContext : public ExprContext { - public: - TimeShiftContext(ExprContext *ctx); + class TimeRangeContext: public ExprContext + { + public: + TimeRangeContext(ExprContext* ctx); - antlr4::tree::TerminalNode *IDENTIFIER(); - antlr4::tree::TerminalNode *LBRACKET(); - std::vector shift(); - ShiftContext* shift(size_t i); - antlr4::tree::TerminalNode *RBRACKET(); + antlr4::tree::TerminalNode* IDENTIFIER(); + antlr4::tree::TerminalNode* LBRACKET(); + std::vector expr(); + ExprContext* expr(size_t i); + antlr4::tree::TerminalNode* RBRACKET(); - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + virtual std::any accept(antlr4::tree::ParseTreeVisitor* visitor) override; + }; - class FunctionContext : public ExprContext { - public: - FunctionContext(ExprContext *ctx); + ExprContext* expr(); + ExprContext* expr(int precedence); - antlr4::tree::TerminalNode *IDENTIFIER(); - ExprContext *expr(); + bool sempred(antlr4::RuleContext* _localctx, size_t ruleIndex, size_t predicateIndex) override; - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; + bool exprSempred(ExprContext* _localctx, size_t predicateIndex); - class TimeShiftRangeContext : public ExprContext { - public: - TimeShiftRangeContext(ExprContext *ctx); - - ExprParser::ShiftContext *shift1 = nullptr; - ExprParser::ShiftContext *shift2 = nullptr; - antlr4::tree::TerminalNode *IDENTIFIER(); - antlr4::tree::TerminalNode *LBRACKET(); - antlr4::tree::TerminalNode *RBRACKET(); - std::vector shift(); - ShiftContext* shift(size_t i); - - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; - - class TimeRangeContext : public ExprContext { - public: - TimeRangeContext(ExprContext *ctx); - - antlr4::tree::TerminalNode *IDENTIFIER(); - antlr4::tree::TerminalNode *LBRACKET(); - std::vector expr(); - ExprContext* expr(size_t i); - antlr4::tree::TerminalNode *RBRACKET(); - - virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override; - }; - - ExprContext* expr(); - ExprContext* expr(int precedence); - - bool sempred(antlr4::RuleContext *_localctx, size_t ruleIndex, size_t predicateIndex) override; - - bool exprSempred(ExprContext *_localctx, size_t predicateIndex); - - // By default the static state used to implement the parser is lazily initialized during the first - // call to the constructor. You can call this function if you wish to initialize the static state - // ahead of time. - static void initialize(); + // By default the static state used to implement the parser is lazily initialized during the + // first call to the constructor. You can call this function if you wish to initialize the + // static state ahead of time. + static void initialize(); private: }; - diff --git a/src/libs/antares/antlr-interface/ExprVisitor.cpp b/src/libs/antares/antlr-interface/ExprVisitor.cpp index c214f0f76f..bf0de76765 100644 --- a/src/libs/antares/antlr-interface/ExprVisitor.cpp +++ b/src/libs/antares/antlr-interface/ExprVisitor.cpp @@ -1,7 +1,4 @@ // Generated from Expr.g4 by ANTLR 4.13.1 - #include "ExprVisitor.h" - - diff --git a/src/libs/antares/antlr-interface/ExprVisitor.h b/src/libs/antares/antlr-interface/ExprVisitor.h index c064d6d54a..6caed416f5 100644 --- a/src/libs/antares/antlr-interface/ExprVisitor.h +++ b/src/libs/antares/antlr-interface/ExprVisitor.h @@ -3,52 +3,46 @@ #pragma once - -#include "antlr4-runtime.h" #include "ExprParser.h" - - +#include "antlr4-runtime.h" /** * This class defines an abstract visitor for a parse tree * produced by ExprParser. */ -class ExprVisitor : public antlr4::tree::AbstractParseTreeVisitor { +class ExprVisitor: public antlr4::tree::AbstractParseTreeVisitor +{ public: + /** + * Visit parse trees produced by ExprParser. + */ + virtual std::any visitFullexpr(ExprParser::FullexprContext* context) = 0; - /** - * Visit parse trees produced by ExprParser. - */ - virtual std::any visitFullexpr(ExprParser::FullexprContext *context) = 0; + virtual std::any visitShift(ExprParser::ShiftContext* context) = 0; - virtual std::any visitShift(ExprParser::ShiftContext *context) = 0; + virtual std::any visitIdentifier(ExprParser::IdentifierContext* context) = 0; - virtual std::any visitIdentifier(ExprParser::IdentifierContext *context) = 0; + virtual std::any visitNegation(ExprParser::NegationContext* context) = 0; - virtual std::any visitNegation(ExprParser::NegationContext *context) = 0; + virtual std::any visitExpression(ExprParser::ExpressionContext* context) = 0; - virtual std::any visitExpression(ExprParser::ExpressionContext *context) = 0; + virtual std::any visitComparison(ExprParser::ComparisonContext* context) = 0; - virtual std::any visitComparison(ExprParser::ComparisonContext *context) = 0; + virtual std::any visitAddsub(ExprParser::AddsubContext* context) = 0; - virtual std::any visitAddsub(ExprParser::AddsubContext *context) = 0; + virtual std::any visitPortField(ExprParser::PortFieldContext* context) = 0; - virtual std::any visitPortField(ExprParser::PortFieldContext *context) = 0; + virtual std::any visitMuldiv(ExprParser::MuldivContext* context) = 0; - virtual std::any visitMuldiv(ExprParser::MuldivContext *context) = 0; + virtual std::any visitNumber(ExprParser::NumberContext* context) = 0; - virtual std::any visitNumber(ExprParser::NumberContext *context) = 0; + virtual std::any visitTimeIndex(ExprParser::TimeIndexContext* context) = 0; - virtual std::any visitTimeIndex(ExprParser::TimeIndexContext *context) = 0; + virtual std::any visitTimeShift(ExprParser::TimeShiftContext* context) = 0; - virtual std::any visitTimeShift(ExprParser::TimeShiftContext *context) = 0; - - virtual std::any visitFunction(ExprParser::FunctionContext *context) = 0; - - virtual std::any visitTimeShiftRange(ExprParser::TimeShiftRangeContext *context) = 0; - - virtual std::any visitTimeRange(ExprParser::TimeRangeContext *context) = 0; + virtual std::any visitFunction(ExprParser::FunctionContext* context) = 0; + virtual std::any visitTimeShiftRange(ExprParser::TimeShiftRangeContext* context) = 0; + virtual std::any visitTimeRange(ExprParser::TimeRangeContext* context) = 0; }; - diff --git a/src/libs/antares/checks/include/antares/checks/checkLoadedInputData.h b/src/libs/antares/checks/include/antares/checks/checkLoadedInputData.h index 113451410f..62352390bc 100644 --- a/src/libs/antares/checks/include/antares/checks/checkLoadedInputData.h +++ b/src/libs/antares/checks/include/antares/checks/checkLoadedInputData.h @@ -28,7 +28,6 @@ void checkOrtoolsUsage(Antares::Data::UnitCommitmentMode ucMode, bool ortoolsUsed, const std::string& solverName); - void checkStudyVersion(const AnyString& optStudyFolder); void checkSimplexRangeHydroPricing(Antares::Data::SimplexOptimization optRange, diff --git a/src/libs/antares/exception/include/antares/exception/LoadingError.hpp b/src/libs/antares/exception/include/antares/exception/LoadingError.hpp index ab1ae664d8..c79b1a791e 100644 --- a/src/libs/antares/exception/include/antares/exception/LoadingError.hpp +++ b/src/libs/antares/exception/include/antares/exception/LoadingError.hpp @@ -130,13 +130,14 @@ class InvalidSolver: public LoadingError explicit InvalidSolver(const std::string& solver, const std::string& availableSolverList); }; -class InvalidSolverSpecificParameters : public LoadingError +class InvalidSolverSpecificParameters: public LoadingError { public: - explicit InvalidSolverSpecificParameters(const std::string& solver, const std::string& specificParameters); + explicit InvalidSolverSpecificParameters(const std::string& solver, + const std::string& specificParameters); }; -class InvalidStudy : public LoadingError +class InvalidStudy: public LoadingError { public: explicit InvalidStudy(const Yuni::String& study); diff --git a/src/libs/antares/file-tree-study-loader/include/antares/file-tree-study-loader/FileTreeStudyLoader.h b/src/libs/antares/file-tree-study-loader/include/antares/file-tree-study-loader/FileTreeStudyLoader.h index 687afa12ae..7b46a95c3a 100644 --- a/src/libs/antares/file-tree-study-loader/include/antares/file-tree-study-loader/FileTreeStudyLoader.h +++ b/src/libs/antares/file-tree-study-loader/include/antares/file-tree-study-loader/FileTreeStudyLoader.h @@ -31,6 +31,7 @@ namespace Data { class Study; } + /** * @class FileTreeStudyLoader * @brief A class to load studies from the file tree. diff --git a/src/libs/antares/inifile/include/antares/inifile/inifile.hxx b/src/libs/antares/inifile/include/antares/inifile/inifile.hxx index 64785d1ece..20498c3ee2 100644 --- a/src/libs/antares/inifile/include/antares/inifile/inifile.hxx +++ b/src/libs/antares/inifile/include/antares/inifile/inifile.hxx @@ -32,7 +32,8 @@ inline bool IniFile::empty() const return not firstSection; } -inline IniFile::Section::Section(const AnyString& name): name(name) +inline IniFile::Section::Section(const AnyString& name): + name(name) { } diff --git a/src/libs/antares/inifile/inifile.cpp b/src/libs/antares/inifile/inifile.cpp index 67190a0654..8cfa6b9607 100644 --- a/src/libs/antares/inifile/inifile.cpp +++ b/src/libs/antares/inifile/inifile.cpp @@ -65,9 +65,8 @@ void IniFile::Section::saveToStream(std::ostream& stream_out, uint64_t& written) stream_out << '[' << name << "]\n"; written += 4 /* []\n\n */ + name.size(); - each([&stream_out, &written](const IniFile::Property& p) { - p.saveToStream(stream_out, written); - }); + each([&stream_out, &written](const IniFile::Property& p) + { p.saveToStream(stream_out, written); }); stream_out << '\n'; } @@ -249,7 +248,7 @@ bool IniFile::open(const fs::path& filename, bool warnings) if (std::ifstream file(filename); file.is_open()) { - if (! readStream(file)) + if (!readStream(file)) { logs.error() << "Invalid INI file : " << filename; return false; @@ -266,9 +265,8 @@ bool IniFile::open(const fs::path& filename, bool warnings) void IniFile::saveToStream(std::ostream& stream_out, uint64_t& written) const { - each([&stream_out, &written](const IniFile::Section& s) { - s.saveToStream(stream_out, written); - }); + each([&stream_out, &written](const IniFile::Section& s) + { s.saveToStream(stream_out, written); }); if (written != 0) { diff --git a/src/libs/antares/io/file.cpp b/src/libs/antares/io/file.cpp index 10bf5b30b9..8ef66b3a3d 100644 --- a/src/libs/antares/io/file.cpp +++ b/src/libs/antares/io/file.cpp @@ -27,13 +27,13 @@ #ifdef YUNI_OS_WINDOWS #include + #include #else #include #include #endif #include - #include #include diff --git a/src/libs/antares/io/include/antares/io/file.h b/src/libs/antares/io/include/antares/io/file.h index e9fd0e91dc..b401b1cece 100644 --- a/src/libs/antares/io/include/antares/io/file.h +++ b/src/libs/antares/io/include/antares/io/file.h @@ -21,10 +21,10 @@ #ifndef __LIBS_ANTARES_IO_FILE_H__ #define __LIBS_ANTARES_IO_FILE_H__ -#include - #include +#include + namespace Antares::IO { /*! diff --git a/src/libs/antares/study-loader/include/antares/study-loader/IStudyLoader.h b/src/libs/antares/study-loader/include/antares/study-loader/IStudyLoader.h index 9b4c710ed4..7d6f25373b 100644 --- a/src/libs/antares/study-loader/include/antares/study-loader/IStudyLoader.h +++ b/src/libs/antares/study-loader/include/antares/study-loader/IStudyLoader.h @@ -29,6 +29,7 @@ namespace Data { class Study; } + /** * @class IStudyLoader * @brief The IStudyLoader class is an interface for loading studies. diff --git a/src/libs/antares/study/area/area.cpp b/src/libs/antares/study/area/area.cpp index da99f973ae..fe2b2b7b75 100644 --- a/src/libs/antares/study/area/area.cpp +++ b/src/libs/antares/study/area/area.cpp @@ -52,19 +52,20 @@ Area::Area(): internalInitialize(); } -Area::Area(const AnyString& name) : Area() +Area::Area(const AnyString& name): + Area() { internalInitialize(); this->name = name; this->id = Antares::transformNameIntoID(this->name); } -Area::Area(const AnyString& name, const AnyString& id) : Area() +Area::Area(const AnyString& name, const AnyString& id): + Area() { internalInitialize(); this->name = name; this->id = Antares::transformNameIntoID(id); - } Area::~Area() diff --git a/src/libs/antares/study/area/links.cpp b/src/libs/antares/study/area/links.cpp index 40da9df149..3523643328 100644 --- a/src/libs/antares/study/area/links.cpp +++ b/src/libs/antares/study/area/links.cpp @@ -142,8 +142,8 @@ bool AreaLink::linkLoadTimeSeries_for_version_820_and_later(const AnyString& fol bool AreaLink::loadTSGenTimeSeries(const fs::path& folder) { const std::string idprepro = std::string(from->id) + "/" + std::string(with->id); - tsGeneration.prepro = - std::make_unique(idprepro, tsGeneration.unitCount); + tsGeneration.prepro = std::make_unique(idprepro, + tsGeneration.unitCount); bool anyFileWasLoaded = false; @@ -157,10 +157,10 @@ bool AreaLink::loadTSGenTimeSeries(const fs::path& folder) { anyFileWasLoaded = true; tsGeneration.valid = tsGeneration.prepro->data.loadFromCSVFile( - filepath.string(), - Antares::Data::PreproAvailability::preproAvailabilityMax, - DAYS_PER_YEAR) - && tsGeneration.prepro->validate(); + filepath.string(), + Antares::Data::PreproAvailability::preproAvailabilityMax, + DAYS_PER_YEAR) + && tsGeneration.prepro->validate(); } // Modulation @@ -170,7 +170,7 @@ bool AreaLink::loadTSGenTimeSeries(const fs::path& folder) { anyFileWasLoaded = true; tsGeneration.valid &= tsGeneration.modulationCapacityDirect - .loadFromCSVFile(filepath.string(), 1, HOURS_PER_YEAR); + .loadFromCSVFile(filepath.string(), 1, HOURS_PER_YEAR); } filepath = preproFile; @@ -179,7 +179,7 @@ bool AreaLink::loadTSGenTimeSeries(const fs::path& folder) { anyFileWasLoaded = true; tsGeneration.valid &= tsGeneration.modulationCapacityIndirect - .loadFromCSVFile(filepath.string(), 1, HOURS_PER_YEAR); + .loadFromCSVFile(filepath.string(), 1, HOURS_PER_YEAR); } if (anyFileWasLoaded) @@ -506,11 +506,8 @@ bool handleKey(Data::AreaLink& link, const String& key, const String& value) return false; } -bool handleTSGenKey(Data::LinkTsGeneration& out, - const std::string& key, - const String& value) +bool handleTSGenKey(Data::LinkTsGeneration& out, const std::string& key, const String& value) { - if (key == "unitcount") { return value.to(out.unitCount); @@ -572,7 +569,11 @@ bool AreaLinksInternalLoadFromProperty(AreaLink& link, const String& key, const } } // anonymous namespace -bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const fs::path& folder, bool loadTSGen) +bool AreaLinksLoadFromFolder(Study& study, + AreaList* l, + Area* area, + const fs::path& folder, + bool loadTSGen) { // Assert assert(area); diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index f76afb5686..181159933b 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -968,8 +968,9 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, ret = hydroSeries->LoadMaxPower(area.id, buffer) && ret; } - hydroSeries->resizeTSinDeratedMode( - study.parameters.derated, studyVersion, study.usedByTheSolver); + hydroSeries->resizeTSinDeratedMode(study.parameters.derated, + studyVersion, + study.usedByTheSolver); } // Wind @@ -1278,7 +1279,7 @@ Area* AreaList::findFromPosition(const int x, const int y) const { auto lastArea = i->second; if (lastArea->ui && std::abs(lastArea->ui->x - x) < nearestDistance - && std::abs(lastArea->ui->y - y) < nearestDistance) + && std::abs(lastArea->ui->y - y) < nearestDistance) { nearestItem = lastArea; } @@ -1326,12 +1327,14 @@ void AreaListEnsureDataLoadPrepro(AreaList* l) /* Asserts */ assert(l); - l->each([](Data::Area& area) { - if (!area.load.prepro) - { - area.load.prepro = new Antares::Data::Load::Prepro(); - } - }); + l->each( + [](Data::Area& area) + { + if (!area.load.prepro) + { + area.load.prepro = new Antares::Data::Load::Prepro(); + } + }); } void AreaListEnsureDataSolarPrepro(AreaList* l) diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp index ff181e7ed8..b29ad4fba2 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp @@ -60,7 +60,9 @@ bool BindingConstraintGroupRepository::buildFrom(const BindingConstraintsReposit bool BindingConstraintGroupRepository::timeSeriesWidthConsistentInGroups() const { - bool allConsistent = !std::ranges::any_of(groups_, [](const auto& group) + bool allConsistent = !std::ranges::any_of( + groups_, + [](const auto& group) { const auto& constraints = group->constraints(); if (constraints.empty()) @@ -68,7 +70,8 @@ bool BindingConstraintGroupRepository::timeSeriesWidthConsistentInGroups() const return false; } auto width = (*constraints.begin())->RHSTimeSeries().width; - bool isConsistent = std::ranges::all_of(constraints, + bool isConsistent = std::ranges::all_of( + constraints, [&width](const std::shared_ptr& bc) { bool sameWidth = bc->RHSTimeSeries().width == width; @@ -89,15 +92,16 @@ bool BindingConstraintGroupRepository::timeSeriesWidthConsistentInGroups() const void BindingConstraintGroupRepository::resizeAllTimeseriesNumbers(unsigned int nb_years) { - std::ranges::for_each(groups_, [&nb_years](auto& group) - { group->timeseriesNumbers.reset(nb_years); }); + std::ranges::for_each(groups_, + [&nb_years](auto& group) { group->timeseriesNumbers.reset(nb_years); }); } BindingConstraintGroup* BindingConstraintGroupRepository::operator[](const std::string& name) const { - if (auto group = std::ranges::find_if(groups_, [&name](auto& group_of_constraint) - { return group_of_constraint->name() == name; }); - group != groups_.end()) + if (auto group = std::ranges::find_if(groups_, + [&name](auto& group_of_constraint) + { return group_of_constraint->name() == name; }); + group != groups_.end()) { return group->get(); } diff --git a/src/libs/antares/study/cleaner/cleaner-v20.cpp b/src/libs/antares/study/cleaner/cleaner-v20.cpp index 7d1aadf58e..3fa46cf4b5 100644 --- a/src/libs/antares/study/cleaner/cleaner-v20.cpp +++ b/src/libs/antares/study/cleaner/cleaner-v20.cpp @@ -391,7 +391,6 @@ bool listOfFilesAnDirectoriesToKeep(StudyCleaningInfos* infos) buffer.clear() << infos->folder << "/input/bindingconstraints/bindingconstraints.ini"; if (ini.open(buffer)) { - ini.each( [&e](const IniFile::Section& section) { diff --git a/src/libs/antares/study/include/antares/study/parameters.h b/src/libs/antares/study/include/antares/study/parameters.h index 791e20f865..1eacc026bb 100644 --- a/src/libs/antares/study/include/antares/study/parameters.h +++ b/src/libs/antares/study/include/antares/study/parameters.h @@ -504,8 +504,7 @@ class Parameters final private: //! Load data from an INI file - bool loadFromINI(const IniFile& ini, - const StudyVersion& version); + bool loadFromINI(const IniFile& ini, const StudyVersion& version); void resetPlayedYears(uint nbOfYears); diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/container.h b/src/libs/antares/study/include/antares/study/parts/hydro/container.h index e09970b79c..9d80ce4369 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/container.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/container.h @@ -22,6 +22,7 @@ #define __ANTARES_LIBS_STUDY_PARTS_HYDRO_CONTAINER_H__ #include + #include "../../fwd.h" #include "allocation.h" #include "prepro.h" @@ -178,9 +179,7 @@ class PartHydro // As this function can be called a lot of times, we pass working variables and returned variables // as arguments, so that we don't have to create them locally (as in a classical function) each // time. -double getWaterValue(const double& level, - const Matrix& waterValues, - const uint day); +double getWaterValue(const double& level, const Matrix& waterValues, const uint day); // Interpolates a rate from the credit modulation table according to a level double getWeeklyModulation(const double& level /* format : in % of reservoir capacity */, diff --git a/src/libs/antares/study/include/antares/study/scenario-builder/hydroLevelsData.h b/src/libs/antares/study/include/antares/study/scenario-builder/hydroLevelsData.h index 42aff6336a..b5cb21073d 100644 --- a/src/libs/antares/study/include/antares/study/scenario-builder/hydroLevelsData.h +++ b/src/libs/antares/study/include/antares/study/scenario-builder/hydroLevelsData.h @@ -21,9 +21,10 @@ #ifndef __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__ #define __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__ -#include "scBuilderDataInterface.h" #include +#include "scBuilderDataInterface.h" + namespace Antares { namespace Data diff --git a/src/libs/antares/study/include/antares/study/sets.hxx b/src/libs/antares/study/include/antares/study/sets.hxx index d2976252cc..df1f9cff93 100644 --- a/src/libs/antares/study/include/antares/study/sets.hxx +++ b/src/libs/antares/study/include/antares/study/sets.hxx @@ -288,8 +288,8 @@ bool Sets::loadFromFile(const std::filesystem::path& filename) continue; } - logs.warning() << "sets: `" << filename << "`: Invalid property `" - << p->key << '\''; + logs.warning() << "sets: `" << filename << "`: Invalid property `" << p->key + << '\''; } // Add the new group diff --git a/src/libs/antares/study/parameters.cpp b/src/libs/antares/study/parameters.cpp index 7337b9c8b0..2f4c0b30b1 100644 --- a/src/libs/antares/study/parameters.cpp +++ b/src/libs/antares/study/parameters.cpp @@ -1109,10 +1109,16 @@ static bool SGDIntLoadFamily_Legacy(Parameters& d, if (key == "initial-reservoir-levels") // ignored since 9.2 { - if (version >= StudyVersion(9,2)) - logs.warning() << "Option initial-reservoir-levels is deprecated, please remove it from the study"; + if (version >= StudyVersion(9, 2)) + { + logs.warning() + << "Option initial-reservoir-levels is deprecated, please remove it from the study"; + } else if (value == "hot start") - logs.warning() << "Hydro hot start not supported with this solver, please use a version < 9.2"; + { + logs.warning() + << "Hydro hot start not supported with this solver, please use a version < 9.2"; + } return true; } @@ -1125,8 +1131,7 @@ bool firstKeyLetterIsValid(const String& name) return (firstLetter >= 'a' && firstLetter <= 'z'); } -bool Parameters::loadFromINI(const IniFile& ini, - const StudyVersion& version) +bool Parameters::loadFromINI(const IniFile& ini, const StudyVersion& version) { // Reset inner data reset(); @@ -1292,7 +1297,9 @@ void Parameters::fixBadValues() } if (simulationDays.first == 0) + { simulationDays.first = 1; + } else { simulationDays.first = std::clamp(simulationDays.first, 1u, 365u); diff --git a/src/libs/antares/study/parts/common/cluster_list.cpp b/src/libs/antares/study/parts/common/cluster_list.cpp index 9be5c2ca57..9c39ca7c8b 100644 --- a/src/libs/antares/study/parts/common/cluster_list.cpp +++ b/src/libs/antares/study/parts/common/cluster_list.cpp @@ -263,8 +263,9 @@ bool ClusterList::saveDataSeriesToFolder(const AnyString& folder) cons template bool ClusterList::loadDataSeriesFromFolder(Study& s, const AnyString& folder) { - return std::ranges::all_of(allClusters_, [&s, &folder](auto c) - { return c->loadDataSeriesFromFolder(s, folder); }); + return std::ranges::all_of(allClusters_, + [&s, &folder](auto c) + { return c->loadDataSeriesFromFolder(s, folder); }); } template diff --git a/src/libs/antares/study/parts/hydro/allocation.cpp b/src/libs/antares/study/parts/hydro/allocation.cpp index 597264cf20..052bc3411d 100644 --- a/src/libs/antares/study/parts/hydro/allocation.cpp +++ b/src/libs/antares/study/parts/hydro/allocation.cpp @@ -164,8 +164,7 @@ void HydroAllocation::clear() #endif } -bool HydroAllocation::loadFromFile(const AreaName& referencearea, - const fs::path& filename) +bool HydroAllocation::loadFromFile(const AreaName& referencearea, const fs::path& filename) { clear(); @@ -177,21 +176,24 @@ bool HydroAllocation::loadFromFile(const AreaName& referencearea, } if (ini.empty()) + { return true; + } - ini.each([this](const IniFile::Section& section) - { - for (auto* p = section.firstProperty; p; p = p->next) - { - double coeff = p->value.to(); - if (!Utils::isZero(coeff)) - { - AreaName areaname = p->key; - areaname.toLower(); - pValues[areaname] = coeff; - } - } - }); + ini.each( + [this](const IniFile::Section& section) + { + for (auto* p = section.firstProperty; p; p = p->next) + { + double coeff = p->value.to(); + if (!Utils::isZero(coeff)) + { + AreaName areaname = p->key; + areaname.toLower(); + pValues[areaname] = coeff; + } + } + }); return true; } diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp index c9dc476de5..e98d94bee4 100644 --- a/src/libs/antares/study/parts/hydro/container.cpp +++ b/src/libs/antares/study/parts/hydro/container.cpp @@ -32,7 +32,7 @@ using namespace Yuni; namespace Antares::Data { -PartHydro::PartHydro(const Data::Area& area) : +PartHydro::PartHydro(const Data::Area& area): interDailyBreakdown(0.), intraDailyModulation(2.), intermonthlyBreakdown(0), @@ -113,7 +113,9 @@ static bool loadProperties(Study& study, T PartHydro::*ptr) { if (!property) + { return false; + } bool ret = true; @@ -242,52 +244,74 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder) if (IniFile::Section* section = ini.find("inter-daily-breakdown")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::interDailyBreakdown) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::interDailyBreakdown) + && ret; } if (IniFile::Section* section = ini.find("intra-daily-modulation")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::intraDailyModulation) && ret; + ret = loadProperties(study, + section->firstProperty, + buffer, + &PartHydro::intraDailyModulation) + && ret; } if (IniFile::Section* section = ini.find("reservoir")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::reservoirManagement) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::reservoirManagement) + && ret; } if (IniFile::Section* section = ini.find("reservoir capacity")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::reservoirCapacity) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::reservoirCapacity) + && ret; } if (IniFile::Section* section = ini.find("follow load")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::followLoadModulations) && ret; + ret = loadProperties(study, + section->firstProperty, + buffer, + &PartHydro::followLoadModulations) + && ret; } if (IniFile::Section* section = ini.find("use water")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::useWaterValue) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::useWaterValue) + && ret; } if (IniFile::Section* section = ini.find("hard bounds")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::hardBoundsOnRuleCurves) && ret; + ret = loadProperties(study, + section->firstProperty, + buffer, + &PartHydro::hardBoundsOnRuleCurves) + && ret; } if (IniFile::Section* section = ini.find("use heuristic")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::useHeuristicTarget) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::useHeuristicTarget) + && ret; } if (IniFile::Section* section = ini.find("power to level")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::powerToLevel) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::powerToLevel) + && ret; } if (IniFile::Section* section = ini.find("initialize reservoir date")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::initializeReservoirLevelDate) && ret; + ret = loadProperties(study, + section->firstProperty, + buffer, + &PartHydro::initializeReservoirLevelDate) + && ret; } if (IniFile::Section* section = ini.find("use leeway")) @@ -297,17 +321,20 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder) if (IniFile::Section* section = ini.find("leeway low")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::leewayLowerBound) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::leewayLowerBound) + && ret; } if (IniFile::Section* section = ini.find("leeway up")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::leewayUpperBound) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::leewayUpperBound) + && ret; } if (IniFile::Section* section = ini.find("pumping efficiency")) { - ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::pumpingEfficiency) && ret; + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::pumpingEfficiency) + && ret; } return ret; @@ -317,10 +344,12 @@ bool PartHydro::checkReservoirLevels(const Study& study) { bool ret = true; - for (const auto& [areaName, area] : study.areas) + for (const auto& [areaName, area]: study.areas) { if (!study.usedByTheSolver) + { return true; + } auto& col = area->hydro.inflowPattern[0]; bool errorInflow = false; @@ -340,8 +369,8 @@ bool PartHydro::checkReservoirLevels(const Study& study) for (unsigned int day = 0; day < DAYS_PER_YEAR; day++) { if (!errorLevels - && (colMin[day] < 0 || colAvg[day] < 0 || colMin[day] > colMax[day] - || colAvg[day] > 100 || colMax[day] > 100)) + && (colMin[day] < 0 || colAvg[day] < 0 || colMin[day] > colMax[day] + || colAvg[day] > 100 || colMax[day] > 100)) { logs.error() << areaName << ": invalid reservoir level value"; errorLevels = true; @@ -352,7 +381,7 @@ bool PartHydro::checkReservoirLevels(const Study& study) for (int i = 0; i < 101; i++) { if ((area->hydro.creditModulation[i][0] < 0) - || (area->hydro.creditModulation[i][1] < 0)) + || (area->hydro.creditModulation[i][1] < 0)) { logs.error() << areaName << ": invalid credit modulation value"; ret = false; @@ -372,75 +401,73 @@ bool PartHydro::checkProperties(Study& study) // the study, because they are too small (< 1e-6). We cannot have reservoir management = yes and // capacity = 0 because of further division by capacity. reservoir management = no and capacity // = 0 is possible (no use of capacity further) - study.areas.each([&ret](Data::Area& area) - { - if (area.hydro.reservoirCapacity < 1e-3 && area.hydro.reservoirManagement) - { - logs.error() << area.name - << ": reservoir capacity not defined. Impossible to manage."; - ret = false; - } + study.areas.each( + [&ret](Data::Area& area) + { + if (area.hydro.reservoirCapacity < 1e-3 && area.hydro.reservoirManagement) + { + logs.error() << area.name + << ": reservoir capacity not defined. Impossible to manage."; + ret = false; + } - if (!area.hydro.useHeuristicTarget && !area.hydro.useWaterValue) - { - logs.error() << area.name - << " : use water value = no conflicts with use heuristic target = no"; - ret = false; - } + if (!area.hydro.useHeuristicTarget && !area.hydro.useWaterValue) + { + logs.error() << area.name + << " : use water value = no conflicts with use heuristic target = no"; + ret = false; + } - if (area.hydro.intraDailyModulation < 1.) - { - logs.error() - << area.id << ": Invalid intra-daily modulation. It must be >= 1.0, Got " - << area.hydro.intraDailyModulation << " (truncated to 1)"; - area.hydro.intraDailyModulation = 1.; - } + if (area.hydro.intraDailyModulation < 1.) + { + logs.error() << area.id << ": Invalid intra-daily modulation. It must be >= 1.0, Got " + << area.hydro.intraDailyModulation << " (truncated to 1)"; + area.hydro.intraDailyModulation = 1.; + } - if (area.hydro.reservoirCapacity < 0) - { - logs.error() << area.id << ": Invalid reservoir capacity."; - area.hydro.reservoirCapacity = 0.; - } + if (area.hydro.reservoirCapacity < 0) + { + logs.error() << area.id << ": Invalid reservoir capacity."; + area.hydro.reservoirCapacity = 0.; + } - if (area.hydro.intermonthlyBreakdown < 0) - { - logs.error() << area.id << ": Invalid intermonthly breakdown"; - area.hydro.intermonthlyBreakdown = 0.; - } + if (area.hydro.intermonthlyBreakdown < 0) + { + logs.error() << area.id << ": Invalid intermonthly breakdown"; + area.hydro.intermonthlyBreakdown = 0.; + } - if (area.hydro.initializeReservoirLevelDate < 0) - { - logs.error() << area.id << ": Invalid initialize reservoir date"; - area.hydro.initializeReservoirLevelDate = 0; - } + if (area.hydro.initializeReservoirLevelDate < 0) + { + logs.error() << area.id << ": Invalid initialize reservoir date"; + area.hydro.initializeReservoirLevelDate = 0; + } - if (area.hydro.leewayLowerBound < 0.) - { - logs.error() - << area.id << ": Invalid leeway lower bound. It must be >= 0.0, Got " - << area.hydro.leewayLowerBound; - area.hydro.leewayLowerBound = 0.; - } + if (area.hydro.leewayLowerBound < 0.) + { + logs.error() << area.id << ": Invalid leeway lower bound. It must be >= 0.0, Got " + << area.hydro.leewayLowerBound; + area.hydro.leewayLowerBound = 0.; + } - if (area.hydro.leewayUpperBound < 0.) - { - logs.error() - << area.id << ": Invalid leeway upper bound. It must be >= 0.0, Got " - << area.hydro.leewayUpperBound; - area.hydro.leewayUpperBound = 0.; - } + if (area.hydro.leewayUpperBound < 0.) + { + logs.error() << area.id << ": Invalid leeway upper bound. It must be >= 0.0, Got " + << area.hydro.leewayUpperBound; + area.hydro.leewayUpperBound = 0.; + } - if (area.hydro.leewayLowerBound > area.hydro.leewayUpperBound) - { + if (area.hydro.leewayLowerBound > area.hydro.leewayUpperBound) + { logs.error() << area.id << ": Leeway lower bound greater than leeway upper bound."; - } + } - if (area.hydro.pumpingEfficiency < 0) - { - logs.error() << area.id << ": Invalid pumping efficiency"; - area.hydro.pumpingEfficiency = 0.; - } - }); + if (area.hydro.pumpingEfficiency < 0) + { + logs.error() << area.id << ": Invalid pumping efficiency"; + area.hydro.pumpingEfficiency = 0.; + } + }); return ret; } @@ -465,40 +492,40 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) struct AllSections { - IniFile::Section* s; - IniFile::Section* smod; - IniFile::Section* sIMB; - IniFile::Section* sreservoir; - IniFile::Section* sreservoirCapacity; - IniFile::Section* sFollowLoad; - IniFile::Section* sUseWater; - IniFile::Section* sHardBounds; - IniFile::Section* sInitializeReservoirDate; - IniFile::Section* sUseHeuristic; - IniFile::Section* sUseLeeway; - IniFile::Section* sPowerToLevel; - IniFile::Section* sLeewayLow; - IniFile::Section* sLeewayUp; - IniFile::Section* spumpingEfficiency; - - AllSections(IniFile& ini) : - s(ini.addSection("inter-daily-breakdown")), - smod(ini.addSection("intra-daily-modulation")), - sIMB(ini.addSection("inter-monthly-breakdown")), - sreservoir(ini.addSection("reservoir")), - sreservoirCapacity(ini.addSection("reservoir capacity")), - sFollowLoad(ini.addSection("follow load")), - sUseWater(ini.addSection("use water")), - sHardBounds(ini.addSection("hard bounds")), - sInitializeReservoirDate(ini.addSection("initialize reservoir date")), - sUseHeuristic(ini.addSection("use heuristic")), - sUseLeeway(ini.addSection("use leeway")), - sPowerToLevel(ini.addSection("power to level")), - sLeewayLow(ini.addSection("leeway low")), - sLeewayUp(ini.addSection("leeway up")), - spumpingEfficiency(ini.addSection("pumping efficiency")) + IniFile::Section* s; + IniFile::Section* smod; + IniFile::Section* sIMB; + IniFile::Section* sreservoir; + IniFile::Section* sreservoirCapacity; + IniFile::Section* sFollowLoad; + IniFile::Section* sUseWater; + IniFile::Section* sHardBounds; + IniFile::Section* sInitializeReservoirDate; + IniFile::Section* sUseHeuristic; + IniFile::Section* sUseLeeway; + IniFile::Section* sPowerToLevel; + IniFile::Section* sLeewayLow; + IniFile::Section* sLeewayUp; + IniFile::Section* spumpingEfficiency; + + AllSections(IniFile& ini): + s(ini.addSection("inter-daily-breakdown")), + smod(ini.addSection("intra-daily-modulation")), + sIMB(ini.addSection("inter-monthly-breakdown")), + sreservoir(ini.addSection("reservoir")), + sreservoirCapacity(ini.addSection("reservoir capacity")), + sFollowLoad(ini.addSection("follow load")), + sUseWater(ini.addSection("use water")), + sHardBounds(ini.addSection("hard bounds")), + sInitializeReservoirDate(ini.addSection("initialize reservoir date")), + sUseHeuristic(ini.addSection("use heuristic")), + sUseLeeway(ini.addSection("use leeway")), + sPowerToLevel(ini.addSection("power to level")), + sLeewayLow(ini.addSection("leeway low")), + sLeewayUp(ini.addSection("leeway up")), + spumpingEfficiency(ini.addSection("pumping efficiency")) { - } + } }; // Init @@ -515,7 +542,8 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) allSections.s->add(area.id, area.hydro.interDailyBreakdown); allSections.smod->add(area.id, area.hydro.intraDailyModulation); allSections.sIMB->add(area.id, area.hydro.intermonthlyBreakdown); - allSections.sInitializeReservoirDate->add(area.id, area.hydro.initializeReservoirLevelDate); + allSections.sInitializeReservoirDate->add(area.id, + area.hydro.initializeReservoirLevelDate); allSections.sLeewayLow->add(area.id, area.hydro.leewayLowerBound); allSections.sLeewayUp->add(area.id, area.hydro.leewayUpperBound); allSections.spumpingEfficiency->add(area.id, area.hydro.pumpingEfficiency); @@ -740,8 +768,8 @@ bool PartHydro::CheckDailyMaxEnergy(const AnyString& areaName) } double getWaterValue(const double& level /* format : in % of reservoir capacity */, - const Matrix& waterValues, - const uint day) + const Matrix& waterValues, + const uint day) { assert((level >= 0. && level <= 100.) && "getWaterValue function : invalid level"); double levelUp = ceil(level); @@ -752,7 +780,7 @@ double getWaterValue(const double& level /* format : in % of reservoir capacity return waterValues[(int)(levelUp)][day]; } return waterValues[(int)(levelUp)][day] * (level - levelDown) - + waterValues[(int)(levelDown)][day] * (levelUp - level); + + waterValues[(int)(levelDown)][day] * (levelUp - level); } double getWeeklyModulation(const double& level /* format : in % of reservoir capacity */, diff --git a/src/libs/antares/study/parts/hydro/finalLevelValidator.cpp b/src/libs/antares/study/parts/hydro/finalLevelValidator.cpp index 2229f75f97..5aa233fedb 100644 --- a/src/libs/antares/study/parts/hydro/finalLevelValidator.cpp +++ b/src/libs/antares/study/parts/hydro/finalLevelValidator.cpp @@ -37,8 +37,8 @@ FinalLevelValidator::FinalLevelValidator(PartHydro& hydro, double finalLevel, const unsigned int year, const unsigned int lastSimulationDay, - const unsigned int firstMonthOfSimulation) - : hydro_(hydro), + const unsigned int firstMonthOfSimulation): + hydro_(hydro), areaName_(areaName), areaIndex_(areaIndex), initialLevel_(initialLevel), @@ -52,36 +52,46 @@ FinalLevelValidator::FinalLevelValidator(PartHydro& hydro, bool FinalLevelValidator::check() { if (skippingFinalLevelUse()) + { return true; - if (! checkForInfeasibility()) + } + if (!checkForInfeasibility()) + { return false; + } finalLevelFineForUse_ = true; return true; } bool FinalLevelValidator::skippingFinalLevelUse() { - if(! wasSetInScenarioBuilder()) + if (!wasSetInScenarioBuilder()) + { return true; - if (! compatibleWithReservoirProperties()) + } + if (!compatibleWithReservoirProperties()) + { return true; + } return false; } bool FinalLevelValidator::wasSetInScenarioBuilder() { - return ! isnan(finalLevel_); + return !isnan(finalLevel_); } bool FinalLevelValidator::compatibleWithReservoirProperties() { if (hydro_.reservoirManagement && !hydro_.useWaterValue) + { return true; + } - logs.warning() << "Final reservoir level not applicable! Year:" << year_ + 1 - << ", Area:" << areaName_ - << ". Check: Reservoir management = Yes, Use water values = No and proper initial " - "reservoir level is provided "; + logs.warning() + << "Final reservoir level not applicable! Year:" << year_ + 1 << ", Area:" << areaName_ + << ". Check: Reservoir management = Yes, Use water values = No and proper initial " + "reservoir level is provided "; return false; } @@ -98,10 +108,12 @@ bool FinalLevelValidator::hydroAllocationStartMatchesSimulation() const { int initReservoirLvlMonth = hydro_.initializeReservoirLevelDate; // month [0-11] if (lastSimulationDay_ == DAYS_PER_YEAR && initReservoirLvlMonth == firstMonthOfSimulation_) + { return true; + } - logs.error() << "Year " << year_ + 1 << ", area '" << areaName_ << "' : " - << "Hydro allocation must start on the 1st simulation month and " + logs.error() << "Year " << year_ + 1 << ", area '" << areaName_ + << "' : " << "Hydro allocation must start on the 1st simulation month and " << "simulation last a whole year"; return false; } @@ -115,8 +127,8 @@ bool FinalLevelValidator::isFinalLevelReachable() const { logs.error() << "Year: " << year_ + 1 << ". Area: " << areaName_ << ". Incompatible total inflows: " << totalYearInflows - << " with initial: " << initialLevel_ - << " and final: " << finalLevel_ << " reservoir levels."; + << " with initial: " << initialLevel_ << " and final: " << finalLevel_ + << " reservoir levels."; return false; } return true; @@ -125,17 +137,19 @@ bool FinalLevelValidator::isFinalLevelReachable() const double FinalLevelValidator::calculateTotalInflows() const { // calculate yearly inflows - auto const& srcinflows = hydro_.series->storage.getColumn(year_); + const auto& srcinflows = hydro_.series->storage.getColumn(year_); double totalYearInflows = 0.0; for (unsigned int day = 0; day < DAYS_PER_YEAR; ++day) + { totalYearInflows += srcinflows[day]; + } return totalYearInflows; } bool FinalLevelValidator::isBetweenRuleCurves() const { - double lowLevelLastDay = hydro_.reservoirLevel[Data::PartHydro::minimum][DAYS_PER_YEAR - 1]; + double lowLevelLastDay = hydro_.reservoirLevel[Data::PartHydro::minimum][DAYS_PER_YEAR - 1]; double highLevelLastDay = hydro_.reservoirLevel[Data::PartHydro::maximum][DAYS_PER_YEAR - 1]; if (finalLevel_ < lowLevelLastDay || finalLevel_ > highLevelLastDay) diff --git a/src/libs/antares/study/parts/hydro/prepro.cpp b/src/libs/antares/study/parts/hydro/prepro.cpp index 9370c562fa..13711759f4 100644 --- a/src/libs/antares/study/parts/hydro/prepro.cpp +++ b/src/libs/antares/study/parts/hydro/prepro.cpp @@ -151,6 +151,7 @@ bool PreproHydro::loadFromFolder(Study& s, const AreaName& areaID, const std::st { mtrxOption = Matrix<>::optFixedSize | Matrix<>::optImmediate, }; + constexpr int maxNbOfLineToLoad = 12; data.resize(hydroPreproMax, 12, true); @@ -160,7 +161,8 @@ bool PreproHydro::loadFromFolder(Study& s, const AreaName& areaID, const std::st bool ret = PreproHydroLoadSettings(this, buffer); buffer.clear() << folder << SEP << areaID << SEP << "energy.txt"; - ret = data.loadFromCSVFile(buffer, hydroPreproMax, maxNbOfLineToLoad, mtrxOption, &s.dataBuffer) && ret; + ret = data.loadFromCSVFile(buffer, hydroPreproMax, maxNbOfLineToLoad, mtrxOption, &s.dataBuffer) + && ret; return ret; } @@ -203,8 +205,8 @@ bool PreproHydro::validate(const std::string& areaID) { ret = false; logs.error() << "Hydro: Prepro: `" << areaID - << "`: minimum energy: At least one value is negative (line: " - << (i + 1) << ')'; + << "`: minimum energy: At least one value is negative (line: " << (i + 1) + << ')'; continue; } if (colMin[i] > colMax[i]) diff --git a/src/libs/antares/study/parts/hydro/series.cpp b/src/libs/antares/study/parts/hydro/series.cpp index 3eda6d5fc3..8c73772565 100644 --- a/src/libs/antares/study/parts/hydro/series.cpp +++ b/src/libs/antares/study/parts/hydro/series.cpp @@ -54,7 +54,7 @@ static void ConvertDailyTSintoHourlyTS(const Matrix::ColumnType& dailyCo { uint hour = 0; uint day = 0; - + while (hour < HOURS_PER_YEAR && day < DAYS_PER_YEAR) { for (uint i = 0; i < HOURS_PER_DAY; ++i) diff --git a/src/libs/antares/study/parts/renewable/cluster_list.cpp b/src/libs/antares/study/parts/renewable/cluster_list.cpp index 62db61a900..aa1c915a75 100644 --- a/src/libs/antares/study/parts/renewable/cluster_list.cpp +++ b/src/libs/antares/study/parts/renewable/cluster_list.cpp @@ -223,7 +223,7 @@ bool RenewableClusterList::loadFromFolder(const AnyString& folder, Area* area) bool RenewableClusterList::validateClusters() const { bool ret = true; - for (const auto& cluster : allClusters_) + for (const auto& cluster: allClusters_) { ret = cluster->integrityCheck() && ret; } diff --git a/src/libs/antares/study/parts/short-term-storage/container.cpp b/src/libs/antares/study/parts/short-term-storage/container.cpp index 749613a14b..9a27233064 100644 --- a/src/libs/antares/study/parts/short-term-storage/container.cpp +++ b/src/libs/antares/study/parts/short-term-storage/container.cpp @@ -37,8 +37,7 @@ namespace Antares::Data::ShortTermStorage { bool STStorageInput::validate() const { - return std::ranges::all_of(storagesByIndex, [](auto& cluster) - { return cluster.validate(); }); + return std::ranges::all_of(storagesByIndex, [](auto& cluster) { return cluster.validate(); }); } bool STStorageInput::createSTStorageClustersFromIniFile(const fs::path& path) @@ -68,8 +67,9 @@ bool STStorageInput::createSTStorageClustersFromIniFile(const fs::path& path) storagesByIndex.push_back(cluster); } - std::ranges::sort(storagesByIndex, [](const auto& a, const auto& b) - { return a.properties.name < b.properties.name; }); + std::ranges::sort(storagesByIndex, + [](const auto& a, const auto& b) + { return a.properties.name < b.properties.name; }); return true; } @@ -100,8 +100,8 @@ bool STStorageInput::saveToFolder(const std::string& folder) const IniFile ini; logs.debug() << "saving file " << pathIni; - std::ranges::for_each(storagesByIndex, [&ini](auto& storage) - { return storage.saveProperties(ini); }); + std::ranges::for_each(storagesByIndex, + [&ini](auto& storage) { return storage.saveProperties(ini); }); return ini.save(pathIni); } @@ -109,20 +109,20 @@ bool STStorageInput::saveToFolder(const std::string& folder) const bool STStorageInput::saveDataSeriesToFolder(const std::string& folder) const { Yuni::IO::Directory::Create(folder); - return std::ranges::all_of(storagesByIndex, [&folder](auto& storage) - { return storage.saveSeries(folder + SEP + storage.id); }); + return std::ranges::all_of(storagesByIndex, + [&folder](auto& storage) + { return storage.saveSeries(folder + SEP + storage.id); }); } std::size_t STStorageInput::count() const { - return std::ranges::count_if(storagesByIndex, [](const STStorageCluster& st) - { return st.properties.enabled; }); + return std::ranges::count_if(storagesByIndex, + [](const STStorageCluster& st) { return st.properties.enabled; }); } uint STStorageInput::removeDisabledClusters() { - return std::erase_if(storagesByIndex, [](const auto& c) - { return !c.enabled(); }); + return std::erase_if(storagesByIndex, [](const auto& c) { return !c.enabled(); }); } } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/parts/thermal/cluster_list.cpp b/src/libs/antares/study/parts/thermal/cluster_list.cpp index 4bf2e042c2..8435870d0a 100644 --- a/src/libs/antares/study/parts/thermal/cluster_list.cpp +++ b/src/libs/antares/study/parts/thermal/cluster_list.cpp @@ -162,7 +162,8 @@ bool ThermalClusterList::loadFromFolder(Study& study, const AnyString& folder, A ret = cluster->modulation.loadFromCSVFile(modulationFile, thermalModulationMax, HOURS_PER_YEAR, - options) && ret; + options) + && ret; // Check the data integrity of the cluster addToCompleteList(cluster); @@ -174,12 +175,11 @@ bool ThermalClusterList::loadFromFolder(Study& study, const AnyString& folder, A return ret; } - bool ThermalClusterList::validateClusters(const Parameters& parameters) const { bool ret = true; - for (const auto& cluster : allClusters_) + for (const auto& cluster: allClusters_) { cluster->minUpTime = std::clamp(cluster->minUpTime, 1u, 168u); cluster->minDownTime = std::clamp(cluster->minDownTime, 1u, 168u); @@ -206,7 +206,6 @@ bool ThermalClusterList::validateClusters(const Parameters& parameters) const cluster->nominalCapacityWithSpinning = cluster->nominalCapacity; ret = cluster->integrityCheck() && ret; - } return ret; @@ -377,7 +376,7 @@ void ThermalClusterList::reverseCalculationOfSpinning() void ThermalClusterList::enableMustrunForEveryone() { - for (const auto& c : allClusters_) + for (const auto& c: allClusters_) { c->mustrun = true; } @@ -541,7 +540,6 @@ bool ThermalClusterList::saveToFolder(const AnyString& folder) const { ret = false; } - } // Write the ini file @@ -598,27 +596,32 @@ bool ThermalClusterList::loadPreproFromFolder(Study& study, const AnyString& fol return std::ranges::all_of(allClusters_ | std::views::filter(hasPrepro), loadPrepro); } -bool ThermalClusterList::validatePrepro(const Study& study) { +bool ThermalClusterList::validatePrepro(const Study& study) +{ auto hasPrepro = [](auto c) { return (bool)c->prepro; }; - const bool globalThermalTSgeneration = - study.parameters.timeSeriesToGenerate & timeSeriesThermal; + const bool globalThermalTSgeneration = study.parameters.timeSeriesToGenerate + & timeSeriesThermal; if (!study.usedByTheSolver) + { return true; + } - return std::ranges::all_of( - allClusters_ | std::views::filter(hasPrepro), - [&globalThermalTSgeneration](auto& c) { - if (globalThermalTSgeneration && !c->prepro->validate()) { - return false; - } - - if (c->doWeGenerateTS(globalThermalTSgeneration)) { - return c->prepro->normalizeAndCheckNPO(); - } - return true; - }); + return std::ranges::all_of(allClusters_ | std::views::filter(hasPrepro), + [&globalThermalTSgeneration](auto& c) + { + if (globalThermalTSgeneration && !c->prepro->validate()) + { + return false; + } + + if (c->doWeGenerateTS(globalThermalTSgeneration)) + { + return c->prepro->normalizeAndCheckNPO(); + } + return true; + }); } bool ThermalClusterList::loadEconomicCosts(Study& study, const AnyString& folder) diff --git a/src/libs/antares/study/runtime/runtime.cpp b/src/libs/antares/study/runtime/runtime.cpp index 035faf86ac..c094450243 100644 --- a/src/libs/antares/study/runtime/runtime.cpp +++ b/src/libs/antares/study/runtime/runtime.cpp @@ -213,8 +213,7 @@ void StudyRuntimeInfos::initializeRangeLimits(const Study& study, StudyRangeLimi } else { - simulationDaysPerMonth[ca.month] = study.calendar.months[ca.month].days - - ca.dayMonth; + simulationDaysPerMonth[ca.month] = study.calendar.months[ca.month].days - ca.dayMonth; simulationDaysPerMonth[cb.month] = cb.dayMonth + 1; for (uint i = ca.month + 1; i < cb.month; ++i) { @@ -441,7 +440,8 @@ void StudyRangeLimits::checkIntegrity() const void StudyRuntimeInfos::disableAllFilters(Study& study) { - study.areas.each([](Data::Area& area) + study.areas.each( + [](Data::Area& area) { area.filterSynthesis = filterAll; area.filterYearByYear = filterAll; diff --git a/src/libs/antares/study/scenario-builder/BindingConstraintsTSNumbersData.cpp b/src/libs/antares/study/scenario-builder/BindingConstraintsTSNumbersData.cpp index 46a0694a58..5ffef13e98 100644 --- a/src/libs/antares/study/scenario-builder/BindingConstraintsTSNumbersData.cpp +++ b/src/libs/antares/study/scenario-builder/BindingConstraintsTSNumbersData.cpp @@ -81,11 +81,11 @@ bool BindingConstraintsTSNumberData::reset(const Study& study) { const uint nbYears = study.parameters.nbYears; std::ranges::for_each(study.bindingConstraintsGroups, - [this, &nbYears](const auto& group) - { - auto& ts_numbers = rules_[group->name()]; - ts_numbers.reset(1, nbYears); - }); + [this, &nbYears](const auto& group) + { + auto& ts_numbers = rules_[group->name()]; + ts_numbers.reset(1, nbYears); + }); return true; } diff --git a/src/libs/antares/study/scenario-builder/hydroLevelsData.cpp b/src/libs/antares/study/scenario-builder/hydroLevelsData.cpp index 3295df4503..8d0575b96a 100644 --- a/src/libs/antares/study/scenario-builder/hydroLevelsData.cpp +++ b/src/libs/antares/study/scenario-builder/hydroLevelsData.cpp @@ -29,9 +29,9 @@ namespace Antares::Data::ScenarioBuilder { hydroLevelsData::hydroLevelsData(const std::string& iniFilePrefix, - std::function applyToTarget) : - addToPrefix_(iniFilePrefix), - applyToTarget_(applyToTarget) + std::function applyToTarget): + addToPrefix_(iniFilePrefix), + applyToTarget_(applyToTarget) { } diff --git a/src/libs/antares/study/scenario-builder/rules.cpp b/src/libs/antares/study/scenario-builder/rules.cpp index fd79f07f7c..2037eede6b 100644 --- a/src/libs/antares/study/scenario-builder/rules.cpp +++ b/src/libs/antares/study/scenario-builder/rules.cpp @@ -288,7 +288,9 @@ bool Rules::readFinalHydroLevels(const AreaName::Vector& splitKey, String value, const Data::Area* area = getArea(areaname, updaterMode); if (!area) + { return false; + } double finalLevel = fromStringToHydroLevel(value, 1.); hydroFinalLevels.setTSnumber(area->index, year, finalLevel); @@ -450,8 +452,7 @@ bool Rules::apply() void Rules::sendWarningsForDisabledClusters() { - for (auto it = disabledClustersOnRuleActive.begin(); - it != disabledClustersOnRuleActive.end(); + for (auto it = disabledClustersOnRuleActive.begin(); it != disabledClustersOnRuleActive.end(); it++) { std::vector& scenariiForCurrentCluster = it->second; diff --git a/src/libs/antares/study/study.cpp b/src/libs/antares/study/study.cpp index 511e61a592..5b1dde8c5f 100644 --- a/src/libs/antares/study/study.cpp +++ b/src/libs/antares/study/study.cpp @@ -856,7 +856,8 @@ void Study::areaDelete(Area::Vector& arealist) << area.name; // Updating all hydro allocation - areas.each([&area](Data::Area& areait) { areait.hydro.allocation.remove(area.id); }); + areas.each([&area](Data::Area& areait) + { areait.hydro.allocation.remove(area.id); }); // Remove all binding constraints attached to the area bindingConstraints.remove(*i); @@ -956,7 +957,7 @@ bool Study::areaRename(Area* area, AreaName newName) // Updating all hydro allocation areas.each([&oldid, &newid](Data::Area& areait) - { areait.hydro.allocation.rename(oldid, newid); }); + { areait.hydro.allocation.rename(oldid, newid); }); ScenarioBuilderUpdater updaterSB(*this); bool ret = true; @@ -1109,13 +1110,14 @@ void Study::destroyAllWindTSGeneratorData() void Study::destroyAllThermalTSGeneratorData() { - areas.each([](const Data::Area& area) - { - for (const auto& cluster: area.thermal.list.each_enabled_and_not_mustrun()) - { - FreeAndNil(cluster->prepro); - } - }); + areas.each( + [](const Data::Area& area) + { + for (const auto& cluster: area.thermal.list.each_enabled_and_not_mustrun()) + { + FreeAndNil(cluster->prepro); + } + }); } void Study::ensureDataAreLoadedForAllBindingConstraints() @@ -1358,7 +1360,6 @@ bool Study::checkForFilenameLimits(bool output, const String& chfolder) const areas.each( [&output, &linkname, &areaname](const Area& area) { - if (areaname.size() < area.id.size()) { areaname = area.id; diff --git a/src/libs/antares/study/study.importprepro.cpp b/src/libs/antares/study/study.importprepro.cpp index 3b8263eadf..f7c8082050 100644 --- a/src/libs/antares/study/study.importprepro.cpp +++ b/src/libs/antares/study/study.importprepro.cpp @@ -50,7 +50,7 @@ bool Study::importTimeseriesIntoInput() if (parameters.haveToImport(timeSeriesLoad)) { logs.info() << "Importing load timeseries..."; - for (const auto& [areaName, area] : areas) + for (const auto& [areaName, area]: areas) { logs.info() << "Importing load timeseries : " << areaName; buffer.clear() << folderInput << SEP << "load" << SEP << "series"; @@ -63,7 +63,7 @@ bool Study::importTimeseriesIntoInput() if (parameters.haveToImport(timeSeriesSolar)) { logs.info() << "Importing solar timeseries..."; - for (const auto& [areaName, area] : areas) + for (const auto& [areaName, area]: areas) { logs.info() << "Importing solar timeseries : " << areaName; buffer.clear() << folderInput << SEP << "solar" << SEP << "series"; @@ -76,7 +76,7 @@ bool Study::importTimeseriesIntoInput() if (parameters.haveToImport(timeSeriesHydro)) { logs.info() << "Importing hydro timeseries..."; - for (const auto& [areaName, area] : areas) + for (const auto& [areaName, area]: areas) { logs.info() << "Importing hydro timeseries : " << areaName; buffer.clear() << folderInput << SEP << "hydro" << SEP << "series"; @@ -89,7 +89,7 @@ bool Study::importTimeseriesIntoInput() if (parameters.haveToImport(timeSeriesWind)) { logs.info() << "Importing wind timeseries..."; - for (const auto& [areaName, area] : areas) + for (const auto& [areaName, area]: areas) { logs.info() << "Importing wind timeseries : " << areaName; buffer.clear() << folderInput << SEP << "wind" << SEP << "series"; @@ -104,7 +104,7 @@ bool Study::importTimeseriesIntoInput() logs.info() << "Importing thermal timeseries..."; String msg; - for (const auto& [areaName, area] : areas) + for (const auto& [areaName, area]: areas) { msg.clear() << "Importing thermal timeseries : " << areaName; diff --git a/src/libs/antares/study/xcast/xcast.cpp b/src/libs/antares/study/xcast/xcast.cpp index 51ed1624b0..0f2e05956b 100644 --- a/src/libs/antares/study/xcast/xcast.cpp +++ b/src/libs/antares/study/xcast/xcast.cpp @@ -207,7 +207,8 @@ bool XCast::loadFromFolder(const AnyString& folder) // For each property if (section.name == "general") { - for (const IniFile::Property* p = section.firstProperty; p != nullptr; p = p->next) + for (const IniFile::Property* p = section.firstProperty; p != nullptr; + p = p->next) { CString<30, false> key = p->key; key.toLower(); diff --git a/src/libs/antares/writer/in_memory_writer.cpp b/src/libs/antares/writer/in_memory_writer.cpp index e3e643a74f..182fee1927 100644 --- a/src/libs/antares/writer/in_memory_writer.cpp +++ b/src/libs/antares/writer/in_memory_writer.cpp @@ -24,9 +24,9 @@ #include #include +#include #include #include -#include namespace fs = std::filesystem; diff --git a/src/libs/antares/writer/zip_writer.cpp b/src/libs/antares/writer/zip_writer.cpp index 362d0e730e..6359460f8a 100644 --- a/src/libs/antares/writer/zip_writer.cpp +++ b/src/libs/antares/writer/zip_writer.cpp @@ -51,7 +51,6 @@ static void logErrorAndThrow [[noreturn]] (const std::string& errorMessage) throw std::runtime_error(errorMessage); } - // Class ZipWriteJob template ZipWriteJob::ZipWriteJob(ZipWriter& writer, diff --git a/src/solver/application/application.cpp b/src/solver/application/application.cpp index d222ad88c0..9ec3ce3e14 100644 --- a/src/solver/application/application.cpp +++ b/src/solver/application/application.cpp @@ -337,10 +337,14 @@ void Application::prepare(int argc, char* argv[]) // don't de-allocate these. if (!parseCommandLine(options)) // --help + { return; + } if (!handleOptions(options)) // --version, --list-solvers - return; + { + return; + } // Perform some checks checkAndCorrectSettingsAndOptions(pSettings, options); diff --git a/src/solver/constraints-builder/cbuilder.cpp b/src/solver/constraints-builder/cbuilder.cpp index a49806ff16..0b37556347 100644 --- a/src/solver/constraints-builder/cbuilder.cpp +++ b/src/solver/constraints-builder/cbuilder.cpp @@ -364,8 +364,7 @@ bool CBuilder::saveCBuilderToFile(const String& filename) const if (filename == "") { - fs::path path = fs::path(pStudy.folder.c_str()) / "settings" - / "constraintbuilder.ini"; + fs::path path = fs::path(pStudy.folder.c_str()) / "settings" / "constraintbuilder.ini"; return ini.save(path.string()); } diff --git a/src/solver/hydro/include/antares/solver/hydro/management/management.h b/src/solver/hydro/include/antares/solver/hydro/management/management.h index b642e441c2..30528d92d2 100644 --- a/src/solver/hydro/include/antares/solver/hydro/management/management.h +++ b/src/solver/hydro/include/antares/solver/hydro/management/management.h @@ -152,8 +152,7 @@ class HydroManagement final // \return The total inflow for the whole year double prepareMonthlyTargetGenerations(Data::Area& area, TmpDataByArea& data); - void prepareDailyOptimalGenerations(uint y, - Antares::Data::Area::ScratchMap& scratchmap); + void prepareDailyOptimalGenerations(uint y, Antares::Data::Area::ScratchMap& scratchmap); void prepareDailyOptimalGenerations(Data::Area& area, uint y, diff --git a/src/solver/hydro/management/daily.cpp b/src/solver/hydro/management/daily.cpp index f7e4665159..d9651a1197 100644 --- a/src/solver/hydro/management/daily.cpp +++ b/src/solver/hydro/management/daily.cpp @@ -219,9 +219,9 @@ struct DebugData }; inline void HydroManagement::prepareDailyOptimalGenerations( - Data::Area& area, - uint y, - Antares::Data::Area::ScratchMap& scratchmap) + Data::Area& area, + uint y, + Antares::Data::Area::ScratchMap& scratchmap) { const auto srcinflows = area.hydro.series->storage.getColumn(y); diff --git a/src/solver/hydro/management/management.cpp b/src/solver/hydro/management/management.cpp index 703235fc61..a863668f64 100644 --- a/src/solver/hydro/management/management.cpp +++ b/src/solver/hydro/management/management.cpp @@ -385,23 +385,31 @@ bool HydroManagement::checkMinGeneration(uint year) const void HydroManagement::changeInflowsToAccommodateFinalLevels(uint year) { - areas_.each([this, &year](Data::Area& area) - { - auto& data = tmpDataByArea_[&area]; - - if (!area.hydro.deltaBetweenFinalAndInitialLevels[year].has_value()) - return; - - // Must be done before prepareMonthlyTargetGenerations - double delta = area.hydro.deltaBetweenFinalAndInitialLevels[year].value(); - if (delta < 0) - data.inflows[0] -= delta; - else if (delta > 0) - data.inflows[11] -= delta; - }); + areas_.each( + [this, &year](Data::Area& area) + { + auto& data = tmpDataByArea_[&area]; + + if (!area.hydro.deltaBetweenFinalAndInitialLevels[year].has_value()) + { + return; + } + + // Must be done before prepareMonthlyTargetGenerations + double delta = area.hydro.deltaBetweenFinalAndInitialLevels[year].value(); + if (delta < 0) + { + data.inflows[0] -= delta; + } + else if (delta > 0) + { + data.inflows[11] -= delta; + } + }); } -void HydroManagement::prepareNetDemand(uint year, Data::SimulationMode mode, +void HydroManagement::prepareNetDemand(uint year, + Data::SimulationMode mode, const Antares::Data::Area::ScratchMap& scratchmap) { areas_.each( diff --git a/src/solver/hydro/management/monthly.cpp b/src/solver/hydro/management/monthly.cpp index aa10b7c10e..37c2085e3c 100644 --- a/src/solver/hydro/management/monthly.cpp +++ b/src/solver/hydro/management/monthly.cpp @@ -290,22 +290,22 @@ void HydroManagement::prepareMonthlyOptimalGenerations(double* random_reservoir_ auto monthName = calendar_.text.months[simulationMonth].name; - buffer << monthName[0] << monthName[1] << monthName[2] << '\t'; - buffer << '\t'; - buffer << data.inflows[realmonth] << '\t'; - buffer << data.MTG[realmonth] << '\t'; - buffer << data.MOG[realmonth] / area.hydro.reservoirCapacity << '\t'; - buffer << data.MOL[realmonth] << '\t'; - buffer << minLvl[firstDay] << '\t'; - buffer << maxLvl[firstDay] << '\t'; - buffer << '\n'; - } - auto content = buffer.str(); - resultWriter_.addEntryFromBuffer(path.str(), content); - } + buffer << monthName[0] << monthName[1] << monthName[2] << '\t'; + buffer << '\t'; + buffer << data.inflows[realmonth] << '\t'; + buffer << data.MTG[realmonth] << '\t'; + buffer << data.MOG[realmonth] / area.hydro.reservoirCapacity << '\t'; + buffer << data.MOL[realmonth] << '\t'; + buffer << minLvl[firstDay] << '\t'; + buffer << maxLvl[firstDay] << '\t'; + buffer << '\n'; + } + auto content = buffer.str(); + resultWriter_.addEntryFromBuffer(path.str(), content); + } - indexArea++; - }); + indexArea++; + }); } } // namespace Antares diff --git a/src/solver/misc/include/antares/solver/misc/options.h b/src/solver/misc/include/antares/solver/misc/options.h index 2560a74d1c..00daf5aec7 100644 --- a/src/solver/misc/include/antares/solver/misc/options.h +++ b/src/solver/misc/include/antares/solver/misc/options.h @@ -27,8 +27,8 @@ #include #include -#include #include +#include /*! ** \brief Command line settings for launching the simulation diff --git a/src/solver/misc/options.cpp b/src/solver/misc/options.cpp index 9429b50e79..458ae2fa06 100644 --- a/src/solver/misc/options.cpp +++ b/src/solver/misc/options.cpp @@ -22,8 +22,8 @@ #include "antares/solver/misc/options.h" #include -#include #include +#include #include #include diff --git a/src/solver/simulation/adequacy.cpp b/src/solver/simulation/adequacy.cpp index 2b03f7bcdc..fa4a292902 100644 --- a/src/solver/simulation/adequacy.cpp +++ b/src/solver/simulation/adequacy.cpp @@ -68,7 +68,10 @@ bool Adequacy::simulationBegin() pProblemesHebdo.resize(pNbMaxPerformedYearsInParallel); for (uint numSpace = 0; numSpace < pNbMaxPerformedYearsInParallel; numSpace++) { - SIM_InitialisationProblemeHebdo(study, pProblemesHebdo[numSpace], nbHoursInAWeek, numSpace); + SIM_InitialisationProblemeHebdo(study, + pProblemesHebdo[numSpace], + nbHoursInAWeek, + numSpace); } } diff --git a/src/solver/simulation/common-eco-adq.cpp b/src/solver/simulation/common-eco-adq.cpp index 1f56235499..8095cc85bb 100644 --- a/src/solver/simulation/common-eco-adq.cpp +++ b/src/solver/simulation/common-eco-adq.cpp @@ -395,21 +395,23 @@ void PrepareRandomNumbers(Data::Study& study, }); } - void SetInitialHydroLevel(Data::Study& study, PROBLEME_HEBDO& problem, const HYDRO_VENTILATION_RESULTS& hydroVentilationResults) { uint firstDaySimu = study.parameters.simulationDays.first; - study.areas.each([&problem, &firstDaySimu, &hydroVentilationResults](const Data::Area& area) - { - if (area.hydro.reservoirManagement) - { - double capacity = area.hydro.reservoirCapacity; - problem.previousSimulationFinalLevel[area.index] = - hydroVentilationResults[area.index].NiveauxReservoirsDebutJours[firstDaySimu] * capacity; - } - }); + study.areas.each( + [&problem, &firstDaySimu, &hydroVentilationResults](const Data::Area& area) + { + if (area.hydro.reservoirManagement) + { + double capacity = area.hydro.reservoirCapacity; + problem.previousSimulationFinalLevel[area.index] = hydroVentilationResults[area.index] + .NiveauxReservoirsDebutJours + [firstDaySimu] + * capacity; + } + }); } void BuildThermalPartOfWeeklyProblem(Data::Study& study, diff --git a/src/solver/simulation/common-hydro-levels.cpp b/src/solver/simulation/common-hydro-levels.cpp index 81602073a1..b0ba258b0e 100644 --- a/src/solver/simulation/common-hydro-levels.cpp +++ b/src/solver/simulation/common-hydro-levels.cpp @@ -33,7 +33,7 @@ void computingHydroLevels(const Data::AreaList& areas, bool remixWasRun, bool computeAnyway) { - for (const auto& [_, area] : areas) + for (const auto& [_, area]: areas) { if (!area->hydro.reservoirManagement) { @@ -50,7 +50,7 @@ void computingHydroLevels(const Data::AreaList& areas, double reservoirCapacity = area->hydro.reservoirCapacity; std::vector& inflows = problem.CaracteristiquesHydrauliques[index] - .ApportNaturelHoraire; + .ApportNaturelHoraire; RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; @@ -65,7 +65,7 @@ void computingHydroLevels(const Data::AreaList& areas, std::vector& ovf = weeklyResults.debordementsHoraires; computeTimeStepLevel - computeLvlObj(nivInit, inflows, ovf, turb, pumpingRatio, pump, reservoirCapacity); + computeLvlObj(nivInit, inflows, ovf, turb, pumpingRatio, pump, reservoirCapacity); for (uint h = 0; h < nbHoursInAWeek - 1; h++) { @@ -94,7 +94,7 @@ void interpolateWaterValue(const Data::AreaList& areas, daysOfWeek[d] = weekFirstDay + d; } - for (const auto& [_, area] : areas) + for (const auto& [_, area]: areas) { uint index = area->index; @@ -118,22 +118,22 @@ void interpolateWaterValue(const Data::AreaList& areas, std::vector& niv = weeklyResults.niveauxHoraires; waterVal[0] = Data::getWaterValue(problem.previousSimulationFinalLevel[index] * 100 - / reservoirCapacity, - area->hydro.waterValues, - weekFirstDay); + / reservoirCapacity, + area->hydro.waterValues, + weekFirstDay); for (uint h = 1; h < nbHoursInAWeek; h++) { waterVal[h] = Data::getWaterValue(niv[h - 1], - area->hydro.waterValues, - daysOfWeek[h / 24]); + area->hydro.waterValues, + daysOfWeek[h / 24]); } } } void updatingWeeklyFinalHydroLevel(const Data::AreaList& areas, PROBLEME_HEBDO& problem) { - for (const auto& [_, area] : areas) + for (const auto& [_, area]: areas) { if (!area->hydro.reservoirManagement) { @@ -149,7 +149,7 @@ void updatingWeeklyFinalHydroLevel(const Data::AreaList& areas, PROBLEME_HEBDO& std::vector& niv = weeklyResults.niveauxHoraires; problem.previousSimulationFinalLevel[index] = niv[nbHoursInAWeek - 1] * reservoirCapacity - / 100; + / 100; } } diff --git a/src/solver/simulation/common-hydro-remix.cpp b/src/solver/simulation/common-hydro-remix.cpp index dcf39052ce..de8e3f5328 100644 --- a/src/solver/simulation/common-hydro-remix.cpp +++ b/src/solver/simulation/common-hydro-remix.cpp @@ -51,8 +51,7 @@ static bool Remix(const Data::AreaList& areas, bool status = true; areas.each( - [&HE, &DE, &remix, &G, &status, &problem, &numSpace, &hourInYear] - (const Data::Area& area) + [&HE, &DE, &remix, &G, &status, &problem, &numSpace, &hourInYear](const Data::Area& area) { auto index = area.index; diff --git a/src/solver/simulation/economy.cpp b/src/solver/simulation/economy.cpp index 934ebc4c2c..ac40117b2c 100644 --- a/src/solver/simulation/economy.cpp +++ b/src/solver/simulation/economy.cpp @@ -73,7 +73,10 @@ bool Economy::simulationBegin() for (uint numSpace = 0; numSpace < pNbMaxPerformedYearsInParallel; numSpace++) { - SIM_InitialisationProblemeHebdo(study, pProblemesHebdo[numSpace], nbHoursInAWeek, numSpace); + SIM_InitialisationProblemeHebdo(study, + pProblemesHebdo[numSpace], + nbHoursInAWeek, + numSpace); auto options = createOptimizationOptions(study); weeklyOptProblems_[numSpace] = Antares::Solver::Optimization::WeeklyOptimization:: diff --git a/src/solver/simulation/hydro-final-reservoir-level-functions.cpp b/src/solver/simulation/hydro-final-reservoir-level-functions.cpp index 32f2d4dfa2..225a0e2be9 100644 --- a/src/solver/simulation/hydro-final-reservoir-level-functions.cpp +++ b/src/solver/simulation/hydro-final-reservoir-level-functions.cpp @@ -26,43 +26,47 @@ */ #include "antares/solver/simulation/hydro-final-reservoir-level-functions.h" -#include "antares/study/parts/hydro/finalLevelValidator.h" + #include +#include "antares/study/parts/hydro/finalLevelValidator.h" namespace Antares::Solver { void CheckFinalReservoirLevelsConfiguration(const Data::Study& study) { - study.areas.each([&study](Data::Area &area) - { - uint nbYears = study.parameters.nbYears; - for (uint year = 0; year != nbYears; ++year) - { - if (! study.parameters.yearsFilter.at(year)) - continue; + study.areas.each( + [&study](Data::Area& area) + { + uint nbYears = study.parameters.nbYears; + for (uint year = 0; year != nbYears; ++year) + { + if (!study.parameters.yearsFilter.at(year)) + { + continue; + } - double initialLevel = study.scenarioInitialHydroLevels.entry[area.index][year]; - double finalLevel = study.scenarioFinalHydroLevels.entry[area.index][year]; + double initialLevel = study.scenarioInitialHydroLevels.entry[area.index][year]; + double finalLevel = study.scenarioFinalHydroLevels.entry[area.index][year]; - Data::FinalLevelValidator validator(area.hydro, - area.index, - area.name, - initialLevel, - finalLevel, - year, - study.parameters.simulationDays.end, - study.parameters.firstMonthInYear); - if (! validator.check()) - { - throw FatalError("hydro final level : infeasibility"); - } - if (validator.finalLevelFineForUse()) - { - area.hydro.deltaBetweenFinalAndInitialLevels[year] = finalLevel - initialLevel; - } - } - }); + Data::FinalLevelValidator validator(area.hydro, + area.index, + area.name, + initialLevel, + finalLevel, + year, + study.parameters.simulationDays.end, + study.parameters.firstMonthInYear); + if (!validator.check()) + { + throw FatalError("hydro final level : infeasibility"); + } + if (validator.finalLevelFineForUse()) + { + area.hydro.deltaBetweenFinalAndInitialLevels[year] = finalLevel - initialLevel; + } + } + }); } // End function CheckFinalReservoirLevelsConfiguration -} // namespace Antares::Solver \ No newline at end of file +} // namespace Antares::Solver diff --git a/src/solver/simulation/include/antares/solver/simulation/solver.hxx b/src/solver/simulation/include/antares/solver/simulation/solver.hxx index 232fa520fc..cd6bcb5f62 100644 --- a/src/solver/simulation/include/antares/solver/simulation/solver.hxx +++ b/src/solver/simulation/include/antares/solver/simulation/solver.hxx @@ -39,7 +39,6 @@ #include "antares/solver/simulation/timeseries-numbers.h" #include "antares/solver/ts-generator/generator.h" - #include "hydro-final-reservoir-level-functions.h" namespace Antares::Solver::Simulation @@ -75,10 +74,7 @@ public: yearByYear(pYearByYear), pDurationCollector(durationCollector), pResultWriter(resultWriter), - hydroManagement(study.areas, - study.parameters, - study.calendar, - resultWriter) + hydroManagement(study.areas, study.parameters, study.calendar, resultWriter) { scratchmap = study.areas.buildScratchMap(numSpace); } @@ -162,11 +158,8 @@ public: simulation_->prepareClustersInMustRunMode(scratchmap, y); // 4 - Hydraulic ventilation - pDurationCollector("hydro_ventilation") << [this, &randomReservoirLevel] { - hydroManagement.makeVentilation(randomReservoirLevel, - y, - scratchmap); - }; + pDurationCollector("hydro_ventilation") << [this, &randomReservoirLevel] + { hydroManagement.makeVentilation(randomReservoirLevel, y, scratchmap); }; // Updating the state state.year = y; @@ -748,15 +741,15 @@ void ISimulation::computeRandomNumbers( max[firstDayOfMonth], randomHydroGenerator); - // Possibly update the intial level from scenario builder - if (study.parameters.useCustomScenario) - { - double levelFromScenarioBuilder = study.scenarioInitialHydroLevels[areaIndex][y]; - if (levelFromScenarioBuilder >= 0.) - { - randomLevel = levelFromScenarioBuilder; - } - } + // Possibly update the intial level from scenario builder + if (study.parameters.useCustomScenario) + { + double levelFromScenarioBuilder = study.scenarioInitialHydroLevels[areaIndex][y]; + if (levelFromScenarioBuilder >= 0.) + { + randomLevel = levelFromScenarioBuilder; + } + } // Current area's hydro starting (or initial) level computation // (no matter if the year is performed or not, we always draw a random initial @@ -780,7 +773,12 @@ void ISimulation::computeRandomNumbers( bool SpilledEnergySeedIsDefault = (currentSpilledEnergySeed == defaultSpilledEnergySeed); areaIndex = 0; study.areas.each( - [&isPerformed, &areaIndex, &randomUnsupplied, &randomSpilled, &randomForYears, &indexYear, + [&isPerformed, + &areaIndex, + &randomUnsupplied, + &randomSpilled, + &randomForYears, + &indexYear, &SpilledEnergySeedIsDefault](Data::Area& area) { (void)area; // Avoiding warnings at compilation (unused variable) on linux @@ -1030,19 +1028,19 @@ void ISimulation::loopThroughYears(uint firstYear, // continue; auto task = std::make_shared>( - this, - y, - set_it->yearFailed, - set_it->isFirstPerformedYearOfASet, - pFirstSetParallelWithAPerformedYearWasRun, - numSpace, - randomForParallelYears, - performCalculations, - study, - state[numSpace], - pYearByYear, - pDurationCollector, - pResultWriter); + this, + y, + set_it->yearFailed, + set_it->isFirstPerformedYearOfASet, + pFirstSetParallelWithAPerformedYearWasRun, + numSpace, + randomForParallelYears, + performCalculations, + study, + state[numSpace], + pYearByYear, + pDurationCollector, + pResultWriter); results.add(Concurrency::AddTask(*pQueueService, task)); } // End loop over years of the current set of parallel years diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index ed13d54fe1..7fb3336599 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -513,11 +513,11 @@ void SIM_RenseignementProblemeHebdo(const Study& study, if (area.hydro.useWaterValue) { - problem.CaracteristiquesHydrauliques[k].WeeklyWaterValueStateRegular = - getWaterValue( - problem.previousSimulationFinalLevel[k] * 100 / area.hydro.reservoirCapacity, - area.hydro.waterValues, - weekFirstDay); + problem.CaracteristiquesHydrauliques[k].WeeklyWaterValueStateRegular + = getWaterValue(problem.previousSimulationFinalLevel[k] * 100 + / area.hydro.reservoirCapacity, + area.hydro.waterValues, + weekFirstDay); } if (problem.CaracteristiquesHydrauliques[k].PresenceDHydrauliqueModulable > 0) diff --git a/src/solver/simulation/timeseries-numbers.cpp b/src/solver/simulation/timeseries-numbers.cpp index 52b1213ada..446a0efa08 100644 --- a/src/solver/simulation/timeseries-numbers.cpp +++ b/src/solver/simulation/timeseries-numbers.cpp @@ -329,8 +329,7 @@ bool checkInterModalConsistencyForArea(const Area& area, { logs.error() << "Inter-modal correlation: time-series numbers of inter-modal modes in area '" - << area.name << "'" - << " are not identical"; + << area.name << "'" << " are not identical"; return false; } diff --git a/src/solver/ts-generator/availability.cpp b/src/solver/ts-generator/availability.cpp index 69f62a10a1..dfb2d8c1f4 100644 --- a/src/solver/ts-generator/availability.cpp +++ b/src/solver/ts-generator/availability.cpp @@ -99,7 +99,9 @@ class GeneratorTempData final const T& duration) const; }; -GeneratorTempData::GeneratorTempData(Data::Study& study, unsigned nbOfSeriesToGen, MersenneTwister& rndGenerator): +GeneratorTempData::GeneratorTempData(Data::Study& study, + unsigned nbOfSeriesToGen, + MersenneTwister& rndGenerator): derated(study.parameters.derated), nbOfSeriesToGen_(nbOfSeriesToGen), rndgenerator(rndGenerator) @@ -616,10 +618,13 @@ listOfLinks getAllLinksToGen(Data::AreaList& areas) areas.each( [&links](const Data::Area& area) { - std::ranges::for_each(area.links, [&links](auto& l) + std::ranges::for_each(area.links, + [&links](auto& l) { if (!l.second->tsGeneration.forceNoGeneration) + { links.push_back(l.second); + } }); }); @@ -698,7 +703,10 @@ bool generateLinkTimeSeries(Data::Study& study, } // DIRECT - AvailabilityTSGeneratorData tsConfigDataDirect(tsGenStruct, ts, tsGenStruct.modulationCapacityDirect, link->with->name); + AvailabilityTSGeneratorData tsConfigDataDirect(tsGenStruct, + ts, + tsGenStruct.modulationCapacityDirect, + link->with->name); generator.generateTS(*link->from, tsConfigDataDirect); @@ -707,12 +715,14 @@ bool generateLinkTimeSeries(Data::Study& study, writeResultsToDisk(study, writer, ts.timeSeries, filePath); // INDIRECT - AvailabilityTSGeneratorData tsConfigDataIndirect(tsGenStruct, ts, tsGenStruct.modulationCapacityIndirect, link->with->name); + AvailabilityTSGeneratorData tsConfigDataIndirect(tsGenStruct, + ts, + tsGenStruct.modulationCapacityIndirect, + link->with->name); generator.generateTS(*link->from, tsConfigDataIndirect); - filePath = savePath + SEP + link->from->id + SEP + link->with->id.c_str() - + "_indirect.txt"; + filePath = savePath + SEP + link->from->id + SEP + link->with->id.c_str() + "_indirect.txt"; writeResultsToDisk(study, writer, ts.timeSeries, filePath); } diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index ca0c96087a..56f7234119 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -593,7 +593,8 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (study.parameters.derated) { - study.areas.each([&predicate](Data::Area& area) { predicate.matrix(area).averageTimeseries(); }); + study.areas.each([&predicate](Data::Area& area) + { predicate.matrix(area).averageTimeseries(); }); } if (study.parameters.timeSeriesToArchive & timeSeriesType) diff --git a/src/solver/utils/ortools_utils.cpp b/src/solver/utils/ortools_utils.cpp index 1f2f5e4169..2cc81b80fa 100644 --- a/src/solver/utils/ortools_utils.cpp +++ b/src/solver/utils/ortools_utils.cpp @@ -56,10 +56,9 @@ static void checkSetSolverSpecificParameters(bool status, } } -static void TuneSolverSpecificOptions( - MPSolver* solver, - const std::string& solverName, - const std::string& solverParameters) +static void TuneSolverSpecificOptions(MPSolver* solver, + const std::string& solverName, + const std::string& solverParameters) { if (!solver) { @@ -135,7 +134,6 @@ MPSolver* ProblemSimplexeNommeConverter::Convert() return solver; } - void ProblemSimplexeNommeConverter::CopyMatrix(const MPSolver* solver) const { auto variables = solver->variables(); diff --git a/src/solver/variable/include/antares/solver/variable/economy/all.h b/src/solver/variable/include/antares/solver/variable/economy/all.h index a3c637c43f..b7a62eb6bf 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/all.h +++ b/src/solver/variable/include/antares/solver/variable/economy/all.h @@ -248,8 +248,8 @@ typedef Variable::Join< Variable::Areas, // Variables for each set of areas Variable::Join, - // Variables for each binding constraint - Variable::BindingConstraints>> + // Variables for each binding constraint + Variable::BindingConstraints>> ItemList; /*! diff --git a/src/solver/variable/include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h b/src/solver/variable/include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h index 6d7e02fa3e..8a1f97676f 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h +++ b/src/solver/variable/include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h @@ -147,7 +147,6 @@ class BindingConstMarginCost NextType::simulationEnd(); } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -257,8 +256,8 @@ class BindingConstMarginCost for (int dayInTheWeek = 0; dayInTheWeek < 7; dayInTheWeek++) { pValuesForTheCurrentYear[numSpace].day[dayInTheYear] - -= state.problemeHebdo - ->ResultatsContraintesCouplantes[associatedBC_][dayInTheWeek]; + -= state.problemeHebdo + ->ResultatsContraintesCouplantes[associatedBC_][dayInTheWeek]; dayInTheYear++; } @@ -270,7 +269,7 @@ class BindingConstMarginCost { uint weekInTheYear = state.weekInTheYear; double weeklyValue = -state.problemeHebdo - ->ResultatsContraintesCouplantes[associatedBC_][0]; + ->ResultatsContraintesCouplantes[associatedBC_][0]; pValuesForTheCurrentYear[numSpace].week[weekInTheYear] = weeklyValue; diff --git a/src/solver/variable/include/antares/solver/variable/endoflist.h b/src/solver/variable/include/antares/solver/variable/endoflist.h index 7c32c32ecb..d8cb5dd69d 100644 --- a/src/solver/variable/include/antares/solver/variable/endoflist.h +++ b/src/solver/variable/include/antares/solver/variable/endoflist.h @@ -254,7 +254,6 @@ class EndOfList static void computeSpatialAggregateWith(O&, const Data::Area*, uint numSpace) { UNUSED_VARIABLE(numSpace); - assert(false); } template diff --git a/src/tests/end-to-end/simple_study/simple-study.cpp b/src/tests/end-to-end/simple_study/simple-study.cpp index bfad50326f..96a66aef3e 100644 --- a/src/tests/end-to-end/simple_study/simple-study.cpp +++ b/src/tests/end-to-end/simple_study/simple-study.cpp @@ -82,7 +82,7 @@ HydroMaxPowerStudy::HydroMaxPowerStudy() area = addAreaToStudy("Area"); area->thermal.unsuppliedEnergyCost = 1; - setNumberMCyears(1); + setNumberMCyears(1); TimeSeriesConfigurer loadTSconfig(area->load.series.timeSeries); loadTSconfig.setColumnCount(1).fillColumnWith(0, loadInArea); diff --git a/src/tests/end-to-end/utils/utils.cpp b/src/tests/end-to-end/utils/utils.cpp index a42891ea45..fdba99c007 100644 --- a/src/tests/end-to-end/utils/utils.cpp +++ b/src/tests/end-to-end/utils/utils.cpp @@ -219,7 +219,8 @@ void StudyBuilder::setNumberMCyears(unsigned int nbYears) { study->parameters.resetPlaylist(nbYears); study->areas.resizeAllTimeseriesNumbers(nbYears); - study->areas.each([&](Data::Area& area) { area.hydro.deltaBetweenFinalAndInitialLevels.resize(nbYears); }); + study->areas.each([&](Data::Area& area) + { area.hydro.deltaBetweenFinalAndInitialLevels.resize(nbYears); }); } void StudyBuilder::playOnlyYear(unsigned int year) diff --git a/src/tests/end-to-end/utils/utils.h b/src/tests/end-to-end/utils/utils.h index 1fa55efbff..84362bf2e0 100644 --- a/src/tests/end-to-end/utils/utils.h +++ b/src/tests/end-to-end/utils/utils.h @@ -164,14 +164,17 @@ class ScenarioBuilderRule { return rules_->load; } + BindingConstraintsTSNumberData& bcGroup() { return rules_->binding_constraints; } + hydroTSNumberData& hydro() { return rules_->hydro; } + private: Rules::Ptr rules_; }; diff --git a/src/tests/src/libs/antares/antlr4-interface/test_antlr_interface.cpp b/src/tests/src/libs/antares/antlr4-interface/test_antlr_interface.cpp index e97f4e3524..04d1c7be9f 100644 --- a/src/tests/src/libs/antares/antlr4-interface/test_antlr_interface.cpp +++ b/src/tests/src/libs/antares/antlr4-interface/test_antlr_interface.cpp @@ -19,15 +19,17 @@ ** along with Antares_Simulator. If not, see . */ #define BOOST_TEST_MODULE antlr_interface tests -#include -#include -#include "antlr4-runtime.h" #include +#include +#include + #include "ExprLexer.h" #include "ExprParser.h" +#include "antlr4-runtime.h" using namespace antlr4; + BOOST_AUTO_TEST_CASE(test_antlr_interface) { const std::string my_input = "y = b + a*x"; diff --git a/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-read-line.cpp b/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-read-line.cpp index 7879559fb0..de09d007d1 100644 --- a/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-read-line.cpp +++ b/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-read-line.cpp @@ -355,10 +355,12 @@ BOOST_FIXTURE_TEST_CASE(on_area1_and_on_year_17__hydro_level_0_123_is_chosen__re AreaName::Vector splitKey = {"hl", "area 1", yearNumber}; my_rule.readLine(splitKey, level); - BOOST_CHECK_EQUAL(my_rule.hydroInitialLevels.get_value(yearNumber.to(), area_1->index), level.to()); + BOOST_CHECK_EQUAL(my_rule.hydroInitialLevels.get_value(yearNumber.to(), area_1->index), + level.to()); - BOOST_CHECK(my_rule.apply()); - BOOST_CHECK_EQUAL(study->scenarioInitialHydroLevels[area_1->index][yearNumber.to()], level.to()); + BOOST_CHECK(my_rule.apply()); + BOOST_CHECK_EQUAL(study->scenarioInitialHydroLevels[area_1->index][yearNumber.to()], + level.to()); } BOOST_FIXTURE_TEST_CASE( @@ -370,10 +372,11 @@ BOOST_FIXTURE_TEST_CASE( AreaName::Vector splitKey = {"hl", "area 2", yearNumber}; BOOST_CHECK(my_rule.readLine(splitKey, level)); - BOOST_CHECK_EQUAL(my_rule.hydroInitialLevels.get_value(yearNumber.to(), area_2->index), 1.); + BOOST_CHECK_EQUAL(my_rule.hydroInitialLevels.get_value(yearNumber.to(), area_2->index), + 1.); - BOOST_CHECK(my_rule.apply()); - BOOST_CHECK_EQUAL(study->scenarioInitialHydroLevels[area_2->index][yearNumber.to()], 1.); + BOOST_CHECK(my_rule.apply()); + BOOST_CHECK_EQUAL(study->scenarioInitialHydroLevels[area_2->index][yearNumber.to()], 1.); } BOOST_FIXTURE_TEST_CASE( @@ -385,10 +388,11 @@ BOOST_FIXTURE_TEST_CASE( AreaName::Vector splitKey = {"hl", "area 3", yearNumber}; BOOST_CHECK(my_rule.readLine(splitKey, level)); - BOOST_CHECK_EQUAL(my_rule.hydroInitialLevels.get_value(yearNumber.to(), area_3->index), 0.); + BOOST_CHECK_EQUAL(my_rule.hydroInitialLevels.get_value(yearNumber.to(), area_3->index), + 0.); - BOOST_CHECK(my_rule.apply()); - BOOST_CHECK_EQUAL(study->scenarioInitialHydroLevels[area_3->index][yearNumber.to()], 0.); + BOOST_CHECK(my_rule.apply()); + BOOST_CHECK_EQUAL(study->scenarioInitialHydroLevels[area_3->index][yearNumber.to()], 0.); } // ======================== @@ -396,47 +400,47 @@ BOOST_FIXTURE_TEST_CASE( // ======================== BOOST_FIXTURE_TEST_CASE(on_area1_and_on_year_8__hydro_level_0_342_is_chosen__reading_OK, Fixture) { - AreaName yearNumber = "8"; - String level = "0.342"; - AreaName::Vector splitKey = {"hfl", "area 1", yearNumber}; - my_rule.readLine(splitKey, level, false); + AreaName yearNumber = "8"; + String level = "0.342"; + AreaName::Vector splitKey = {"hfl", "area 1", yearNumber}; + my_rule.readLine(splitKey, level, false); - BOOST_CHECK_EQUAL(my_rule.hydroFinalLevels.get_value(yearNumber.to(), area_1->index), - level.to()); + BOOST_CHECK_EQUAL(my_rule.hydroFinalLevels.get_value(yearNumber.to(), area_1->index), + level.to()); - BOOST_CHECK(my_rule.apply()); - BOOST_CHECK_EQUAL(study->scenarioFinalHydroLevels[area_1->index][yearNumber.to()], - level.to()); + BOOST_CHECK(my_rule.apply()); + BOOST_CHECK_EQUAL(study->scenarioFinalHydroLevels[area_1->index][yearNumber.to()], + level.to()); } -BOOST_FIXTURE_TEST_CASE(on_area2_and_on_year_1__hydro_level_2_4_is_chosen_level_lowered_to_1__reading_OK, Fixture) +BOOST_FIXTURE_TEST_CASE( + on_area2_and_on_year_1__hydro_level_2_4_is_chosen_level_lowered_to_1__reading_OK, + Fixture) { - AreaName yearNumber = "1"; - String level = "2.4"; - AreaName::Vector splitKey = {"hfl", "area 2", yearNumber}; - BOOST_CHECK(my_rule.readLine(splitKey, level, false)); + AreaName yearNumber = "1"; + String level = "2.4"; + AreaName::Vector splitKey = {"hfl", "area 2", yearNumber}; + BOOST_CHECK(my_rule.readLine(splitKey, level, false)); - BOOST_CHECK_EQUAL(my_rule.hydroFinalLevels.get_value(yearNumber.to(), area_2->index), - 1.); + BOOST_CHECK_EQUAL(my_rule.hydroFinalLevels.get_value(yearNumber.to(), area_2->index), 1.); - BOOST_CHECK(my_rule.apply()); - BOOST_CHECK_EQUAL(study->scenarioFinalHydroLevels[area_2->index][yearNumber.to()], - 1.); + BOOST_CHECK(my_rule.apply()); + BOOST_CHECK_EQUAL(study->scenarioFinalHydroLevels[area_2->index][yearNumber.to()], 1.); } -BOOST_FIXTURE_TEST_CASE(on_area3_and_on_year_3__hydro_level_neg_5_2_is_chosen__level_raised_to_0__reading_OK, Fixture) +BOOST_FIXTURE_TEST_CASE( + on_area3_and_on_year_3__hydro_level_neg_5_2_is_chosen__level_raised_to_0__reading_OK, + Fixture) { - AreaName yearNumber = "3"; - String level = "-5.2"; - AreaName::Vector splitKey = {"hfl", "area 3", yearNumber}; - BOOST_CHECK(my_rule.readLine(splitKey, level, false)); + AreaName yearNumber = "3"; + String level = "-5.2"; + AreaName::Vector splitKey = {"hfl", "area 3", yearNumber}; + BOOST_CHECK(my_rule.readLine(splitKey, level, false)); - BOOST_CHECK_EQUAL(my_rule.hydroFinalLevels.get_value(yearNumber.to(), area_3->index), - 0.); + BOOST_CHECK_EQUAL(my_rule.hydroFinalLevels.get_value(yearNumber.to(), area_3->index), 0.); - BOOST_CHECK(my_rule.apply()); - BOOST_CHECK_EQUAL(study->scenarioFinalHydroLevels[area_3->index][yearNumber.to()], - 0.); + BOOST_CHECK(my_rule.apply()); + BOOST_CHECK_EQUAL(study->scenarioFinalHydroLevels[area_3->index][yearNumber.to()], 0.); } // ====================== diff --git a/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-save.cpp b/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-save.cpp index 13d5a38b48..64813637fc 100644 --- a/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-save.cpp +++ b/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-save.cpp @@ -436,7 +436,9 @@ BOOST_FIXTURE_TEST_CASE( // ======================== // Tests on Hydro final levels // ======================== -BOOST_FIXTURE_TEST_CASE(HYDRO_FINAL_LEVEL__TS_number_for_many_areas_and_years__generated_and_ref_sc_buider_files_are_identical, saveFixture) +BOOST_FIXTURE_TEST_CASE( + HYDRO_FINAL_LEVEL__TS_number_for_many_areas_and_years__generated_and_ref_sc_buider_files_are_identical, + saveFixture) { my_rule->hydroFinalLevels.setTSnumber(area_1->index, 4, 8); my_rule->hydroFinalLevels.setTSnumber(area_2->index, 11, 3); diff --git a/src/tests/src/libs/antares/test_utils.cpp b/src/tests/src/libs/antares/test_utils.cpp index ad7e97d833..5cb05e27c4 100644 --- a/src/tests/src/libs/antares/test_utils.cpp +++ b/src/tests/src/libs/antares/test_utils.cpp @@ -19,14 +19,14 @@ * along with Antares_Simulator. If not, see . */ #define BOOST_TEST_MODULE test utils +#include #include #include -#include - #include -#include + +#include namespace fs = std::filesystem; @@ -99,7 +99,8 @@ BOOST_AUTO_TEST_CASE(yuni_normalize_vs_std_lexically_normal) { Yuni::String yuniNorm; Yuni::IO::Normalize(yuniNorm, path.string()); - BOOST_CHECK_MESSAGE(path.lexically_normal().string() == yuniNorm, std::string("Check failed for ") + path.string()); + BOOST_CHECK_MESSAGE(path.lexically_normal().string() == yuniNorm, + std::string("Check failed for ") + path.string()); }; helper(fs::path("a/./b/..")); helper(fs::path("a/.///b/../")); diff --git a/src/tests/src/libs/antares/yaml-parser/test_yaml_parser.cpp b/src/tests/src/libs/antares/yaml-parser/test_yaml_parser.cpp index ebfbc4bba8..87978fbcaa 100644 --- a/src/tests/src/libs/antares/yaml-parser/test_yaml_parser.cpp +++ b/src/tests/src/libs/antares/yaml-parser/test_yaml_parser.cpp @@ -19,19 +19,22 @@ ** along with Antares_Simulator. If not, see . */ #define BOOST_TEST_MODULE yamlcpp tests -#include -#include -#include "yaml-cpp/yaml.h" -#include #include +#include #include #include +#include +#include + +#include "yaml-cpp/yaml.h" + // our data types struct Vec3 { float x, y, z; }; + struct Power { std::string name; @@ -44,6 +47,7 @@ struct Monster Vec3 position; std::vector powers; }; + namespace YAML { template<> @@ -71,6 +75,7 @@ struct convert return true; } }; + template<> struct convert { @@ -89,6 +94,7 @@ struct convert return true; } }; + template<> struct convert { @@ -108,7 +114,7 @@ struct convert rhs.name = node["name"].as(); rhs.position = node["position"].as(); const YAML::Node& powers = node["powers"]; - for (const auto power : powers) + for (const auto power: powers) { rhs.powers.push_back(power.as()); } diff --git a/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp b/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp index d4a6c3512b..a38d7ea12c 100644 --- a/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp +++ b/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp @@ -6,23 +6,24 @@ #define WIN32_LEAN_AND_MEAN #include +#include + #include "include/antares/solver/simulation/hydro-final-reservoir-level-functions.h" #include "include/antares/study/parts/hydro/finalLevelValidator.h" -#include using namespace Antares::Solver; using namespace Antares::Data; - struct Fixture { Fixture(const Fixture& f) = delete; Fixture(const Fixture&& f) = delete; Fixture& operator=(const Fixture& f) = delete; Fixture& operator=(const Fixture&& f) = delete; + Fixture() { - // Simulation last day must be 365 so that final level checks succeeds + // Simulation last day must be 365 so that final level checks succeeds study->parameters.simulationDays.end = 365; study->parameters.firstMonthInYear = january; uint nbYears = study->parameters.nbYears = 2; @@ -56,7 +57,6 @@ struct Fixture area_1->hydro.deltaBetweenFinalAndInitialLevels.resize(nbYears); area_2->hydro.deltaBetweenFinalAndInitialLevels.resize(nbYears); - // Scenario builder for initial and final reservoir levels // ------------------------------------------------------- uint areasCount = study->areas.size(); @@ -96,7 +96,7 @@ struct Fixture // ... Area 2 : Inflows time series area_2->hydro.series->storage.resize(nbInflowTS, 365); area_2->hydro.series->storage.timeSeries.fill(300.); - area_2->hydro.series->storage[0][0] = 300. + 1.; //DAYS_PER_YEAR + area_2->hydro.series->storage[0][0] = 300. + 1.; // DAYS_PER_YEAR area_2->hydro.series->storage[0][DAYS_PER_YEAR - 1] = 300. + 2.; } @@ -178,7 +178,8 @@ BOOST_AUTO_TEST_CASE(final_level_not_set_by_user____check_succeeds_but_final_lev BOOST_CHECK_EQUAL(validator.finalLevelFineForUse(), false); } -BOOST_AUTO_TEST_CASE(initial_level_month_and_simulation_first_month_different___check_fails_and_final_level_not_usable) +BOOST_AUTO_TEST_CASE( + initial_level_month_and_simulation_first_month_different___check_fails_and_final_level_not_usable) { uint year = 0; area_1->hydro.initializeReservoirLevelDate = 3; // initialize reservoir level != January @@ -233,7 +234,8 @@ BOOST_AUTO_TEST_CASE(final_level_out_of_rule_curves___check_fails_and_final_leve BOOST_CHECK_EQUAL(validator.finalLevelFineForUse(), false); } -BOOST_AUTO_TEST_CASE(final_level_unreachable_because_of_too_few_inflows___check_fails_and_final_level_not_usable) +BOOST_AUTO_TEST_CASE( + final_level_unreachable_because_of_too_few_inflows___check_fails_and_final_level_not_usable) { area_1->hydro.reservoirCapacity = 185000; uint year = 0; @@ -272,4 +274,4 @@ BOOST_AUTO_TEST_CASE(check_all_areas_final_levels_when_config_is_ok___all_checks BOOST_CHECK_EQUAL(area_2->hydro.deltaBetweenFinalAndInitialLevels[1].value(), 4.3 - 2.4); } -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END()