Skip to content

Commit

Permalink
[solver] Remove useless parentheses (#652)
Browse files Browse the repository at this point in the history
find -type f | xargs sed -E -i 's/\((.+)\)->/\1->/g'
  • Loading branch information
flomnes authored Apr 20, 2022
1 parent bf37a0a commit 219ece9
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 69 deletions.
33 changes: 16 additions & 17 deletions src/solver/hydro/daily/h2o_j_free.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,32 @@ void H2O_J_Free(DONNEES_MENSUELLES* DonneesMensuelles)

for (i = 0; i < NombreDeProblemes; i++)
{
free((ProblemeHydraulique->CorrespondanceDesVariables[i])->NumeroDeVariableTurbine);
free(ProblemeHydraulique->CorrespondanceDesVariables[i]->NumeroDeVariableTurbine);
free(ProblemeHydraulique->CorrespondanceDesVariables[i]);

free((ProblemeHydraulique->CorrespondanceDesContraintes[i])->NumeroDeContrainteSurXi);
free(ProblemeHydraulique->CorrespondanceDesContraintes[i]->NumeroDeContrainteSurXi);
free(ProblemeHydraulique->CorrespondanceDesContraintes[i]);

free((ProblemeHydraulique->ProblemeLineairePartieFixe[i])->CoutLineaire);
free((ProblemeHydraulique->ProblemeLineairePartieFixe[i])->TypeDeVariable);
free((ProblemeHydraulique->ProblemeLineairePartieFixe[i])->Sens);
free((ProblemeHydraulique->ProblemeLineairePartieFixe[i])->IndicesDebutDeLigne);
free((ProblemeHydraulique->ProblemeLineairePartieFixe[i])->NombreDeTermesDesLignes);
free(ProblemeHydraulique->ProblemeLineairePartieFixe[i]->CoutLineaire);
free(ProblemeHydraulique->ProblemeLineairePartieFixe[i]->TypeDeVariable);
free(ProblemeHydraulique->ProblemeLineairePartieFixe[i]->Sens);
free(ProblemeHydraulique->ProblemeLineairePartieFixe[i]->IndicesDebutDeLigne);
free(ProblemeHydraulique->ProblemeLineairePartieFixe[i]->NombreDeTermesDesLignes);
free((ProblemeHydraulique->ProblemeLineairePartieFixe[i])
->CoefficientsDeLaMatriceDesContraintes);
free((ProblemeHydraulique->ProblemeLineairePartieFixe[i])->IndicesColonnes);
free(ProblemeHydraulique->ProblemeLineairePartieFixe[i]->IndicesColonnes);
free(ProblemeHydraulique->ProblemeLineairePartieFixe[i]);

free((ProblemeHydraulique->ProblemeLineairePartieVariable[i])->Xmin);
free((ProblemeHydraulique->ProblemeLineairePartieVariable[i])->Xmax);
free((ProblemeHydraulique->ProblemeLineairePartieVariable[i])->SecondMembre);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]->Xmin);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]->Xmax);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]->SecondMembre);
free((ProblemeHydraulique->ProblemeLineairePartieVariable[i])
->AdresseOuPlacerLaValeurDesVariablesOptimisees);
free((ProblemeHydraulique->ProblemeLineairePartieVariable[i])->X);
free((ProblemeHydraulique->ProblemeLineairePartieVariable[i])->PositionDeLaVariable);
free((ProblemeHydraulique->ProblemeLineairePartieVariable[i])->ComplementDeLaBase);
free((ProblemeHydraulique->ProblemeLineairePartieVariable[i])->CoutsReduits);
free(
(ProblemeHydraulique->ProblemeLineairePartieVariable[i])->CoutsMarginauxDesContraintes);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]->X);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]->PositionDeLaVariable);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]->ComplementDeLaBase);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]->CoutsReduits);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]->CoutsMarginauxDesContraintes);
free(ProblemeHydraulique->ProblemeLineairePartieVariable[i]);

