Skip to content

Commit

Permalink
compiled work on determinism
Browse files Browse the repository at this point in the history
Signed-off-by: arnaud <[email protected]>
  • Loading branch information
ARnDOSrte committed Nov 30, 2023
1 parent 2334614 commit b7ab09d
Show file tree
Hide file tree
Showing 220 changed files with 2,629 additions and 618 deletions.
4 changes: 3 additions & 1 deletion metrix-simulator/etc/METRIX.dic
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ ERRPremiereVarIntrouvable Le numéro de la première variante est introuvabl
ERRFormatNombre Format de nombre incorrect : '$2' pour la loi $1
ERRRegionIntrouvable La région '$1' de la loi $2 est introuvable
ERRGroupeIntrouvable Le groupe '$1' de la loi $2 est introuvable
ERRTDPriseIntrouvable Pour le td '$1' la prise souhaitée $2 est introuvable pour la variante $3
ERRTDPriseIntrouvable Pour le td '$1' la prise souhaitée $2 est introuvable pour la variante '$3'
ERRTDIntrouvable Le td '$1' est introuvable pour la variante '$2'
ERRNoeudConsoIntrouvable Le noeud '$1' de la loi $2 de variation de conso est introuvable
ERRQuadIntrouvable La ligne '$1' de la loi $2:$3 est introuvable
ERRConsoIntrouvable La consommation '$1' de la loi $2 pour la variante $3 est introuvable
ERRIncidentIntrouvable L'incident '$1' de la loi $2 pour la variante $3 est introuvable
ERRElemCurIntrouvable L'élément curatif '$1' de l'incident '$2' en variante $3 est introuvable
ERRTypeLoiInconnu Le type de loi $1 est inconnu
ERRPasDeconsoSurNoeud Il n'y a pas de conso sur le noeud $1
ERRApplLoiBilanGrpNonImp Erreur sur l'application de la variante de bilan, le groupe $1 n etant pas impose
Expand Down
2 changes: 2 additions & 0 deletions metrix-simulator/etc/METRIX_En.dic
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ ERRGroupeIntrouvable Production unit '$1' in law $2 cannot be found
ERRTDPriseIntrouvable For PST '$1' required tap $2 cannot be found for variant $3
ERRNoeudConsoIntrouvable Node '$1' in load variation law number $2 cannot be found
ERRIncidentIntrouvable Outage id '$1' in variation law $2 for variant $3 cannot be found
ERRTDIntrouvable The td '$1' cannot be found in variant '$2'
ERRElemCurIntrouvable CurativeElement '$1' of incident '$2' in variant $3 cannot be found
ERRQuadIntrouvable Line '$1' in law $2:$3 cannot be found
ERRConsoIntrouvable Load id '$1' in variation law $2 for variant $3 cannot be found
ERRTypeLoiInconnu Law type $1 is unknown
Expand Down
9 changes: 5 additions & 4 deletions metrix-simulator/src/calcul.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class Calculer
int getClosestTapPosition(TransformateurDephaseur* td, double angleFinal);
bool calculVariationsMarginales(FILE* fr, const std::map<std::shared_ptr<Incident>, int>& incidentsContraignants);
static double round(double x, double prec); // utiliser pour arrondir les calculs
static double cutDecimals(double x); //utilisé quand le round ne suffit pas, pour R3 et R3B
Calculer(Reseau& res, MapQuadinVar& variantesOrdonnees);
int PneSolveur(TypeDeSolveur typeSolveur, const std::shared_ptr<Variante>& varianteCourante);
void comput_ParticipationGrp(const std::shared_ptr<Incident>& icdt) const;
Expand Down Expand Up @@ -450,10 +451,10 @@ class Calculer
void assessAndPrintPTDF(const string& PTDFfileName);
void printLODF(const string& LODFfileName, bool writeLODFfile) const;

void addCurativeVariable(const std::shared_ptr<TransformateurDephaseur>& td, double proba, int numVarCur);
void addCurativeVariable(const std::shared_ptr<TransformateurDephaseur>& td_fictive);
void addCurativeVariable(const std::shared_ptr<LigneCC>& lcc, double proba, int numVarCur);
void addCurativeVariable(const std::shared_ptr<Groupe>& grp, double proba, int numVarCur);
void addCurativeVariable(const std::shared_ptr<ElementCuratifTD>& elemCurTD, double proba, int numVarCur);
void addCurativeVariable(const std::shared_ptr<ElementCuratifTD>& elemCurTDFictif, double proba);
void addCurativeVariable(const std::shared_ptr<ElementCuratifHVDC>& elemCurHVDC, double proba, int numVarCur);
void addCurativeVariable(const std::shared_ptr<ElementCuratifGroupe>& elemCurGrp, double proba, int numVarCur);
void addCurativeVariable(const std::shared_ptr<Consommation>& conso, double proba, int numVarCur);

