-
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.
Refactor constraint construction (#1627)
* start * add FictitiousLoad * shortTermStorageLevel * flowDissociation * bindingConstraintHour * ghost * this is not only about constraint builder * pay attention to the time step * specific issue * bug free * smooth green? * M&M * Max Pumping ok? * Area Hydro Level (_-_) * finally * basic * tiny * clean code * add {PMin,PMax}DispatchableGeneration * clean code * ConsistenceNODU ok * NbUnitsOutageLessThanNbUnitsStop * NbDispUnitsMinBoundSinceMinUpTime * MinDownTime * setup Access Control * remove comments * remove comments * treat major code smells * treat major code smells 2 * more on major code smells * update after review * about objects lifetime * (does not compile) cut into small pieces * Revert "(does not compile) cut into small pieces" This reverts commit 5a047c0. * aesthetic * remove comment * smart move * **** move * shallow * customize error exception * work on "group 1" * fix * update * small * group of constraint * from free function to class (LinearProblemMatrixBuilder) * update LinearProblemMatrixBuilder class * fix * continue to group * implement week binding constraints group * add HydroPowerGroup * builder as ctor parameter * builder as ctor parameter * clean * int is not a bool * add Hydro Smoothing group * MinMaxHydroPowerGroup * rename * new MaxPumpingGroup * AreaHydroLevelGroup * new FictitiousLoad * New ShortTermStorageLevel * New FlowDissociation * NEw BindingConstraintHour * delete copies * New BindingConstraintDay * about includes * New BindingConstraintWeek * includes... * HydroPower * include....... * new HydroPowerSmoothingUsingVariationSum * new HydroPowerSmoothingUsingVariationMaxDown * new HydroPowerSmoothingUsingVariationMaxUP * MinHydroPower * MaxHydroPower * MaxPumping * new AreaHydroLevel * setup FinalStockGroup * fix * shrink method: linear problem run * decomposition * remove duplicated includes * update * make FinalStockGroup is built * merge conflict fix * new P{Min, Max}DispatchableGeneration & PMinMaxDispatchableGenerationGroup * renew StartUpCosts * add NbUnitsOutageLessThanNbUnitsStopGroup * minuptime * remove copy error * new LinearProblemMatrixStartUpCosts * fix * fix 2 * update CmakeLists.txt * fix * include errors * fix read-write data * add documentation * add doc for StartUpCosts group of constraints * remove deprecated * work on CsrQuadraticProblem / CsrFlowDissociation * missing include * Update CsrFlowDissociation.h * get rid of old code * inline function * CsrAreaBalance new way & rename * fix : CsrAreaBalance = Group * logic issue * fix doubled NegativeUnsuppliedEnergy * 🐍 CsrBindingConstraintHour 💥 * method call syntax * remove old logs * remove old code * update QuadraticProblemMatrix * remove copy error * ; * unused params * add return type * it's 🏃 * update * fix * remove old Style Constraint Builder * ConstraintBuilder is the New ConstraintBuilder * rename file * rename classes * keep renaming * rename new_exportPaliers * transform shared_ptr data to ref: first try * FictitiousLoadData as ref * shortTermStorageLevelData 💾 * FlowDissociationData * BindingConstraintHourData * bindingConstraintDayData * BindingConstraintWeekData * HydroPowerData * Min/Max/HydroPowerData * MaxPumpingData * AreaHydroLevelData * data as ctor parameter * perf issue * fix perf issue * small change * updates * about FlowDissociationData * optimized loop in bindingConstraintHour * remove empty line * continue refactor * re-work binding Constraint Week Data * move HydroPowerData to ctor * set data once for {Min, Max}HydroPower * skip windows & sonar * same for MaxPumping * we're ok AreaHydroLevelGroup * ok FinalStockGroup * fix * update StartUpCosts Group * fix constraint index * changes * CsrAreaBalance * no shared_ptr of data anymore! * test MinDownTime elsewhere * test NbDispUnitsMinBoundSinceMinUpTime out of it's inner loop * test NbUnitsOutageLessThanNbUnitsStop out of it's inner loop * big one * shared???? * reactivate w&s * reshape constraint construction (#1815) * rename method * rename with respect to the default style * remove default parameters * fix * update * fix * ShortTermStorageLevel specific case * NTC fix * . * @guilpier-code's remark * typo * from PR * move unrelated jobs from LinearProblemMatrix
- Loading branch information
Showing
114 changed files
with
2,381 additions
and
1,275 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
** Copyright 2007-2023 RTE | ||
** Authors: Antares_Simulator Team | ||
** | ||
** This file is part of Antares_Simulator. | ||
** | ||
** Antares_Simulator is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** There are special exceptions to the terms and conditions of the | ||
** license as they are applied to this software. View the full text of | ||
** the exceptions in file COPYING.txt in the directory of this software | ||
** distribution | ||
** | ||
** 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 | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions | ||
*/ | ||
|
||
#include "LinearProblemMatrix.h" | ||
#include "opt_export_structure.h" | ||
#include "antares/solver/utils/filename.h" | ||
#include "opt_fonctions.h" | ||
#include "LinearProblemMatrixStartUpCosts.h" | ||
|
||
using namespace Antares::Data; | ||
|
||
LinearProblemMatrix::LinearProblemMatrix(PROBLEME_HEBDO* problemeHebdo, | ||
ConstraintBuilder& builder) : | ||
ProblemMatrixEssential(problemeHebdo), | ||
builder_(builder), | ||
group1_(problemeHebdo, builder), | ||
bindingConstraintDayGroup_(problemeHebdo, builder), | ||
bindingConstraintWeekGroup_(problemeHebdo, builder), | ||
hydroPowerGroup_(problemeHebdo, builder), | ||
hydraulicSmoothingGroup_(problemeHebdo, builder), | ||
minMaxHydroPowerGroup_(problemeHebdo, builder), | ||
maxPumpingGroup_(problemeHebdo, builder), | ||
areaHydroLevelGroup_(problemeHebdo, builder), | ||
finalStockGroup_(problemeHebdo, builder) | ||
{ | ||
constraintgroups_ = {&group1_, | ||
&bindingConstraintDayGroup_, | ||
&bindingConstraintWeekGroup_, | ||
&hydroPowerGroup_, | ||
&hydraulicSmoothingGroup_, | ||
&minMaxHydroPowerGroup_, | ||
&maxPumpingGroup_, | ||
&areaHydroLevelGroup_, | ||
&finalStockGroup_}; | ||
} | ||
|
||
void LinearProblemMatrix::Run() | ||
{ | ||
InitializeProblemAResoudreCounters(); | ||
|
||
ProblemMatrixEssential::Run(); | ||
|
||
if (problemeHebdo_->OptimisationAvecCoutsDeDemarrage) | ||
{ | ||
LinearProblemMatrixStartUpCosts(problemeHebdo_, false, builder_).Run(); | ||
} | ||
|
||
return; | ||
} |
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,63 @@ | ||
/* | ||
** Copyright 2007-2023 RTE | ||
** Authors: Antares_Simulator Team | ||
** | ||
** This file is part of Antares_Simulator. | ||
** | ||
** Antares_Simulator is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** There are special exceptions to the terms and conditions of the | ||
** license as they are applied to this software. View the full text of | ||
** the exceptions in file COPYING.txt in the directory of this software | ||
** distribution | ||
** | ||
** 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 | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions | ||
*/ | ||
#pragma once | ||
#include "opt_structure_probleme_a_resoudre.h" | ||
#include "sim_structure_probleme_economique.h" | ||
#include "ProblemMatrixEssential.h" | ||
#include "constraints/ConstraintGroup.h" | ||
#include "constraints/Group1.h" | ||
#include "constraints/BindingConstraintDayGroup.h" | ||
#include "constraints/BindingConstraintWeekGroup.h" | ||
#include "constraints/HydroPowerGroup.h" | ||
#include "constraints/HydraulicSmoothingGroup.h" | ||
#include "constraints/MinMaxHydroPowerGroup.h" | ||
#include "constraints/MaxPumpingGroup.h" | ||
#include "constraints/AreaHydroLevelGroup.h" | ||
#include "constraints/FinalStockGroup.h" | ||
|
||
#include <antares/study/study.h> | ||
|
||
using namespace Antares::Data; | ||
class LinearProblemMatrix : public ProblemMatrixEssential | ||
{ | ||
public: | ||
explicit LinearProblemMatrix(PROBLEME_HEBDO* problemeHebdo, ConstraintBuilder& builder); | ||
|
||
void Run() override; | ||
|
||
private: | ||
ConstraintBuilder& builder_; | ||
Group1 group1_; | ||
BindingConstraintDayGroup bindingConstraintDayGroup_; | ||
BindingConstraintWeekGroup bindingConstraintWeekGroup_; | ||
HydroPowerGroup hydroPowerGroup_; | ||
HydraulicSmoothingGroup hydraulicSmoothingGroup_; | ||
MinMaxHydroPowerGroup minMaxHydroPowerGroup_; | ||
MaxPumpingGroup maxPumpingGroup_; | ||
AreaHydroLevelGroup areaHydroLevelGroup_; | ||
FinalStockGroup finalStockGroup_; | ||
}; |
47 changes: 47 additions & 0 deletions
47
src/solver/optimisation/LinearProblemMatrixStartUpCosts.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,47 @@ | ||
/* | ||
** Copyright 2007-2023 RTE | ||
** Authors: Antares_Simulator Team | ||
** | ||
** This file is part of Antares_Simulator. | ||
** | ||
** Antares_Simulator is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** There are special exceptions to the terms and conditions of the | ||
** license as they are applied to this software. View the full text of | ||
** the exceptions in file COPYING.txt in the directory of this software | ||
** distribution | ||
** | ||
** 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 | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions | ||
*/ | ||
#pragma once | ||
#include "LinearProblemMatrixStartUpCosts.h" | ||
using namespace Antares::Data; | ||
|
||
LinearProblemMatrixStartUpCosts::LinearProblemMatrixStartUpCosts(PROBLEME_HEBDO* problemeHebdo, | ||
bool Simulation, | ||
ConstraintBuilder& builder) : | ||
ProblemMatrixEssential(problemeHebdo), | ||
simulation_(Simulation), | ||
pMinMaxDispatchableGenerationGroup_(problemeHebdo, simulation_, builder), | ||
consistenceNumberOfDispatchableUnitsGroup_(problemeHebdo, simulation_, builder), | ||
nbUnitsOutageLessThanNbUnitsStopGroup_(problemeHebdo, simulation_, builder), | ||
nbDispUnitsMinBoundSinceMinUpTimeGroup_(problemeHebdo, simulation_, builder), | ||
minDownTimeGroup_(problemeHebdo, simulation_, builder) | ||
{ | ||
constraintgroups_ = {&pMinMaxDispatchableGenerationGroup_, | ||
&consistenceNumberOfDispatchableUnitsGroup_, | ||
&nbUnitsOutageLessThanNbUnitsStopGroup_, | ||
&nbDispUnitsMinBoundSinceMinUpTimeGroup_, | ||
&minDownTimeGroup_}; | ||
} |
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,58 @@ | ||
/* | ||
** Copyright 2007-2023 RTE | ||
** Authors: Antares_Simulator Team | ||
** | ||
** This file is part of Antares_Simulator. | ||
** | ||
** Antares_Simulator is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** There are special exceptions to the terms and conditions of the | ||
** license as they are applied to this software. View the full text of | ||
** the exceptions in file COPYING.txt in the directory of this software | ||
** distribution | ||
** | ||
** 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 | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions | ||
*/ | ||
#pragma once | ||
#include "opt_structure_probleme_a_resoudre.h" | ||
#include "sim_structure_probleme_economique.h" | ||
#include "constraints/ConstraintGroup.h" | ||
#include "ProblemMatrixEssential.h" | ||
#include "opt_structure_probleme_a_resoudre.h" | ||
|
||
#include "constraints/PMinMaxDispatchableGenerationGroup.h" | ||
#include "constraints/ConsistenceNumberOfDispatchableUnitsGroup.h" | ||
#include "constraints/NbUnitsOutageLessThanNbUnitsStopGroup.h" | ||
#include "constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.h" | ||
#include "constraints/MinDownTimeGroup.h" | ||
|
||
#include <antares/study/study.h> | ||
|
||
using namespace Antares::Data; | ||
|
||
class LinearProblemMatrixStartUpCosts : public ProblemMatrixEssential | ||
{ | ||
public: | ||
explicit LinearProblemMatrixStartUpCosts(PROBLEME_HEBDO* problemeHebdo, | ||
bool Simulation, | ||
ConstraintBuilder& builder); | ||
|
||
private: | ||
bool simulation_ = false; | ||
PMinMaxDispatchableGenerationGroup pMinMaxDispatchableGenerationGroup_; | ||
ConsistenceNumberOfDispatchableUnitsGroup consistenceNumberOfDispatchableUnitsGroup_; | ||
NbUnitsOutageLessThanNbUnitsStopGroup nbUnitsOutageLessThanNbUnitsStopGroup_; | ||
NbDispUnitsMinBoundSinceMinUpTimeGroup nbDispUnitsMinBoundSinceMinUpTimeGroup_; | ||
MinDownTimeGroup minDownTimeGroup_; | ||
}; |
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,47 @@ | ||
/* | ||
** Copyright 2007-2023 RTE | ||
** Authors: Antares_Simulator Team | ||
** | ||
** This file is part of Antares_Simulator. | ||
** | ||
** Antares_Simulator is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** There are special exceptions to the terms and conditions of the | ||
** license as they are applied to this software. View the full text of | ||
** the exceptions in file COPYING.txt in the directory of this software | ||
** distribution | ||
** | ||
** 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 | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions | ||
*/ | ||
#include "ProblemMatrixEssential.h" | ||
|
||
ProblemMatrixEssential::ProblemMatrixEssential(PROBLEME_HEBDO* problemeHebdo) : | ||
problemeHebdo_(problemeHebdo) | ||
{ | ||
} | ||
|
||
void ProblemMatrixEssential::Run() | ||
{ | ||
for (auto& group : constraintgroups_) | ||
{ | ||
group->BuildConstraints(); | ||
} | ||
} | ||
|
||
void ProblemMatrixEssential::InitializeProblemAResoudreCounters() | ||
{ | ||
auto& ProblemeAResoudre = problemeHebdo_->ProblemeAResoudre; | ||
ProblemeAResoudre->NombreDeContraintes = 0; | ||
ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes = 0; | ||
} |
Oops, something went wrong.