ProbSpx = (PROBLEME_SPX*)ProblemeHydraulique->ProblemeSpx[i];
Expand Down
32 changes: 16 additions & 16 deletions src/solver/hydro/daily2/h2o2_j_free.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,35 @@ void H2O2_J_Free(DONNEES_MENSUELLES_ETENDUES* DonneesMensuelles)

for (i = 0; i < NombreDeProblemes; i++)
{
free((ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i])->NumeroVar_Turbine);
free((ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i])->NumeroVar_niveauxFinJours);
free((ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i])->NumeroVar_overflow);
free((ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i])->NumeroVar_deviations);
free((ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i])->NumeroVar_violations);
free(ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i]->NumeroVar_Turbine);
free(ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i]->NumeroVar_niveauxFinJours);
free(ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i]->NumeroVar_overflow);
free(ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i]->NumeroVar_deviations);
free(ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i]->NumeroVar_violations);
free(ProblemeHydrauliqueEtendu->CorrespondanceDesVariables[i]);

free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i])->CoutLineaire);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i])->TypeDeVariable);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i])->Sens);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i])->IndicesDebutDeLigne);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i]->CoutLineaire);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i]->TypeDeVariable);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i]->Sens);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i]->IndicesDebutDeLigne);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i])
->NombreDeTermesDesLignes);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i])
->CoefficientsDeLaMatriceDesContraintes);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i])->IndicesColonnes);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i]->IndicesColonnes);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieFixe[i]);

free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])->Xmin);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])->Xmax);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])->SecondMembre);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i]->Xmin);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i]->Xmax);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i]->SecondMembre);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])
->AdresseOuPlacerLaValeurDesVariablesOptimisees);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])->X);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i]->X);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])
->PositionDeLaVariable);
free(
(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])->ComplementDeLaBase);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])->CoutsReduits);
ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i]->ComplementDeLaBase);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i]->CoutsReduits);
free((ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i])
->CoutsMarginauxDesContraintes);
free(ProblemeHydrauliqueEtendu->ProblemeLineaireEtenduPartieVariable[i]);
Expand Down
40 changes: 20 additions & 20 deletions src/solver/hydro/monthly/h2o_m_free.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,36 @@ void H2O_M_Free(DONNEES_ANNUELLES* DonneesAnnuelles)

ProblemeHydraulique = DonneesAnnuelles->ProblemeHydraulique;

free((ProblemeHydraulique->CorrespondanceDesVariables)->NumeroDeVariableVolume);
free((ProblemeHydraulique->CorrespondanceDesVariables)->NumeroDeVariableTurbine);
free((ProblemeHydraulique->CorrespondanceDesVariables)->NumeroDeVariableDepassementVolumeMax);
free((ProblemeHydraulique->CorrespondanceDesVariables)->NumeroDeVariableDepassementVolumeMin);
free(ProblemeHydraulique->CorrespondanceDesVariables->NumeroDeVariableVolume);
free(ProblemeHydraulique->CorrespondanceDesVariables->NumeroDeVariableTurbine);
free(ProblemeHydraulique->CorrespondanceDesVariables->NumeroDeVariableDepassementVolumeMax);
free(ProblemeHydraulique->CorrespondanceDesVariables->NumeroDeVariableDepassementVolumeMin);
free((ProblemeHydraulique->CorrespondanceDesVariables)
->NumeroDeVariableDEcartPositifAuTurbineCible);
free((ProblemeHydraulique->CorrespondanceDesVariables)
->NumeroDeVariableDEcartNegatifAuTurbineCible);
free(ProblemeHydraulique->CorrespondanceDesVariables);