private:
Expand Down
1 change: 1 addition & 0 deletions metrix-simulator/src/calculeEmpilementGroupes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ int Calculer::empilementEconomiqueDesGroupes(const std::shared_ptr<Variante>& va

// utilisation de PneSolveur
int status = METRIX_PAS_PROBLEME;
std::cout<<"PneSolveur : calculeEmpilementGroupes"<<std::endl;
status = PneSolveur(UTILISATION_PC_SIMPLEXE, varianteCourante);
if (status == METRIX_PROBLEME) {
LOG_ALL(error) << err::ioDico().msg("ERRAppelSpx");
Expand Down
474 changes: 409 additions & 65 deletions metrix-simulator/src/calculecrirecontraintesdodu.cpp

Large diffs are not rendered by default.

34 changes: 29 additions & 5 deletions metrix-simulator/src/calculmacrofonctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ int Calculer::resolutionProbleme()
//--------------------------------
auto mapVarEnd = variantesOrdonnees_.end();
for (auto mapVar = variantesOrdonnees_.begin(); mapVar != mapVarEnd; ++mapVar) {
std::cout<<"Passage dans la boucle de variantesOrdonnees_"<<std::endl;
const Quadripole::SetQuadripoleSortedByName& quads = mapVar->first;

LOG_RES() << "\n********************************************";
Expand Down Expand Up @@ -304,6 +305,7 @@ int Calculer::resolutionProbleme()
auto varEnd = mapVar->second.end();
for (auto var = mapVar->second.begin(); var != varEnd; ++var) {
varianteCourante_ = (*var);
std::cout<<"Variante n° "<<varianteCourante_->num_<<std::endl;

LOG_RES() << "\n---------------------";
LOG_RES() << "---------------------";
Expand Down Expand Up @@ -419,9 +421,9 @@ int Calculer::resolutionProbleme()

int Calculer::PneSolveur(TypeDeSolveur typeSolveur, const std::shared_ptr<Variante>& varianteCourante)
{
if (config::inputConfiguration().printConstraintsMatrix()) {
printMatriceDesContraintes();
}
// if (config::inputConfiguration().printConstraintsMatrix()) {
printMatriceDesContraintes();
// }

// Solveur I : utilisation de PNE_SOLVEUR
//--------------------------------------
Expand All @@ -432,7 +434,7 @@ int Calculer::PneSolveur(TypeDeSolveur typeSolveur, const std::shared_ptr<Varian

// Options du solveur
//------------------
pbPNE_.AffichageDesTraces = TRACES_PNE;
pbPNE_.AffichageDesTraces = OUI_PNE;
pbPNE_.SortirLesDonneesDuProbleme = config::inputConfiguration().exportMPSFile() ? OUI_PNE
: NON_PNE; // fichier mps
pbPNE_.FaireDuPresolve
Expand Down Expand Up @@ -634,6 +636,16 @@ int Calculer::resolutionUnProblemeDodu(const std::shared_ptr<Variante>& variante
if (status == METRIX_PAS_SOLUTION) {
return status;
}
std::cout<<"EQUILIBRAGE : "<<std::endl;
// for (unsigned long int i = 0; i!= pbX_.size();++i){
// if (pbPositionDeLaVariable_[i] == EN_BASE){
// std::cout<<" Variable "<<i<<" : en base et de valeur "<<pbX_[i]<<std::endl;
// }else{
// if(pbX_[i] != 0){
// std::cout<<"Variable "<<i<<" Hors-base : "<<pbX_[i]<<std::endl;
// }
// }
// }

if (status == METRIX_PROBLEME) {
LOG_ALL(error) << err::ioDico().msg("ERRCalcInterne") << "Probleme lors de l'appel a Pne_solveur";
Expand Down Expand Up @@ -721,6 +733,7 @@ int Calculer::resolutionUnProblemeDodu(const std::shared_ptr<Variante>& variante

// Appel du solveur
if (numMicroIteration_ != 1 && pbNombreDeContraintes_ > 0) {
std::cout<<"PneSolveur de résolutionUnProblemeDodu"<<std::endl;
status = PneSolveur(typeSolveur_, varianteCourante);
}

Expand All @@ -730,7 +743,18 @@ int Calculer::resolutionUnProblemeDodu(const std::shared_ptr<Variante>& variante
}
return status;
}

std::cout<<"MICROITERATION N°"<<compteur<<" : "<<std::endl;
// for (unsigned long int i = 0; i!= pbX_.size();++i){
// if (pbPositionDeLaVariable_[i] == EN_BASE){
// std::cout<<" Variable "<<i<<" : en base et de valeur "<<pbX_[i]<<std::endl;
// }else{
// if(pbX_[i] != 0){
// std::cout<<"Variable "<<i<<" Hors-base : "<<pbX_[i]<<std::endl;
// }
// }
// }
// std::cout<<"Nombre de contraintes : "<<pbNombreDeContraintes_<<std::endl;
// std::cout<<"Valeur de pbNbVarDeBaseComplementaires_ :"<<pbNbVarDeBaseComplementaires_<<std::endl;
// III- mise a jour du second membre
//*********************************

Expand Down
14 changes: 14 additions & 0 deletions metrix-simulator/src/config/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ void Configuration::initWithRawConfig(const raw_configuration& raw_config)
resultats_surcharges_ = helper::updateValueNumber(std::get<BOOLEAN>(raw_config), "OVRLDRES", false);
showAllAngleTDTransitHVDC_ = helper::updateValueNumber(std::get<BOOLEAN>(raw_config), "SHTDHVDC", false);
show_lost_load_detailed_ = helper::updateValueNumber(std::get<BOOLEAN>(raw_config), "LOSTLOAD", false);
raz_groupes = helper::updateValueNumber(std::get<BOOLEAN>(raw_config), "RAZGROUP", false);

cost_td_ = helper::updateValueNumber(std::get<FLOAT>(raw_config), "TDPENALI", 1.e-2F);
cost_hvdc_ = helper::updateValueNumber(std::get<FLOAT>(raw_config), "HVDCPENA", 0.1F);
Expand Down Expand Up @@ -377,4 +378,17 @@ double Configuration::thresholdMaxITAM(double thresholdMaxInc, double thresholdM
return thresholdMaxBeforeCur;
}

std::tuple<std::string, double> Configuration::nameThresholdMaxITAM(double thresholdMaxInc, std::string nameThresholdMaxInc, double thresholdMaxBeforeCur, std::string nameThresholdMaxBeforeCur) const
{
std::tuple<std::string, double> thresholdAndName;
if (!test_seuil_itam_ || thresholdMaxInc != constants::valdef) {
thresholdAndName = make_tuple(nameThresholdMaxInc, thresholdMaxInc);

}else{
// This implies that in case both equal valdef, we return valdef
thresholdAndName = make_tuple(nameThresholdMaxBeforeCur, thresholdMaxBeforeCur);
}
return thresholdAndName;
}

} // namespace config
3 changes: 3 additions & 0 deletions metrix-simulator/src/config/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class Configuration
bool displayResultatsSurcharges() const { return resultats_surcharges_; }
bool showAllAngleTDTransitHVDC() const { return showAllAngleTDTransitHVDC_; }
bool showLostLoadDetailed() const { return show_lost_load_detailed_; }
bool displayRAZGroupes() const { return raz_groupes; }

float costTd() const { return cost_td_; }
float costHvdc() const { return cost_hvdc_; }
Expand Down Expand Up @@ -211,6 +212,7 @@ class Configuration

// complex getter
double thresholdMaxITAM(double thresholdMaxInc, double thresholdMaxBeforeCur) const;
std::tuple<std::string, double> nameThresholdMaxITAM(double thresholdMaxInc, std::string nameThresholdMaxInc, double thresholdMaxBeforeCur, std::string nameThresholdMaxBeforeCur) const;

private:
static std::string pathname_;
Expand Down Expand Up @@ -351,6 +353,7 @@ class Configuration
bool resultats_surcharges_; // sortie uniquement des résultats sur les flux correspondants à une surcharge
bool showAllAngleTDTransitHVDC_; // Display in all cases the angle for TDs and HVDCs even if they were not modified
bool show_lost_load_detailed_;
bool raz_groupes; //After every variant, put all production costs back to their original value (FOR TESTS ONLY)

float cost_td_; // cost of TD actions
float cost_hvdc_; // cost of HVDC action
Expand Down
Loading

0 comments on commit b7ab09d

Please sign in to comment.