Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement latest CSR comments #825

Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dd54bd4
Bump to CXX 17
flomnes Jul 15, 2022
5a9254e
Clarify execution-info.ini file
flomnes Aug 16, 2022
7d29b55
Merge pull request #65 from rte-i/feature/issue64-milos
Milos-RTEi Aug 18, 2022
c1054c2
Merge remote-tracking branch 'upstream/feature/csr-merge-develop' int…
Milos-RTEi Aug 22, 2022
919fc6a
1. Make NumberOfVariables a reference var
Milos-RTEi Aug 22, 2022
653af41
change function name CSR_DEBUG_
Milos-RTEi Aug 22, 2022
d593fb2
3. test Probleme.ExistenceDUneSolution directly
Milos-RTEi Aug 22, 2022
eda86bd
2. Slightly clearer version
Milos-RTEi Aug 22, 2022
3525d44
4. make hoursRequiringCurtailmentSharing const var
Milos-RTEi Aug 22, 2022
15e10dd
5. avoid cast sumENS[i] to int!
Milos-RTEi Aug 22, 2022
65caf6e
17. move default thresholds to adequacy_patch.h
Milos-RTEi Aug 22, 2022
6df6a4e
20. use A.size() in addArray function
Milos-RTEi Aug 22, 2022
90c6f0b
19. create dedicated method solveCSR
Milos-RTEi Aug 22, 2022
5352870
7. name change
Milos-RTEi Aug 22, 2022
7086560
8. make methods of AdequacyPatchOptimization private
Milos-RTEi Aug 22, 2022
5bdbd35
11. 14. 16 delete unused logs
Milos-RTEi Aug 22, 2022
cca06c7
9. delete forward declaration of HOURLY_CSR_PROBLEM
Milos-RTEi Aug 22, 2022
e513d85
Merge pull request #803 from AntaresSimulatorTeam/fix/execution-info-…
flomnes Aug 22, 2022
ab253ad
15. remove Double definition.
Milos-RTEi Aug 22, 2022
363208c
12. 13 update copyright & Authors for adq-patch files
Milos-RTEi Aug 22, 2022
97fb7e7
Merge pull request #779 from AntaresSimulatorTeam/feature/cxx-17
flomnes Aug 23, 2022
3b4c181
Fix missing renewable columns in districts (sets of areas) (#802)
flomnes Aug 23, 2022
ac4f7f4
execution_info.ini : add OR-Tools used & solver (#820)
flomnes Aug 23, 2022
5a9ee2f
Fix wrong number of cores + code de-duplication (#793)
flomnes Aug 23, 2022
713f167
Release/8.3.1 (#818)
flomnes Aug 23, 2022
d6fbef8
Merge pull request #68 from rte-i/feature/issue66-milos
Milos-RTEi Aug 24, 2022
be94993
Merge pull request #67 from rte-i/feature/keep-track-with-rte-develop
Milos-RTEi Aug 24, 2022
2ffb5b7
Merge remote-tracking branch 'origin/develop' into feature/adq-patch-4
Milos-RTEi Aug 24, 2022
b4ad703
make solveCSR private method
Milos-RTEi Aug 24, 2022
c865631
use auto instead of std::unique_ptr<PROBLEME_POINT_INTERIEUR>
Milos-RTEi Aug 24, 2022
20d0bd3
float->double
Milos-RTEi Aug 24, 2022
0164441
remove saveIntermediateResults
Milos-RTEi Aug 24, 2022
a5e6bd7
Merge pull request #70 from rte-i/feature/issue66-update
Milos-RTEi Aug 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/libs/antares/study/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,6 @@ enum AdqPatchPTO

}; // enum AdqPatchPTO

//! A default threshold value for initiate curtailment sharing rule
const float adqPatchDefaultValueThresholdInitiateCurtailmentSharingRule = 0.0;
//! A default threshold value for display local matching rule violations
const float adqPatchDefaultValueThresholdDisplayLocalMatchingRuleViolations = 0.0;

} // namespace AdequacyPatch
} // namespace Data
} // namespace Antares
Expand Down
5 changes: 3 additions & 2 deletions src/libs/antares/study/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <limits.h>
#include <antares/study/memory-usage.h>
#include "../solver/variable/economy/all.h"
#include "../solver/optimisation/adequacy_patch.h"

#include <antares/exception/AssertionError.hpp>
#include <antares/Enum.hxx>
Expand Down Expand Up @@ -237,9 +238,9 @@ void Parameters::resetThresholdsAdqPatch()
{
// Initialize all thresholds values for adequacy patch
adqPatch.curtailmentSharing.thresholdInitiate
= adqPatchDefaultValueThresholdInitiateCurtailmentSharingRule;
= defaultValueThresholdInitiateCurtailmentSharingRule;
adqPatch.curtailmentSharing.thresholdDisplayViolations
= adqPatchDefaultValueThresholdDisplayLocalMatchingRuleViolations;
= defaultValueThresholdDisplayLocalMatchingRuleViolations;
}