free((ProblemeHydraulique->ProblemeLineairePartieFixe)->CoutLineaire);
free((ProblemeHydraulique->ProblemeLineairePartieFixe)->CoutLineaireBruite);
free((ProblemeHydraulique->ProblemeLineairePartieFixe)->TypeDeVariable);
free((ProblemeHydraulique->ProblemeLineairePartieFixe)->Sens);
free((ProblemeHydraulique->ProblemeLineairePartieFixe)->IndicesDebutDeLigne);
free((ProblemeHydraulique->ProblemeLineairePartieFixe)->NombreDeTermesDesLignes);
free((ProblemeHydraulique->ProblemeLineairePartieFixe)->CoefficientsDeLaMatriceDesContraintes);
free((ProblemeHydraulique->ProblemeLineairePartieFixe)->IndicesColonnes);
free(ProblemeHydraulique->ProblemeLineairePartieFixe->CoutLineaire);
free(ProblemeHydraulique->ProblemeLineairePartieFixe->CoutLineaireBruite);
free(ProblemeHydraulique->ProblemeLineairePartieFixe->TypeDeVariable);
free(ProblemeHydraulique->ProblemeLineairePartieFixe->Sens);
free(ProblemeHydraulique->ProblemeLineairePartieFixe->IndicesDebutDeLigne);
free(ProblemeHydraulique->ProblemeLineairePartieFixe->NombreDeTermesDesLignes);
free(ProblemeHydraulique->ProblemeLineairePartieFixe->CoefficientsDeLaMatriceDesContraintes);
free(ProblemeHydraulique->ProblemeLineairePartieFixe->IndicesColonnes);
free(ProblemeHydraulique->ProblemeLineairePartieFixe);

free((ProblemeHydraulique->ProblemeLineairePartieVariable)->Xmin);
free((ProblemeHydraulique->ProblemeLineairePartieVariable)->Xmax);
free((ProblemeHydraulique->ProblemeLineairePartieVariable)->SecondMembre);
free(ProblemeHydraulique->ProblemeLineairePartieVariable->Xmin);
free(ProblemeHydraulique->ProblemeLineairePartieVariable->Xmax);
free(ProblemeHydraulique->ProblemeLineairePartieVariable->SecondMembre);
free((ProblemeHydraulique->ProblemeLineairePartieVariable)
->AdresseOuPlacerLaValeurDesVariablesOptimisees);
free((ProblemeHydraulique->ProblemeLineairePartieVariable)->X);
free((ProblemeHydraulique->ProblemeLineairePartieVariable)->PositionDeLaVariable);
free((ProblemeHydraulique->ProblemeLineairePartieVariable)->ComplementDeLaBase);
free((ProblemeHydraulique->ProblemeLineairePartieVariable)->CoutsReduits);
free((ProblemeHydraulique->ProblemeLineairePartieVariable)->CoutsMarginauxDesContraintes);
free(ProblemeHydraulique->ProblemeLineairePartieVariable->X);
free(ProblemeHydraulique->ProblemeLineairePartieVariable->PositionDeLaVariable);
free(ProblemeHydraulique->ProblemeLineairePartieVariable->ComplementDeLaBase);
free(ProblemeHydraulique->ProblemeLineairePartieVariable->CoutsReduits);
free(ProblemeHydraulique->ProblemeLineairePartieVariable->CoutsMarginauxDesContraintes);
free(ProblemeHydraulique->ProblemeLineairePartieVariable);

