Skip to content

Commit

Permalink
Fix cost for ST storage (#2522)
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes authored Dec 4, 2024
1 parent c2335ca commit c67e312
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/solver/optimisation/opt_gestion_des_couts_cas_lineaire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
void OPT_InitialiserLesCoutsLineaireCoutsDeDemarrage(PROBLEME_HEBDO*, const int, const int);

static void shortTermStorageCost(
int weekInTheYear,
int PremierPdtDeLIntervalle,
int DernierPdtDeLIntervalle,
int NombreDePays,
const std::vector<::ShortTermStorage::AREA_INPUT>& shortTermStorageInput,
VariableManagement::VariableManager& variableManager,
std::vector<double>& linearCost)
{
const int weekFirstHour = weekInTheYear * 168;
for (int pays = 0; pays < NombreDePays; ++pays)
{
for (const auto& storage: shortTermStorageInput[pays])
Expand All @@ -41,45 +43,46 @@ static void shortTermStorageCost(
pdtHebdo < DernierPdtDeLIntervalle;
pdtHebdo++, pdtJour++)
{
int hourInTheYear = weekFirstHour + pdtHebdo;
const int clusterGlobalIndex = storage.clusterGlobalIndex;
if (const int varLevel = variableManager.ShortTermStorageLevel(clusterGlobalIndex,
pdtJour);
varLevel >= 0)
{
linearCost[varLevel] = storage.series->costLevel[pdtHebdo];
linearCost[varLevel] = storage.series->costLevel[hourInTheYear];
}

if (const int varInjection = variableManager.ShortTermStorageInjection(
clusterGlobalIndex,
pdtJour);
varInjection >= 0)
{
linearCost[varInjection] = storage.series->costInjection[pdtHebdo];
linearCost[varInjection] = storage.series->costInjection[hourInTheYear];
}

if (const int varWithdrawal = variableManager.ShortTermStorageWithdrawal(
clusterGlobalIndex,
pdtJour);
varWithdrawal >= 0)
{
linearCost[varWithdrawal] = storage.series->costWithdrawal[pdtHebdo];
linearCost[varWithdrawal] = storage.series->costWithdrawal[hourInTheYear];
}
if (const int varCostVariationInjection = variableManager
.ShortTermStorageCostVariationInjection(
clusterGlobalIndex,
pdtJour);
storage.penalizeVariationInjection && varCostVariationInjection >= 0)
{
linearCost[varCostVariationInjection] = storage.series
->costVariationInjection[pdtHebdo];
linearCost[varCostVariationInjection] = storage.series->costVariationInjection
[hourInTheYear];
}
if (const int varCostVariationWithdrawal
= variableManager.ShortTermStorageCostVariationWithdrawal(clusterGlobalIndex,
pdtJour);
storage.penalizeVariationWithdrawal && varCostVariationWithdrawal >= 0)
{
linearCost[varCostVariationWithdrawal] = storage.series
->costVariationWithdrawal[pdtHebdo];
linearCost[varCostVariationWithdrawal] = storage.series->costVariationWithdrawal
[hourInTheYear];
}
}
}
Expand All @@ -97,7 +100,8 @@ void OPT_InitialiserLesCoutsLineaire(PROBLEME_HEBDO* problemeHebdo,
ProblemeAResoudre->CoutQuadratique.assign(ProblemeAResoudre->NombreDeVariables, 0.);
auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo);

shortTermStorageCost(PremierPdtDeLIntervalle,
shortTermStorageCost(problemeHebdo->weekInTheYear,
PremierPdtDeLIntervalle,
DernierPdtDeLIntervalle,
problemeHebdo->NombreDePays,
problemeHebdo->ShortTermStorage,
Expand Down

0 comments on commit c67e312

Please sign in to comment.