void Parameters::resetAdqPatchParameters()
Expand Down
10 changes: 5 additions & 5 deletions src/solver/optimisation/adequacy_patch.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
** Copyright 2007-2022 RTE
** Authors: RTE-international / Redstork / Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
Expand Down Expand Up @@ -136,7 +136,7 @@ void setNTCbounds(double& Xmax,

double checkLocalMatchingRuleViolations(PROBLEME_HEBDO* ProblemeHebdo, uint weekNb)
{
float threshold = ProblemeHebdo->adqPatchParams->ThresholdDisplayLocalMatchingRuleViolations;
double threshold = ProblemeHebdo->adqPatchParams->ThresholdDisplayLocalMatchingRuleViolations;
double netPositionInit;
double densNew;
double ensInit;
Expand Down Expand Up @@ -222,9 +222,9 @@ std::pair<double, double> calculateAreaFlowBalance(PROBLEME_HEBDO* ProblemeHebdo
return std::make_pair(netPositionInit, densNew);
}

void addArray(std::vector<double>& A, double* B, int num)
void addArray(std::vector<double>& A, double* B)
{
for (uint i = 0; i < num; ++i)
for (uint i = 0; i < A.size(); ++i)
A[i] += B[i];
}

Expand Down
11 changes: 7 additions & 4 deletions src/solver/optimisation/adequacy_patch.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
** Copyright 2007-2022 RTE
** Authors: RTE-international / Redstork / Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
Expand Down Expand Up @@ -37,6 +37,10 @@ namespace Data
{
namespace AdequacyPatch
{
//! A default threshold value for initiate curtailment sharing rule
const double defaultValueThresholdInitiateCurtailmentSharingRule = 0.0;
//! A default threshold value for display local matching rule violations
const double defaultValueThresholdDisplayLocalMatchingRuleViolations = 0.0;
/*!
* Determines restriction type for transmission links for first step of adequacy patch.
*
Expand Down Expand Up @@ -107,10 +111,9 @@ double checkLocalMatchingRuleViolations(PROBLEME_HEBDO* ProblemeHebdo, uint week
** **
** ** \param A A vector
** ** \param B An array
** ** \param num An integer
** ** \return
** */
void addArray(std::vector<double>& A, double* B, int num);
void addArray(std::vector<double>& A, double* B);

} // end namespace Antares
} // end namespace Data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
** Copyright 2007-2022 RTE
** Authors: RTE-international / Redstork / Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
** Copyright 2007-2022 RTE
** Authors: RTE-international / Redstork / Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
Expand Down Expand Up @@ -131,9 +131,6 @@ void setRHSbindingConstraintsValue(PROBLEME_HEBDO* ProblemeHebdo,
// 1. The original RHS of bingding constraint
SecondMembre[Cnt]
= MatriceDesContraintesCouplantes->SecondMembreDeLaContrainteCouplante[hour];
// logs.debug() << Cnt << ": Hourly bc: Existing-RHS[" << Cnt
// << "] = " << SecondMembre[Cnt] << " (CntCouplante = " << CntCouplante
// << ")";

// 2. RHS part 2: flow other than 2<->2
NbInterco
Expand All @@ -150,17 +147,6 @@ void setRHSbindingConstraintsValue(PROBLEME_HEBDO* ProblemeHebdo,
{
ValueOfFlow = ProblemeHebdo->ValeursDeNTC[hour]->ValeurDuFlux[Interco];
SecondMembre[Cnt] -= ValueOfFlow * Poids;
// logs.debug()
// << Cnt << ": Hourly bc: IntercoFlow-RHS[" << Cnt
// << "] = " << SecondMembre[Cnt] << " (CntCouplante = " << CntCouplante << ")"
// << ". Interco;" + std::to_string(Interco) << ". Between:["
// << ProblemeHebdo
// ->NomsDesPays[ProblemeHebdo->PaysOrigineDeLInterconnexion[Interco]]
// << "]-["
// << ProblemeHebdo
// ->NomsDesPays[ProblemeHebdo->PaysExtremiteDeLInterconnexion[Interco]]
// << "]"
// << ". ValueOfFlow: " << ValueOfFlow << ". Poids: " << Poids;
}
}

Expand Down Expand Up @@ -190,11 +176,6 @@ void setRHSbindingConstraintsValue(PROBLEME_HEBDO* ProblemeHebdo,
->ProductionThermiqueDuPalier[IndexNumeroDuPalierDispatch];

SecondMembre[Cnt] -= ValueOfVar * Poids;
// logs.debug() << Cnt << ": Hourly bc: ThermalCluster-RHS[" << Cnt
// << "] = " << SecondMembre[Cnt] << " (CntCouplante = " << CntCouplante
// << ")"
// << ". Area:" << Area << ", Palier:" << Palier << ", Poids" << Poids
// << ", ValueOfVar:" << ValueOfVar;
}
if (MatriceDesContraintesCouplantes->SensDeLaContrainteCouplante == '<')
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
** Copyright 2007-2022 RTE
** Authors: RTE-international / Redstork / Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
Expand Down Expand Up @@ -37,10 +37,11 @@

void constructVariableENS(PROBLEME_HEBDO* ProblemeHebdo, HOURLY_CSR_PROBLEM& hourlyCsrProblem)
{
int NumberOfVariables = 0;
int hour = hourlyCsrProblem.hourInWeekTriggeredCsr;
PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre;
ProblemeAResoudre = ProblemeHebdo->ProblemeAResoudre;
int& NumberOfVariables = ProblemeAResoudre->NombreDeVariables;
NumberOfVariables = 0;
CORRESPONDANCES_DES_VARIABLES* CorrespondanceVarNativesVarOptim;
CorrespondanceVarNativesVarOptim = ProblemeHebdo->CorrespondanceVarNativesVarOptim[hour];

Expand All @@ -62,7 +63,6 @@ void constructVariableENS(PROBLEME_HEBDO* ProblemeHebdo, HOURLY_CSR_PROBLEM& hou
NumberOfVariables++;
}
}
ProblemeAResoudre->NombreDeVariables = NumberOfVariables;
}

void constructVariableSpilledEnergy(PROBLEME_HEBDO* ProblemeHebdo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
** Copyright 2007-2022 RTE
** Authors: RTE-international / Redstork / Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
** Copyright 2007-2022 RTE
** Authors: RTE-international / Redstork / Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
Expand Down
74 changes: 38 additions & 36 deletions src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
** Copyright 2007-2022 RTE
** Authors: RTE-international / Redstork / Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
Expand Down Expand Up @@ -55,9 +55,10 @@ extern "C"

using namespace Antares;

void setInteriorPointProblem(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre,
PROBLEME_POINT_INTERIEUR& Probleme)
std::unique_ptr<PROBLEME_POINT_INTERIEUR> buildInteriorPointProblem(
PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre)
{
std::unique_ptr<PROBLEME_POINT_INTERIEUR> Probleme(new PROBLEME_POINT_INTERIEUR());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::unique_ptr<PROBLEME_POINT_INTERIEUR> Probleme(new PROBLEME_POINT_INTERIEUR());
auto Probleme = std::make_unique<PROBLEME_POINT_INTERIEUR>();

You need to merge branch develop for that, since it contains #779. This feature is only available from C++17.

int ChoixToleranceParDefautSurLAdmissibilite;
int ChoixToleranceParDefautSurLaStationnarite;
int ChoixToleranceParDefautSurLaComplementarite;
Expand All @@ -66,40 +67,42 @@ void setInteriorPointProblem(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre,
ChoixToleranceParDefautSurLaStationnarite = OUI_PI;
ChoixToleranceParDefautSurLaComplementarite = OUI_PI;

Probleme.NombreMaxDIterations = -1;
Probleme.CoutQuadratique = ProblemeAResoudre->CoutQuadratique;
Probleme.CoutLineaire = ProblemeAResoudre->CoutLineaire;
Probleme.X = ProblemeAResoudre->X;
Probleme.Xmin = ProblemeAResoudre->Xmin;
Probleme.Xmax = ProblemeAResoudre->Xmax;
Probleme.NombreDeVariables = ProblemeAResoudre->NombreDeVariables;
Probleme.TypeDeVariable = ProblemeAResoudre->TypeDeVariable;

Probleme.VariableBinaire = (char*)ProblemeAResoudre->CoutsReduits;

Probleme.NombreDeContraintes = ProblemeAResoudre->NombreDeContraintes;
Probleme.IndicesDebutDeLigne = ProblemeAResoudre->IndicesDebutDeLigne;
Probleme.NombreDeTermesDesLignes = ProblemeAResoudre->NombreDeTermesDesLignes;
Probleme.IndicesColonnes = ProblemeAResoudre->IndicesColonnes;
Probleme.CoefficientsDeLaMatriceDesContraintes
Probleme->NombreMaxDIterations = -1;
Probleme->CoutQuadratique = ProblemeAResoudre->CoutQuadratique;
Probleme->CoutLineaire = ProblemeAResoudre->CoutLineaire;
Probleme->X = ProblemeAResoudre->X;
Probleme->Xmin = ProblemeAResoudre->Xmin;
Probleme->Xmax = ProblemeAResoudre->Xmax;
Probleme->NombreDeVariables = ProblemeAResoudre->NombreDeVariables;
Probleme->TypeDeVariable = ProblemeAResoudre->TypeDeVariable;

Probleme->VariableBinaire = (char*)ProblemeAResoudre->CoutsReduits;

Probleme->NombreDeContraintes = ProblemeAResoudre->NombreDeContraintes;
Probleme->IndicesDebutDeLigne = ProblemeAResoudre->IndicesDebutDeLigne;
Probleme->NombreDeTermesDesLignes = ProblemeAResoudre->NombreDeTermesDesLignes;
Probleme->IndicesColonnes = ProblemeAResoudre->IndicesColonnes;
Probleme->CoefficientsDeLaMatriceDesContraintes
= ProblemeAResoudre->CoefficientsDeLaMatriceDesContraintes;
Probleme.Sens = ProblemeAResoudre->Sens;
Probleme.SecondMembre = ProblemeAResoudre->SecondMembre;
Probleme->Sens = ProblemeAResoudre->Sens;
Probleme->SecondMembre = ProblemeAResoudre->SecondMembre;

Probleme.AffichageDesTraces = NON_PI;
Probleme->AffichageDesTraces = NON_PI;

Probleme.UtiliserLaToleranceDAdmissibiliteParDefaut = ChoixToleranceParDefautSurLAdmissibilite;
Probleme->UtiliserLaToleranceDAdmissibiliteParDefaut = ChoixToleranceParDefautSurLAdmissibilite;

Probleme.UtiliserLaToleranceDeStationnariteParDefaut
Probleme->UtiliserLaToleranceDeStationnariteParDefaut
= ChoixToleranceParDefautSurLaStationnarite;

Probleme.UtiliserLaToleranceDeComplementariteParDefaut
Probleme->UtiliserLaToleranceDeComplementariteParDefaut
= ChoixToleranceParDefautSurLaComplementarite;

Probleme.CoutsMarginauxDesContraintes = ProblemeAResoudre->CoutsMarginauxDesContraintes;
Probleme->CoutsMarginauxDesContraintes = ProblemeAResoudre->CoutsMarginauxDesContraintes;

Probleme.CoutsMarginauxDesContraintesDeBorneInf = ProblemeAResoudre->CoutsReduits;
Probleme.CoutsMarginauxDesContraintesDeBorneSup = ProblemeAResoudre->CoutsReduits;
Probleme->CoutsMarginauxDesContraintesDeBorneInf = ProblemeAResoudre->CoutsReduits;
Probleme->CoutsMarginauxDesContraintesDeBorneSup = ProblemeAResoudre->CoutsReduits;

return Probleme;
}

void setToZeroIfBelowThreshold(double* pt, int Var, HOURLY_CSR_PROBLEM& hourlyCsrProblem)
Expand Down Expand Up @@ -128,7 +131,7 @@ void storeInteriorPointResults(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre,
}
}

void CSR_DEBUG_BLAH(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre)
void CSR_DEBUG_HANDLE(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre)
{
int Var;

Expand Down Expand Up @@ -177,7 +180,7 @@ void handleInteriorPointError(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre,
<< ". hour: " << weekNb * hoursInWeek + hourlyCsrProblem.hourInWeekTriggeredCsr + 1;

#ifndef NDEBUG
CSR_DEBUG_BLAH(ProblemeAResoudre);
CSR_DEBUG_HANDLE(ProblemeAResoudre);
#endif
}

Expand All @@ -186,11 +189,10 @@ bool ADQ_PATCH_CSR(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre,
uint weekNb,
int yearNb)
{
PROBLEME_POINT_INTERIEUR Probleme;
setInteriorPointProblem(ProblemeAResoudre, Probleme);
PI_Quamin(&Probleme); // resolution
ProblemeAResoudre->ExistenceDUneSolution = Probleme.ExistenceDUneSolution;
if (ProblemeAResoudre->ExistenceDUneSolution == OUI_PI)
std::unique_ptr<PROBLEME_POINT_INTERIEUR> Probleme
= buildInteriorPointProblem(ProblemeAResoudre);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::unique_ptr<PROBLEME_POINT_INTERIEUR> Probleme
= buildInteriorPointProblem(ProblemeAResoudre);
auto Probleme
= buildInteriorPointProblem(ProblemeAResoudre);

PI_Quamin(Probleme.get()); // resolution
if (Probleme->ExistenceDUneSolution == OUI_PI)
{
storeInteriorPointResults(ProblemeAResoudre, hourlyCsrProblem);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
*/

const double csrSolverRelaxationRHS = 1e-3;

#include "opt_structure_probleme_a_resoudre.h"

#include "../simulation/simulation.h"
Expand Down
Loading