for (i = 0; i < ProblemeHydraulique->NombreDeReservoirs; i++)
Expand Down
10 changes: 5 additions & 5 deletions src/solver/optimisation/opt_appel_solveur_lineaire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ bool OPT_AppelDuSimplexe(PROBLEME_HEBDO* ProblemeHebdo, uint numSpace, int NumIn
PremierPassage = OUI_ANTARES;
MPSolver* solver;

ProbSpx = (PROBLEME_SPX*)((ProblemeAResoudre->ProblemesSpx)->ProblemeSpx[(int)NumIntervalle]);
solver = (MPSolver*)((ProblemeAResoudre->ProblemesSpx)->ProblemeSpx[(int)NumIntervalle]);
ProbSpx = (PROBLEME_SPX*)(ProblemeAResoudre->ProblemesSpx->ProblemeSpx[(int)NumIntervalle]);
solver = (MPSolver*)(ProblemeAResoudre->ProblemesSpx->ProblemeSpx[(int)NumIntervalle]);

auto& study = *Data::Study::Current::Get();
bool ortoolsUsed = study.parameters.ortoolsUsed;
Expand All @@ -139,7 +139,7 @@ bool OPT_AppelDuSimplexe(PROBLEME_HEBDO* ProblemeHebdo, uint numSpace, int NumIn
{
SPX_LibererProbleme(ProbSpx);
}
(ProblemeAResoudre->ProblemesSpx)->ProblemeSpx[NumIntervalle] = NULL;
ProblemeAResoudre->ProblemesSpx->ProblemeSpx[NumIntervalle] = NULL;

ProbSpx = NULL;
solver = NULL;
Expand Down Expand Up @@ -244,15 +244,15 @@ bool OPT_AppelDuSimplexe(PROBLEME_HEBDO* ProblemeHebdo, uint numSpace, int NumIn
solver = ORTOOLS_Simplexe(&Probleme, solver);
if (solver != NULL)
{
(ProblemeAResoudre->ProblemesSpx)->ProblemeSpx[NumIntervalle] = (void*)solver;
ProblemeAResoudre->ProblemesSpx->ProblemeSpx[NumIntervalle] = (void*)solver;
}
}
else
{
ProbSpx = SPX_Simplexe(&Probleme, ProbSpx);
if (ProbSpx != NULL)
{
(ProblemeAResoudre->ProblemesSpx)->ProblemeSpx[NumIntervalle] = (void*)ProbSpx;
ProblemeAResoudre->ProblemesSpx->ProblemeSpx[NumIntervalle] = (void*)ProbSpx;
}
}
measure.tick();
Expand Down
4 changes: 2 additions & 2 deletions src/solver/optimisation/opt_liberation_problemes_simplexe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ void OPT_LiberationProblemesSimplexe(PROBLEME_HEBDO* ProblemeHebdo)
for (NumIntervalle = 0; NumIntervalle < NbIntervalles; NumIntervalle++)
{
ProbSpx
= (PROBLEME_SPX*)((ProblemeAResoudre->ProblemesSpx)->ProblemeSpx[NumIntervalle]);
solver = (MPSolver*)((ProblemeAResoudre->ProblemesSpx)->ProblemeSpx[NumIntervalle]);
= (PROBLEME_SPX*)(ProblemeAResoudre->ProblemesSpx->ProblemeSpx[NumIntervalle]);
solver = (MPSolver*)(ProblemeAResoudre->ProblemesSpx->ProblemeSpx[NumIntervalle]);

if (ortoolsUsed && solver != NULL)
{
Expand Down
6 changes: 3 additions & 3 deletions src/solver/optimisation/opt_optimisation_lineaire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool OPT_OptimisationLineaire(PROBLEME_HEBDO* ProblemeHebdo, uint numSpace)

NombreDePasDeTempsPourUneOptimisation = ProblemeHebdo->NombreDePasDeTempsPourUneOptimisation;

(ProblemeHebdo->ProblemeAResoudre)->NumeroDOptimisation = PREMIERE_OPTIMISATION;
ProblemeHebdo->ProblemeAResoudre->NumeroDOptimisation = PREMIERE_OPTIMISATION;

OPT_NumeroDeJourDuPasDeTemps(ProblemeHebdo);

Expand Down Expand Up @@ -105,7 +105,7 @@ bool OPT_OptimisationLineaire(PROBLEME_HEBDO* ProblemeHebdo, uint numSpace)
ProblemeHebdo->numeroOptimisation[NumeroDeLIntervalle] = 0;
}

if ((ProblemeHebdo->ProblemeAResoudre)->NumeroDOptimisation == PREMIERE_OPTIMISATION)
if (ProblemeHebdo->ProblemeAResoudre->NumeroDOptimisation == PREMIERE_OPTIMISATION)
{
if (ProblemeHebdo->OptimisationAvecCoutsDeDemarrage == NON_ANTARES)
{
Expand All @@ -119,7 +119,7 @@ bool OPT_OptimisationLineaire(PROBLEME_HEBDO* ProblemeHebdo, uint numSpace)
printf("BUG: l'indicateur ProblemeHebdo->OptimisationAvecCoutsDeDemarrage doit etre "
"initialise a OUI_ANTARES ou NON_ANTARES\n");

(ProblemeHebdo->ProblemeAResoudre)->NumeroDOptimisation = DEUXIEME_OPTIMISATION;
ProblemeHebdo->ProblemeAResoudre->NumeroDOptimisation = DEUXIEME_OPTIMISATION;

if (ProblemeHebdo->Expansion == NON_ANTARES)
goto OptimisationHebdo;
Expand Down
2 changes: 1 addition & 1 deletion src/solver/optimisation/opt_restaurer_les_donnees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void OPT_RestaurerLesDonnees(PROBLEME_HEBDO* ProblemeHebdo)
}

if (ProblemeHebdo->YaDeLaReserveJmoins1 == OUI_ANTARES
&& (ProblemeHebdo->ProblemeAResoudre)->NumeroDOptimisation == PREMIERE_OPTIMISATION)
&& ProblemeHebdo->ProblemeAResoudre->NumeroDOptimisation == PREMIERE_OPTIMISATION)
{
for (Pdt = 0; Pdt < DernierPasDeTemps; Pdt++)
{
Expand Down
4 changes: 2 additions & 2 deletions src/solver/simulation/sim_alloc_probleme_hebdo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void SIM_AllocationProblemeHebdo(PROBLEME_HEBDO& problem, int NombreDePasDeTemps

for (k = 0; k < (int)nbPays; k++)
{
const uint nbPaliers = (study.areas.byIndex[k])->thermal.list.size();
const uint nbPaliers = study.areas.byIndex[k]->thermal.list.size();

problem.PaliersThermiquesDuPays[k]
= (PALIERS_THERMIQUES*)MemAlloc(sizeof(PALIERS_THERMIQUES));
Expand Down Expand Up @@ -758,7 +758,7 @@ void SIM_DesallocationProblemeHebdo(PROBLEME_HEBDO& problem)

for (int k = 0; k < (int)nbPays; ++k)
{
const uint nbPaliers = (study.areas.byIndex[k])->thermal.list.size();
const uint nbPaliers = study.areas.byIndex[k]->thermal.list.size();

MemFree(problem.PaliersThermiquesDuPays[k]->PminDuPalierThermiquePendantUneHeure);
MemFree(problem.PaliersThermiquesDuPays[k]->PminDuPalierThermiquePendantUneSemaine);
Expand Down
4 changes: 2 additions & 2 deletions src/solver/simulation/solver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void ISimulation<Impl>::estimateMemoryForWeeklyPb(Antares::Data::StudyMemoryUsag

for (int k = 0; k < (int)nbAreas; k++)
{
const uint nbPaliers = (study.areas.byIndex[k])->thermal.list.size();
const uint nbPaliers = study.areas.byIndex[k]->thermal.list.size();

requiredMemoryForWeeklyPb += 10 * NombreDePasDeTemps * sizeof(double);
requiredMemoryForWeeklyPb += NombreDePasDeTemps * sizeof(void*);
Expand Down Expand Up @@ -676,7 +676,7 @@ void ISimulation<Impl>::estimateMemoryForWeeklyPb(Antares::Data::StudyMemoryUsag

for (int k = 0; k < (int)nbAreas; k++)
{
const uint nbPaliers = (study.areas.byIndex[k])->thermal.list.size();
const uint nbPaliers = study.areas.byIndex[k]->thermal.list.size();

requiredMemoryForWeeklyPb += sizeof(PALIERS_THERMIQUES);
requiredMemoryForWeeklyPb += sizeof(ENERGIES_ET_PUISSANCES_HYDRAULIQUES);
Expand Down
2 changes: 1 addition & 1 deletion src/solver/variable/surveyresults/surveyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void ExportGridInfosAreas(const Data::Study& study, const String& folder)
{
auto end = area.links.end();
for (auto i = area.links.begin(); i != end; ++i)
outLinks << area.id << '\t' << (i->second)->with->id << '\n';
outLinks << area.id << '\t' << i->second->with->id << '\n';
}

// Thermal clusters
Expand Down

0 comments on commit 219ece9

Please sign in to comment.