diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba7010934b..b79849439c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,55 +1,8 @@ # How to contribute to Antares Simulator ## Reporting a bug -- First, please make sure that the bug has not been already reported under [Issues](https://github.com/AntaresSimulatorTeam/Antares_Simulator/issues). - -- If not, [open a new one](https://github.com/AntaresSimulatorTeam/Antares_Simulator/issues/new). You must provide : - - a description of the bug and its unexpected behavior - - the expected behavior - - a small antares study to reproduce the unexpected behavior - - the version of Antares Simulator and OS used - +- First, please make sure that the bug has not been already reported under [Issues](https://github.com/AntaresSimulatorTeam/Antares_Simulator/issues). +- Then [open a bug here](https://github.com/AntaresSimulatorTeam/Antares_Simulator/issues/new?template=bug_report.md). ## Development -Antares Simulator team will be pleased to have developers join our project. - -You can find all the steps needed to build & install Antares Simulator in -the [documentation website](https://antares-simulator.readthedocs.io/) -or [its sources](docs/developer-guide/0-Introduction.md). - -### Branch names -Currently, CI is run only for specific branch names: -- `feature/*` -- `features/*` -- `fix/*` -- `release/*` -- `issue-*` -- `doc/*` - -If you create a branch with a different name, no CI will be run, but you will receive an email -indicating that your branch name is incorrect. - -In order to avoid pushing with invalid branch name, a git hook is provided for pre-commit check. -This hook is available in the `.githooks` directory. - -By default, git use hooks in `.git/hooks` directory which is not under version control. You can -define a new hooks directory with this command in Antares Simulator root directory : -``` -git config core.hooksPath .githooks -``` - -### Code formatting -We're using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to format code. Rules are defined in [.clang-format](src/.clang-format) file. - -### Pull Requests - -A pull request name must be self-explanatory: this will be the default commit title when merging. - -Please provide a description in the head comment of the PR. This description will be the details of the merge commit. -The description should be short but proportional to the length or complexity of the PR. Try to explain the motivation -of the PR (why) and the method employed (how). - -When a pull request is opened, please set it to draft if it is still being worked on or not ready for review. - -If your Pull Request changes a part of the code that is [documented](https://antares-simulator.readthedocs.io/), -please update the documentation also, in the ["docs"](docs) directory. \ No newline at end of file +See [here for more details](./docs/developer-guide/6-Contributing.md). diff --git a/docs/developer-guide/0-Overview.md b/docs/developer-guide/0-Overview.md index 139f23d552..c974f85ac3 100644 --- a/docs/developer-guide/0-Overview.md +++ b/docs/developer-guide/0-Overview.md @@ -5,8 +5,6 @@ hide: # Overview -*ANTARES* is developed mainly in **C++** - This software suite has been tested under: * Ubuntu 20.04 [![Status][ubuntu_ci_svg]][ubuntu_ci_link] diff --git a/docs/developer-guide/6-Contributing.md b/docs/developer-guide/6-Contributing.md new file mode 100644 index 0000000000..977a2860b8 --- /dev/null +++ b/docs/developer-guide/6-Contributing.md @@ -0,0 +1,277 @@ +# C++ Style Guide + +In general, [Google's coding standard](https://google.github.io/styleguide/cppguide.html) is used, and we strongly encourage to read it. + +You can find all the steps needed to build & install Antares Simulator in the [documentation website](https://antares-simulator.readthedocs.io/) or [its sources](docs/developer-guide/0-Introduction.md). + +Below are our specific (but not all!) exceptions to the Google's coding standard: + +- All C++ code should conform to the C++20 standard. +- We use `.cpp` files and `.h` for headers, in UTF-8 encoding. +- For new files we use CamelCase, like `FileReader.cpp`. +- We use `#pragma once` instead of the `#define` Guard in header files. +- Includes are sorted and grouped by directory, there should be newlines between different directories. +- Order of directories in includes: "current_dir/current_file.h", includes from other dirs sorted by dependencies (e.g. indexer, then coding, then base), "defines.h", C++ standard library headers, boost headers. +- We ARE using C++ exceptions. Feel free to define your own exceptions, derived from `std::exception` or any child class. +- We are using all features of C++17 and C++20 +- We try to limit the usage of boost libraries which require linking (and prefer C++20 types over their boost counterparts). + +Naming and formatting + +- We ALWAYS use 4 spaces indent and don't use tabs. +- We don't have strict limits on line width, but keep it reasonable to fit on the screen. The advised width is that written in the [src/.clang-format](src/.clang-format) file (currently 100). +- Doxygen-style comments can be used. +- Use left-to-right order for variables/params: `const string& s` (reference to the const string). +- In one line `if`, `for`, `while` we use brackets. +- Space after the keyword in conditions and loops. Space after `;` in `for` loop. +- Space between binary operators: `x = y * y + z * z`. +- Space after double dash. +- We use `using` keyword instead of `typedef`. +- We do not use the Systems Hungarian Notation: do not add the "p" suffix to your pointer variable names and the "T" prefix or suffix to your type names. +- Compile-time constants must be named in CamelCase, starting with a lower-case `k`, e.g. `kCompileTimeConstant` and marked as `constexpr` when possible. +- Functions (free or member) should be named using `lowerCamelCase`, e.g `isPrime(unsigned int n)`. +- Values of enum classes must be named in CAPITAL, e.g. `enum class Color { RED, GREEN, LIGHT_BLUE };`. +- Macros and C-style enums should be avoided. If necessary, they must be named in UPPER_CASE, and enum values must be prefixed with a capitalized enum name. + + Note that macros complicate debugging, and old-style enums have dangerous implicit conversions to integers, and tend to clutter + containing namespaces. Avoid them when possible - use `const` or `constexpr` instead of macros, and enum classes instead of enums. + +**We write code without warnings on clang++, g++ and MSVC !** + +## Global/static variables +When using `static` variables, be aware that some of Antares Simulator's functions run on multiple threads. Please avoid introducing global variables. + +## Yuni + +Yuni is a C++ framework that fullfiled some of the lacking features pre-C++11. Even though you'll see it used widely through the existing code base, we recommend against using it for new code. It is namespaced under `Yuni`. + +## Branch names +Currently, CI is run only for specific branch names: +- `feature/*` +- `features/*` +- `fix/*` +- `release/*` +- `issue-*` +- `doc/*` + +If you create a branch with a different name, no CI will be run, but you will receive a notification indicating that your branch name is incorrect. + +In order to avoid pushing with invalid branch name, a git hook is provided for pre-commit check. +This hook is available in the `.githooks` directory. + +By default, git use hooks in `.git/hooks` directory which is not under version control. You can +define a new hooks directory with this command in Antares Simulator root directory : +``` +git config core.hooksPath .githooks +``` + +## Pull Requests +A pull request name must be self-explanatory: this will be the default commit title when merging. + +Please provide a description in the head comment of the PR. This description will be the details of the merge commit. +The description should be short but proportional to the length or complexity of the PR. Try to explain the motivation of the PR (why) and the method employed (how). + +When a pull request is opened, please set it to draft if it is still being worked on or not ready for review. + +If your Pull Request changes a part of the code that is [documented](https://antares-simulator.readthedocs.io/), +please update the documentation also, in the ["docs"](docs) directory. + +## ClangFormat + +Most of our coding style is specified in a configuration file for [ClangFormat](http://clang.llvm.org/docs/ClangFormat.html). +To automatically format a file, install `clang-format` and run: + + clang-format -i file.cpp file.hpp other_file.cpp + +clang-format 18.1.3 is the reference version, but any 18.x version should work as well. We strongly advise that you configure your IDE / text editor to automatically format code according to the clang-format style. Non-conforming code can't be merged to the develop branch. + +You may also use script [src/format-code.sh](src/format-code.sh) to format all the code. Generated code (ANTLR, etc.) won't be automatically formatted. + +## Formatting Example/Guide/Reference + +```cpp +#pragma once + +#include + +uint16_t constexpr kBufferSize = 255; + +// C-style enums are ALL_CAPS. But remember that C++11 enum classes are preferred. +enum Type +{ + TYPE_INTEGER, + TYPE_FLOAT, + TYPE_STRING +}; + +using TMyTypeStartsWithCapitalTLetter = double; + +class ComplexClass +{ +public: + Complex(double rePart, double imPart): + re(rePart), + im(imPart) + { + } + + double Modulus() const + { + const double rere = re * re; + const double imim = im * im; + return sqrt(rere + imim); + } + + double OneLineMethod() const + { + return re; + } + +private: + double re; + double im; +}; + +namespace +{ +void lowerCamelCaseFunctionName(int lowerCamelCaseVar) +{ + static int counter = 0; + counter += lowerCamelCaseVar; +} +} // namespace + +namespace lower_case +{ +template +void SomeFoo(int a, int b, TypenameWithoutAffixes /* We avoid compilation warnings. */) +{ + for (int i = 0; i < a; ++i) + { + // IMPORTANT! We DON'T use one-liners for if statements for easier debugging. + // The following syntax is invalid: if (i < b) Bar(i); + if (i < b) + { + Bar(i); + } + else + { + Bar(i); + Bar(b); + // Commented out the call. + // Bar(c); + } + } +} +} // namespace lower_case + +// Switch formatting. +int Foo(int a) +{ + switch (a) + { + case 1: + Bar(1); + break; + case 2: + { + Bar(2); + break; + } + case 3: + default: + Bar(3); + break; + } + return 0; +} + +// Loops formatting. + +if (condition) +{ + foo(); +} +else +{ + bar(); +} + +if (condition) +{ + if (condition) + { + foo(); + } + else + { + bar(); + } +} + +for (size_t i = 0; i < size; ++i) +{ + foo(i); +} + +while (true) +{ + if (condition) + { + break; + } +} + +// Space after the keyword. +if (condition) +{ +} + +for (size_t i = 0; i < 5; ++i) +{ +} + +while (condition) +{ +} + +switch (i) +{ +} + +// Space between operators, and don't use space between unary operator and expression. +x = 0; +x = -5; +++x; +x--; +x *= 5; +if (x && !y) +{ +} +v = w * x + y / z; +v = w * (x + z); + + +// Space after double dash. And full sentences in comments. +``` + +## Tips and Hints + +- If you see outdated code which can be improved, DO IT NOW (but in a separate pull request or commit)! +- Your code should work at least on [ubuntu|windows] platforms. +- Your code should compile with a C++20 compiler (currently supported clang++/g++/MSVC) +- Consult with the dev team before using any new 3party library +- Cover your code with unit tests. See examples for existing libraries +- Check Base and Coding libraries for most of the basic functions +- Ask your team if you have any questions +- Release builds contain debugging information (for profiling), production builds do not +- If you don't have enough time to make it right, leave a `// TODO(DeveloperName): need to fix it` comment + +## Logging functions: + +- Use `Antares::logs.[level]() << message` for logging, below is more detailed description for level: + - `logs.info() << msg` - always prints log message + - `logs.debug() << msg` - logs only in DEBUG + - `logs.warning() << msg` - the same as `logs.info()` but catches your attention + - `logs.error()` - the same as `logs.warning()`, but triggers an error when loading a study, with exceptions + - `logs.fatal()` - same as `logs.error()` diff --git a/mkdocs.yml b/mkdocs.yml index cf71684518..129404222e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -77,6 +77,7 @@ nav: - 'Tests (user)': 'developer-guide/4-Tests-user.md' - 'Tests (developer)': 'developer-guide/4-Tests-dev.md' - 'Installer creation': 'developer-guide/5-Installer-creation.md' + - 'Contributing': 'developer-guide/6-Contributing.md' - 'Continuous Integration': 'developer-guide/continuous-integration.md' - 'OR-tools integration': 'developer-guide/ortools-integration.md' - 'Changelog': 'developer-guide/CHANGELOG.md' 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 1da5ab6023..8b8533da8c 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 @@ -224,6 +224,8 @@ class PartHydro std::vector> deltaBetweenFinalAndInitialLevels; + double overflowCost = 0.; + private: static bool checkReservoirLevels(const Study& study); static bool checkProperties(Study& study); diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp index 336595b95b..06cb68ec1e 100644 --- a/src/libs/antares/study/parts/hydro/container.cpp +++ b/src/libs/antares/study/parts/hydro/container.cpp @@ -89,6 +89,8 @@ void PartHydro::reset() allocation.clear(); // allocation.fromArea(, 1.); // Area::reset() + overflowCost = 0.; + if (prepro) { prepro->reset(); @@ -330,6 +332,12 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder) && ret; } + if (IniFile::Section* section = ini.find("overflow cost")) + { + ret = loadProperties(study, section->firstProperty, buffer, &PartHydro::overflowCost) + && ret; + } + return ret; } @@ -500,6 +508,7 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) IniFile::Section* sLeewayLow; IniFile::Section* sLeewayUp; IniFile::Section* spumpingEfficiency; + IniFile::Section* sOverflowCost; AllSections(IniFile& ini): s(ini.addSection("inter-daily-breakdown")), @@ -516,7 +525,8 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) sPowerToLevel(ini.addSection("power to level")), sLeewayLow(ini.addSection("leeway low")), sLeewayUp(ini.addSection("leeway up")), - spumpingEfficiency(ini.addSection("pumping efficiency")) + spumpingEfficiency(ini.addSection("pumping efficiency")), + sOverflowCost(ini.addSection("overflow cost")) { } }; @@ -572,6 +582,10 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) { allSections.sPowerToLevel->add(area.id, true); } + if (area.hydro.overflowCost) + { + allSections.sOverflowCost->add(area.id, area.hydro.overflowCost); + } // max hours gen buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP diff --git a/src/solver/hydro/daily/h2o_j_initialiser_les_bornes_des_variables.cpp b/src/solver/hydro/daily/h2o_j_initialiser_les_bornes_des_variables.cpp index 50f6e72bd5..fa7dab5a4c 100644 --- a/src/solver/hydro/daily/h2o_j_initialiser_les_bornes_des_variables.cpp +++ b/src/solver/hydro/daily/h2o_j_initialiser_les_bornes_des_variables.cpp @@ -53,7 +53,7 @@ void H2O_J_InitialiserLesBornesdesVariables(DONNEES_MENSUELLES* DonneesMensuelle int Var = CorrespondanceDesVariables.NumeroDeVariableTurbine[Pdt]; Xmax[Var] = TurbineMax[Pdt]; - Xmin[Var] = std::min(TurbineMax[Pdt], std::max(TurbineCible[Pdt], TurbineMin[Pdt])); + Xmin[Var] = std::min(TurbineMax[Pdt], TurbineMin[Pdt]); AdresseOuPlacerLaValeurDesVariablesOptimisees[Var] = &(Turbine[Pdt]); } diff --git a/src/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.cpp b/src/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.cpp index 1ed1e80371..95ce1c5555 100644 --- a/src/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.cpp @@ -41,8 +41,7 @@ AdqPatchPostProcessList::AdqPatchPostProcessList(const AdqPatchParams& adqPatchP problemeHebdo_, areas, thread_number_)); - post_process_list.push_back( - std::make_unique(problemeHebdo_, areas, false, false)); + post_process_list.push_back(std::make_unique(problemeHebdo_, areas, sheddingPolicy, @@ -54,8 +53,7 @@ AdqPatchPostProcessList::AdqPatchPostProcessList(const AdqPatchParams& adqPatchP problemeHebdo_, areas, thread_number)); - post_process_list.push_back( - std::make_unique(problemeHebdo_, areas, true, false)); + post_process_list.push_back( std::make_unique(problemeHebdo_, areas, calendar)); post_process_list.push_back( diff --git a/src/solver/optimisation/include/antares/solver/optimisation/post_process_commands.h b/src/solver/optimisation/include/antares/solver/optimisation/post_process_commands.h index 652ab48132..2d2ad8f0cd 100644 --- a/src/solver/optimisation/include/antares/solver/optimisation/post_process_commands.h +++ b/src/solver/optimisation/include/antares/solver/optimisation/post_process_commands.h @@ -37,21 +37,6 @@ class DispatchableMarginPostProcessCmd: public basePostProcessCommand const AreaList& area_list_; }; -class HydroLevelsUpdatePostProcessCmd: public basePostProcessCommand -{ -public: - HydroLevelsUpdatePostProcessCmd(PROBLEME_HEBDO* problemeHebdo, - AreaList& areas, - bool remixWasRun, - bool computeAnyway); - void execute(const optRuntimeData& opt_runtime_data) override; - -private: - const AreaList& area_list_; - bool remixWasRun_ = false; - bool computeAnyway_ = false; -}; - class RemixHydroPostProcessCmd: public basePostProcessCommand { public: diff --git a/src/solver/optimisation/opt_gestion_des_couts_cas_lineaire.cpp b/src/solver/optimisation/opt_gestion_des_couts_cas_lineaire.cpp index 4ea8c80457..9457d5cae4 100644 --- a/src/solver/optimisation/opt_gestion_des_couts_cas_lineaire.cpp +++ b/src/solver/optimisation/opt_gestion_des_couts_cas_lineaire.cpp @@ -275,22 +275,13 @@ void OPT_InitialiserLesCoutsLineaire(PROBLEME_HEBDO* problemeHebdo, */ + ProblemeAResoudre->CoutLineaire[var] = problemeHebdo->CoutDeDebordement[pays]; if (!problemeHebdo->CaracteristiquesHydrauliques[pays].AccurateWaterValue) { - ProblemeAResoudre->CoutLineaire[var] = abs(problemeHebdo - ->CoutDeDefaillanceNegative[pays]) - * 1.10; - ProblemeAResoudre->CoutLineaire[var] += problemeHebdo ->CaracteristiquesHydrauliques[pays] .WeeklyWaterValueStateRegular; } - else - { - ProblemeAResoudre->CoutLineaire[var] = abs(problemeHebdo - ->CoutDeDefaillanceNegative[pays]) - * 1.10; - } } var = variableManager.HydroLevel(pays, pdtJour); diff --git a/src/solver/optimisation/optim_post_process_list.cpp b/src/solver/optimisation/optim_post_process_list.cpp index a9eb38f7e8..baceb7f9d6 100644 --- a/src/solver/optimisation/optim_post_process_list.cpp +++ b/src/solver/optimisation/optim_post_process_list.cpp @@ -37,15 +37,13 @@ OptPostProcessList::OptPostProcessList(PROBLEME_HEBDO* problemeHebdo, { post_process_list.push_back( std::make_unique(problemeHebdo_, thread_number_, areas)); - post_process_list.push_back( - std::make_unique(problemeHebdo_, areas, false, false)); + post_process_list.push_back(std::make_unique(problemeHebdo_, areas, sheddingPolicy, splxOptimization, thread_number)); - post_process_list.push_back( - std::make_unique(problemeHebdo_, areas, true, false)); + post_process_list.push_back( std::make_unique(problemeHebdo_, areas, calendar)); post_process_list.push_back( diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index fb628d694d..7b48927363 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -70,25 +70,6 @@ void DispatchableMarginPostProcessCmd::execute(const optRuntimeData& opt_runtime }); } -// ----------------------------- -// Hydro levels update -// ----------------------------- -HydroLevelsUpdatePostProcessCmd::HydroLevelsUpdatePostProcessCmd(PROBLEME_HEBDO* problemeHebdo, - AreaList& areas, - bool remixWasRun, - bool computeAnyway): - basePostProcessCommand(problemeHebdo), - area_list_(areas), - remixWasRun_(remixWasRun), - computeAnyway_(computeAnyway) -{ -} - -void HydroLevelsUpdatePostProcessCmd::execute(const optRuntimeData&) -{ - computingHydroLevels(area_list_, *problemeHebdo_, remixWasRun_, computeAnyway_); -} - // ----------------------------- // Remix Hydro // ----------------------------- diff --git a/src/solver/simulation/adequacy.cpp b/src/solver/simulation/adequacy.cpp index eed49029e8..ca6a9b25bb 100644 --- a/src/solver/simulation/adequacy.cpp +++ b/src/solver/simulation/adequacy.cpp @@ -215,16 +215,12 @@ bool Adequacy::year(Progression::Task& progression, resultWriter, simulationObserver_.get()); - computingHydroLevels(study.areas, currentProblem, false); - RemixHydroForAllAreas(study.areas, currentProblem, study.parameters.shedding.policy, study.parameters.simplexOptimizationRange, numSpace, hourInTheYear); - - computingHydroLevels(study.areas, currentProblem, true); } catch (Data::AssertionError& ex) { @@ -329,8 +325,6 @@ bool Adequacy::year(Progression::Task& progression, .ConsommationAbattueDuPays[k]; } } - - computingHydroLevels(study.areas, currentProblem, false, true); } interpolateWaterValue(study.areas, currentProblem, study.calendar, hourInTheYear); diff --git a/src/solver/simulation/common-hydro-levels.cpp b/src/solver/simulation/common-hydro-levels.cpp index b0ba258b0e..3694da72f7 100644 --- a/src/solver/simulation/common-hydro-levels.cpp +++ b/src/solver/simulation/common-hydro-levels.cpp @@ -28,57 +28,6 @@ namespace Antares::Solver::Simulation { using Constants::nbHoursInAWeek; -void computingHydroLevels(const Data::AreaList& areas, - PROBLEME_HEBDO& problem, - bool remixWasRun, - bool computeAnyway) -{ - for (const auto& [_, area]: areas) - { - if (!area->hydro.reservoirManagement) - { - continue; - } - - if (!computeAnyway && area->hydro.useHeuristicTarget != remixWasRun) - { - continue; - } - - uint index = area->index; - - double reservoirCapacity = area->hydro.reservoirCapacity; - - std::vector& inflows = problem.CaracteristiquesHydrauliques[index] - .ApportNaturelHoraire; - - RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; - - std::vector& turb = weeklyResults.TurbinageHoraire; - - std::vector& pump = weeklyResults.PompageHoraire; - double pumpingRatio = area->hydro.pumpingEfficiency; - - double nivInit = problem.CaracteristiquesHydrauliques[index].NiveauInitialReservoir; - std::vector& niv = weeklyResults.niveauxHoraires; - - std::vector& ovf = weeklyResults.debordementsHoraires; - - computeTimeStepLevel - computeLvlObj(nivInit, inflows, ovf, turb, pumpingRatio, pump, reservoirCapacity); - - for (uint h = 0; h < nbHoursInAWeek - 1; h++) - { - computeLvlObj.run(); - niv[h] = computeLvlObj.getLevel() * 100 / reservoirCapacity; - computeLvlObj.prepareNextStep(); - } - - computeLvlObj.run(); - niv[nbHoursInAWeek - 1] = computeLvlObj.getLevel() * 100 / reservoirCapacity; - } -} - void interpolateWaterValue(const Data::AreaList& areas, PROBLEME_HEBDO& problem, const Date::Calendar& calendar, @@ -115,7 +64,7 @@ void interpolateWaterValue(const Data::AreaList& areas, double reservoirCapacity = area->hydro.reservoirCapacity; - std::vector& niv = weeklyResults.niveauxHoraires; + const std::vector& niv = weeklyResults.niveauxHoraires; waterVal[0] = Data::getWaterValue(problem.previousSimulationFinalLevel[index] * 100 / reservoirCapacity, @@ -140,14 +89,11 @@ void updatingWeeklyFinalHydroLevel(const Data::AreaList& areas, PROBLEME_HEBDO& continue; } - uint index = area->index; - - double reservoirCapacity = area->hydro.reservoirCapacity; - - RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; - - std::vector& niv = weeklyResults.niveauxHoraires; + const double reservoirCapacity = area->hydro.reservoirCapacity; + const uint index = area->index; + const RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; + const std::vector& niv = weeklyResults.niveauxHoraires; problem.previousSimulationFinalLevel[index] = niv[nbHoursInAWeek - 1] * reservoirCapacity / 100; } diff --git a/src/solver/simulation/include/antares/solver/simulation/common-eco-adq.h b/src/solver/simulation/include/antares/solver/simulation/common-eco-adq.h index 6a4dabd763..8f89b4998a 100644 --- a/src/solver/simulation/include/antares/solver/simulation/common-eco-adq.h +++ b/src/solver/simulation/include/antares/solver/simulation/common-eco-adq.h @@ -95,18 +95,6 @@ void RemixHydroForAllAreas(const Data::AreaList& areas, uint numSpace, uint hourInYear); -/* -** \brief Computing levels from hydro generation, natural and pumping inflows -** -** If hydro remix was not done yet, levels are computed only for areas for which we do not use the -*heuristic -** If hydro remix was done, levels are computed only for areas for which we use the heuristic -*/ -void computingHydroLevels(const Data::AreaList& areas, - PROBLEME_HEBDO& problem, - bool remixWasRun, - bool computeAnyway = false); - /* ** \brief Interpolates water values related to reservoir levels for outputs only ** diff --git a/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h b/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h index 26b8e837ef..506357e35e 100644 --- a/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h +++ b/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h @@ -302,7 +302,7 @@ struct ENERGIES_ET_PUISSANCES_HYDRAULIQUES bool TurbinageEntreBornes; bool SansHeuristique; - bool SuiviNiveauHoraire; + const bool SuiviNiveauHoraire = true; std::vector NiveauHoraireSup; std::vector NiveauHoraireInf; @@ -324,72 +324,6 @@ struct ENERGIES_ET_PUISSANCES_HYDRAULIQUES bounding constraint on final level*/ }; -class computeTimeStepLevel -{ -private: - int step; - double level; - - double capacity; - std::vector& inflows; - std::vector& ovf; - std::vector& turb; - double pumpRatio; - std::vector& pump; - double excessDown; - -public: - computeTimeStepLevel(const double& startLvl, - std::vector& infl, - std::vector& overfl, - std::vector& H, - double pumpEff, - std::vector& Pump, - double rc): - step(0), - level(startLvl), - capacity(rc), - inflows(infl), - ovf(overfl), - turb(H), - pumpRatio(pumpEff), - pump(Pump), - excessDown(0.) - { - } - - void run() - { - excessDown = 0.; - - level = level + inflows[step] - turb[step] + pumpRatio * pump[step] - ovf[step]; - - if (level > capacity) - { - level = capacity; - } - - if (level < 0) - { - excessDown = -level; - level = 0.; - inflows[step] += excessDown; - } - } - - void prepareNextStep() - { - step++; - - inflows[step] -= excessDown; - } - - double getLevel() - { - return level; - } -}; - struct RESERVE_JMOINS1 { std::vector ReserveHoraireJMoins1; @@ -494,6 +428,8 @@ struct PROBLEME_HEBDO std::vector CoutDeDefaillanceNegative; std::vector CoutDeDefaillanceEnReserve; + std::vector CoutDeDebordement; + std::vector PaliersThermiquesDuPays; std::vector CaracteristiquesHydrauliques; diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index 305d5fb31b..7d13891ec9 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -86,6 +86,8 @@ void SIM_AllocationProblemeDonneesGenerales(PROBLEME_HEBDO& problem, problem.CoutDeDefaillanceNegative.assign(nbPays, 0); problem.CoutDeDefaillanceEnReserve.assign(nbPays, 0); + problem.CoutDeDebordement.assign(nbPays, 0); + problem.NumeroDeContrainteEnergieHydraulique.assign(nbPays, 0); problem.NumeroDeContrainteMinEnergieHydraulique.assign(nbPays, 0); problem.NumeroDeContrainteMaxEnergieHydraulique.assign(nbPays, 0); diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index e14f85e945..bc45b3048b 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -152,6 +152,8 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, problem.CoutDeDefaillanceNegative[i] = area.thermal.spilledEnergyCost; + problem.CoutDeDebordement[i] = area.hydro.overflowCost; + problem.CoutDeDefaillanceEnReserve[i] = area.thermal.unsuppliedEnergyCost; problem.DefaillanceNegativeUtiliserPMinThermique[i] = (anoOtherDispatchPower @@ -183,17 +185,11 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, .useHeuristicTarget || area.hydro.useLeeway); - problem.CaracteristiquesHydrauliques[i].SuiviNiveauHoraire - = area.hydro.reservoirManagement && (problem.OptimisationAuPasHebdomadaire) - && (!area.hydro.useHeuristicTarget - || problem.CaracteristiquesHydrauliques[i].PresenceDePompageModulable); - problem.CaracteristiquesHydrauliques[i].DirectLevelAccess = false; problem.CaracteristiquesHydrauliques[i].AccurateWaterValue = false; if (problem.WaterValueAccurate && area.hydro.useWaterValue) { problem.CaracteristiquesHydrauliques[i].AccurateWaterValue = true; - problem.CaracteristiquesHydrauliques[i].SuiviNiveauHoraire = true; problem.CaracteristiquesHydrauliques[i].DirectLevelAccess = true; }