-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding constraints on injection-witdrawal cumulation with constant RH…
…S [ANT-1885] (#2535) This pull request introduces new functionality for handling additional constraints in the short-term storage component of the Antares Simulator. The changes include adding new files, modifying existing classes to support the new constraints, and updating the build configuration to include the new files. Below are the most important changes: ### New Functionality for Additional Constraints * Added `AdditionalConstraint` structure and related methods to handle validation and storage of constraints. (`src/libs/antares/study/include/antares/study/parts/short-term-storage/AdditionalConstraint.h`, [src/libs/antares/study/include/antares/study/parts/short-term-storage/AdditionalConstraint.hR1-R53](diffhunk://#diff-28f2057f7eba48ae42dec99b653d4022ea6604fa48a13ae8ac1b806315506e27R1-R53)) * Implemented methods to load additional constraints from an INI file and validate them. (`src/libs/antares/study/parts/short-term-storage/AdditionalConstraint.cpp`, [src/libs/antares/study/parts/short-term-storage/AdditionalConstraint.cppR1-R65](diffhunk://#diff-3621d191c85fb5b66bcbfeaf356663b248edc889bb73333496d195ab52e278f5R1-R65)) ### Modifications to Existing Classes * Updated `STStorageCluster` to include a vector of `AdditionalConstraint` objects and added necessary methods to handle these constraints. (`src/libs/antares/study/include/antares/study/parts/short-term-storage/cluster.h`, [src/libs/antares/study/include/antares/study/parts/short-term-storage/cluster.hR39-R54](diffhunk://#diff-bdfebe31db8d5e9aa119ac2793a107597bca647f65f399d1f408060f4e945ef9R39-R54)) * Modified `STStorageInput` to load constraints from an INI file and calculate the cumulative constraint count. (`src/libs/antares/study/include/antares/study/parts/short-term-storage/container.h`, [[1]](diffhunk://#diff-52dc8a33c0238cd4143e96739e689b64a1723f13f3d09a4aca5ac9f62f21b882R35-R57); `src/libs/antares/study/parts/short-term-storage/container.cpp`, [[2]](diffhunk://#diff-cec1ba69ce05b7ff57b2fa19d1fd601b94db222e9fdd0b784d6be9313ce4f790R78-R154) [[3]](diffhunk://#diff-cec1ba69ce05b7ff57b2fa19d1fd601b94db222e9fdd0b784d6be9313ce4f790R195-R203) ### Build Configuration Updates * Updated `CMakeLists.txt` to include new header and source files for additional constraints. (`src/libs/antares/study/CMakeLists.txt`, [[1]](diffhunk://#diff-8710cc094e1d5a6f4a53b07116cd0d335fe1efb285e154dcd5b3a3c297079647R105-R107); `src/solver/optimisation/CMakeLists.txt`, [[2]](diffhunk://#diff-8d1079b5acad0fbdef8bc452ff03744eae4089d018b72461e91e31eba16ec714R85-R87) ### Solver Integration * Integrated the handling of additional constraints into the solver's optimization process by adding new methods and including the necessary headers. (`src/solver/optimisation/constraints/Group1.cpp`, [[1]](diffhunk://#diff-819577c61bf6475f45b1df04e74fb7d665c6fc52c36f3484a1a0dc1c0421facdR25) [[2]](diffhunk://#diff-819577c61bf6475f45b1df04e74fb7d665c6fc52c36f3484a1a0dc1c0421facdR53-R59) [[3]](diffhunk://#diff-819577c61bf6475f45b1df04e74fb7d665c6fc52c36f3484a1a0dc1c0421facdR100-R104) [[4]](diffhunk://#diff-819577c61bf6475f45b1df04e74fb7d665c6fc52c36f3484a1a0dc1c0421facdR139-R143) ### Runtime Information * Enhanced `StudyRuntimeInfos` to include cumulative constraint counts for short-term storage. (`src/libs/antares/study/runtime/runtime.h`, [[1]](diffhunk://#diff-458433d2f769bbbcbc330ee42ec7258665121c44c7971082cfda8f95bae3b029R113); `src/libs/antares/study/runtime/runtime.cpp`, [[2]](diffhunk://#diff-c5ee413f02cb61b2ec6d93145fcd7254e1d566a391a7ffccf66da9851fc8e746R97-R98) [[3]](diffhunk://#diff-c5ee413f02cb61b2ec6d93145fcd7254e1d566a391a7ffccf66da9851fc8e746R368-R369) These changes collectively add support for additional constraints in the short-term storage component, ensuring they are loaded, validated, and integrated into the simulation and optimization processes. --------- Co-authored-by: Florian Omnès <[email protected]>
- Loading branch information
Showing
24 changed files
with
546 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/libs/antares/study/include/antares/study/parts/short-term-storage/AdditionalConstraint.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2007-2024, RTE (https://www.rte-france.com) | ||
* See AUTHORS.txt | ||
* SPDX-License-Identifier: MPL-2.0 | ||
* This file is part of Antares-Simulator, | ||
* Adequacy and Performance assessment for interconnected energy networks. | ||
* | ||
* Antares_Simulator is free software: you can redistribute it and/or modify | ||
* it under the terms of the Mozilla Public Licence 2.0 as published by | ||
* the Mozilla Foundation, either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Antares_Simulator is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Mozilla Public Licence 2.0 for more details. | ||
* | ||
* You should have received a copy of the Mozilla Public Licence 2.0 | ||
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>. | ||
*/ | ||
|
||
#pragma once | ||
#include <set> | ||
#include <string> | ||
|
||
namespace Antares::Data::ShortTermStorage | ||
{ | ||
|
||
struct AdditionalConstraint | ||
{ | ||
std::string name; | ||
std::string cluster_id; | ||
std::string variable; | ||
std::string operatorType; | ||
std::set<int> hours; | ||
double rhs; | ||
|
||
unsigned int globalIndex = 0; | ||
|
||
struct ValidateResult | ||
{ | ||
bool ok; | ||
std::string error_msg; | ||
}; | ||
|
||
ValidateResult validate() const; | ||
|
||
private: | ||
bool isValidVariable() const; | ||
bool isValidOperatorType() const; | ||
bool isValidHoursRange() const; | ||
}; | ||
} // namespace Antares::Data::ShortTermStorage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/libs/antares/study/parts/short-term-storage/AdditionalConstraint.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
** Copyright 2007-2024, RTE (https://www.rte-france.com) | ||
** See AUTHORS.txt | ||
** SPDX-License-Identifier: MPL-2.0 | ||
** This file is part of Antares-Simulator, | ||
** Adequacy and Performance assessment for interconnected energy networks. | ||
** | ||
** Antares_Simulator is free software: you can redistribute it and/or modify | ||
** it under the terms of the Mozilla Public Licence 2.0 as published by | ||
** the Mozilla Foundation, either version 2 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Antares_Simulator is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** Mozilla Public Licence 2.0 for more details. | ||
** | ||
** You should have received a copy of the Mozilla Public Licence 2.0 | ||
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>. | ||
*/ | ||
#include "antares/study/parts/short-term-storage/AdditionalConstraint.h" | ||
|
||
namespace Antares::Data::ShortTermStorage | ||
{ | ||
AdditionalConstraint::ValidateResult AdditionalConstraint::validate() const | ||
{ | ||
if (cluster_id.empty()) | ||
{ | ||
return {false, "Cluster ID is empty."}; | ||
} | ||
|
||
if (!isValidVariable()) | ||
{ | ||
return {false, "Invalid variable type. Must be 'injection', 'withdrawal', or 'netting'."}; | ||
} | ||
|
||
if (!isValidOperatorType()) | ||
{ | ||
return {false, "Invalid operator type. Must be 'less', 'equal', or 'greater'."}; | ||
} | ||
|
||
if (!isValidHoursRange()) | ||
{ | ||
return {false, "Hours set contains invalid values. Must be between 1 and 168."}; | ||
} | ||
|
||
return {true, ""}; | ||
} | ||
|
||
bool AdditionalConstraint::isValidHoursRange() const | ||
{ | ||
// `hours` is a sorted set; begin() gives the smallest and prev(end()) gives the largest. | ||
return !hours.empty() && *hours.begin() >= 1 && *std::prev(hours.end()) <= 168; | ||
} | ||
|
||
bool AdditionalConstraint::isValidVariable() const | ||
{ | ||
return variable == "injection" || variable == "withdrawal" || variable == "netting"; | ||
} | ||
|
||
bool AdditionalConstraint::isValidOperatorType() const | ||
{ | ||
return operatorType == "less" || operatorType == "equal" || operatorType == "greater"; | ||
} | ||
} // namespace Antares::Data::ShortTermStorage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.