Skip to content

Commit

Permalink
Clean opt code a bit (#387)
Browse files Browse the repository at this point in the history
* Remove unused OPT_ChargerLaContrainteAPartirDePi
* Use references instead of copies
  • Loading branch information
flomnes authored Sep 27, 2021
1 parent 6b99169 commit 0754ccf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,62 +33,18 @@

#include "opt_fonctions.h"

void OPT_ChargerLaContrainteAPartirDePi(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre,
double* Pi,
char SensContrainte)
{
int NombreDeVariables;
int NombreDeContraintes;
int NombreDeTermes;
int NombreDeTermesDeLaContrainte;
int Var;

NombreDeVariables = ProblemeAResoudre->NombreDeVariables;
NombreDeContraintes = ProblemeAResoudre->NombreDeContraintes;
NombreDeTermes = ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes;

NombreDeTermesDeLaContrainte = 0;
ProblemeAResoudre->IndicesDebutDeLigne[NombreDeContraintes] = NombreDeTermes;
for (Var = 0; Var < NombreDeVariables; Var++)
{
if (Pi[Var] == 0.0)
continue;
ProblemeAResoudre->CoefficientsDeLaMatriceDesContraintes[NombreDeTermes] = Pi[Var];
ProblemeAResoudre->IndicesColonnes[NombreDeTermes] = Var;
NombreDeTermesDeLaContrainte++;
NombreDeTermes++;
if (NombreDeTermes == ProblemeAResoudre->NombreDeTermesAllouesDansLaMatriceDesContraintes)
{
OPT_AugmenterLaTailleDeLaMatriceDesContraintes(ProblemeAResoudre);
}
}
ProblemeAResoudre->NombreDeTermesDesLignes[NombreDeContraintes] = NombreDeTermesDeLaContrainte;

ProblemeAResoudre->Sens[NombreDeContraintes] = SensContrainte;
NombreDeContraintes++;

ProblemeAResoudre->NombreDeContraintes = NombreDeContraintes;
ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes = NombreDeTermes;

return;
}

void OPT_ChargerLaContrainteDansLaMatriceDesContraintes(
PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre,
double* Pi,
int* Colonne,
int NombreDeTermesDeLaContrainte,
char SensContrainte)
{
int i;
int NombreDeTermes;
int NombreDeContraintes;

NombreDeContraintes = ProblemeAResoudre->NombreDeContraintes;
NombreDeTermes = ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes;
int& NombreDeTermes = ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes;
int& NombreDeContraintes = ProblemeAResoudre->NombreDeContraintes;

ProblemeAResoudre->IndicesDebutDeLigne[NombreDeContraintes] = NombreDeTermes;
for (i = 0; i < NombreDeTermesDeLaContrainte; i++)
for (int i = 0; i < NombreDeTermesDeLaContrainte; i++)
{
ProblemeAResoudre->CoefficientsDeLaMatriceDesContraintes[NombreDeTermes] = Pi[i];
ProblemeAResoudre->IndicesColonnes[NombreDeTermes] = Colonne[i];
Expand All @@ -103,8 +59,5 @@ void OPT_ChargerLaContrainteDansLaMatriceDesContraintes(
ProblemeAResoudre->Sens[NombreDeContraintes] = SensContrainte;
NombreDeContraintes++;

ProblemeAResoudre->NombreDeContraintes = NombreDeContraintes;
ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes = NombreDeTermes;

return;
}
1 change: 0 additions & 1 deletion src/solver/optimisation/opt_fonctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ void OPT_RestaurerLesDonnees(PROBLEME_HEBDO*);
void OPT_CalculerLesPminThermiquesEnFonctionDeMUTetMDT(PROBLEME_HEBDO*);
double OPT_CalculerAireMaxPminJour(int, int, int, int, int*, int*);

void OPT_ChargerLaContrainteAPartirDePi(PROBLEME_ANTARES_A_RESOUDRE*, double*, char);
void OPT_ChargerLaContrainteDansLaMatriceDesContraintes(PROBLEME_ANTARES_A_RESOUDRE*,
double*,
int*,
Expand Down

0 comments on commit 0754ccf

Please sign in to comment.