Skip to content

Commit

Permalink
cherry pick #1982
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes authored and payetvin committed Mar 19, 2024
1 parent cafbe57 commit b53e042
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 59 deletions.
14 changes: 5 additions & 9 deletions src/libs/antares/study/parameters/adq-patch-params.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ using namespace Yuni;

namespace Antares::Data::AdequacyPatch
{

//! A default threshold value for initiate curtailment sharing rule
const double defaultThresholdToRunCurtailmentSharing = 0.0;
//! A default threshold value for display local matching rule violations
Expand Down Expand Up @@ -60,7 +59,6 @@ enum class AdqPatchPTO

}; // enum AdqPatchPTO


struct LocalMatching
{
bool enabled = true;
Expand All @@ -73,12 +71,11 @@ struct LocalMatching
//! rule.
bool setToZeroOutsideOutsideLinks = true;
/*!
** \brief Reset to default values related to local matching
*/
** \brief Reset to default values related to local matching
*/
void reset();
bool updateFromKeyValue(const String& key, const String& value);
void addProperties(IniFile::Section* section) const;

};

class CurtailmentSharing
Expand All @@ -97,7 +94,9 @@ class CurtailmentSharing
//! Check CSR cost function prior & after CSR optimization
bool checkCsrCostFunction;

bool updateFromKeyValue(const String& key, const String& value);
bool recomputeDTGMRG = false;

bool updateFromKeyValue(const Yuni::String& key, const Yuni::String& value);
void addProperties(IniFile::Section* section) const;

void reset();
Expand All @@ -106,10 +105,8 @@ class CurtailmentSharing
void resetThresholds();
};


struct AdqPatchParams
{

bool enabled;
LocalMatching localMatching;
CurtailmentSharing curtailmentSharing;
Expand All @@ -122,7 +119,6 @@ struct AdqPatchParams
const AreaList& areas,
const bool includeHurdleCostParameters) const;


void checkAdqPatchStudyModeEconomyOnly(const StudyMode studyMode) const;
void checkAdqPatchContainsAdqPatchArea(const Antares::Data::AreaList& areas) const;
void checkAdqPatchIncludeHurdleCost(const bool includeHurdleCost) const;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,35 @@
#include "adq_patch_post_process_list.h"
#include "../post_process_commands.h"


namespace Antares::Solver::Simulation
{

AdqPatchPostProcessList::AdqPatchPostProcessList(const AdqPatchParams& adqPatchParams,
PROBLEME_HEBDO* problemeHebdo,
uint thread_number,
AreaList& areas,
SheddingPolicy sheddingPolicy,
SimplexOptimization splxOptimization,
Calendar& calendar)
: interfacePostProcessList(problemeHebdo, thread_number)
Calendar& calendar) :
interfacePostProcessList(problemeHebdo, thread_number)
{
post_process_list.push_back(std::make_unique<DispatchableMarginPostProcessCmd>(
problemeHebdo_,
thread_number_,
areas));
post_process_list.push_back(
std::make_unique<DispatchableMarginPostProcessCmd>(problemeHebdo_, thread_number_, areas));
// Here a post process particular to adq patch
post_process_list.push_back(std::make_unique<CurtailmentSharingPostProcessCmd>(
adqPatchParams,
problemeHebdo_,
areas,
thread_number_));
post_process_list.push_back(std::make_unique<HydroLevelsUpdatePostProcessCmd>(
problemeHebdo_,
areas,
false,
false));
adqPatchParams, problemeHebdo_, areas, thread_number_));
post_process_list.push_back(
std::make_unique<HydroLevelsUpdatePostProcessCmd>(problemeHebdo_, areas, false, false));
post_process_list.push_back(std::make_unique<RemixHydroPostProcessCmd>(
problemeHebdo_,
areas,
sheddingPolicy,
splxOptimization,
thread_number));
problemeHebdo_, areas, sheddingPolicy, splxOptimization, thread_number));
// Here a post process particular to adq patch
post_process_list.push_back(std::make_unique<DTGmarginForAdqPatchPostProcessCmd>(
problemeHebdo_,
areas,
thread_number));
post_process_list.push_back(std::make_unique<HydroLevelsUpdatePostProcessCmd>(
problemeHebdo_,
areas,
true,
false));
post_process_list.push_back(std::make_unique<InterpolateWaterValuePostProcessCmd>(
problemeHebdo_,
areas,
calendar));
post_process_list.push_back(std::make_unique<HydroLevelsFinalUpdatePostProcessCmd>(
problemeHebdo_,
areas));
adqPatchParams, problemeHebdo_, areas, thread_number));
post_process_list.push_back(
std::make_unique<HydroLevelsUpdatePostProcessCmd>(problemeHebdo_, areas, true, false));
post_process_list.push_back(
std::make_unique<InterpolateWaterValuePostProcessCmd>(problemeHebdo_, areas, calendar));
post_process_list.push_back(
std::make_unique<HydroLevelsFinalUpdatePostProcessCmd>(problemeHebdo_, areas));
}

} // namespace Antares::Solver::Simulation
} // namespace Antares::Solver::Simulation
52 changes: 41 additions & 11 deletions src/solver/optimisation/post_process_commands.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "post_process_commands.h"
#include "../simulation/common-eco-adq.h"
Expand Down Expand Up @@ -105,10 +125,14 @@ void RemixHydroPostProcessCmd::execute(const optRuntimeData& opt_runtime_data)
using namespace Antares::Data::AdequacyPatch;

DTGmarginForAdqPatchPostProcessCmd::DTGmarginForAdqPatchPostProcessCmd(
const AdqPatchParams& adqPatchParams,
PROBLEME_HEBDO* problemeHebdo,
AreaList& areas,
unsigned int thread_number) :
basePostProcessCommand(problemeHebdo), area_list_(areas), thread_number_(thread_number)
basePostProcessCommand(problemeHebdo),
adqPatchParams_(adqPatchParams),
area_list_(areas),
thread_number_(thread_number)
{
}

Expand Down Expand Up @@ -138,6 +162,11 @@ void DTGmarginForAdqPatchPostProcessCmd::execute(const optRuntimeData&)
{
dtgMrgCsr = std::max(0.0, dtgMrg - ens);
ens = std::max(0.0, ens - dtgMrg);
if (adqPatchParams_.curtailmentSharing.recomputeDTGMRG)
{
dtgMrgCsr = std::max(0.0, dtgMrg - ens);
ens = std::max(0.0, ens - dtgMrg);
}
// set MRG PRICE to value of unsupplied energy cost, if LOLD=1.0 (ENS>0.5)
if (ens > 0.5)
mrgCost = -area_list_[Area]->thermal.unsuppliedEnergyCost;
Expand Down Expand Up @@ -190,8 +219,8 @@ CurtailmentSharingPostProcessCmd::CurtailmentSharingPostProcessCmd(const AdqPatc
AreaList& areas,
unsigned int thread_number) :
basePostProcessCommand(problemeHebdo),
area_list_(areas),
adqPatchParams_(adqPatchParams),
area_list_(areas),
thread_number_(thread_number)
{
}
Expand Down Expand Up @@ -225,11 +254,11 @@ double CurtailmentSharingPostProcessCmd::calculateDensNewAndTotalLmrViolation()
{
for (uint hour = 0; hour < nbHoursInWeek; hour++)
{
const auto [netPositionInit, densNew, totalNodeBalance]
= calculateAreaFlowBalance(problemeHebdo_,
adqPatchParams_.localMatching.setToZeroOutsideInsideLinks,
Area,
hour);
const auto [netPositionInit, densNew, totalNodeBalance] = calculateAreaFlowBalance(
problemeHebdo_,
adqPatchParams_.localMatching.setToZeroOutsideInsideLinks,
Area,
hour);
// adjust densNew according to the new specification/request by ELIA
/* DENS_new (node A) = max [ 0; ENS_init (node A) + net_position_init (node A)
+ ? flows (node 1 -> node A) - DTG.MRG(node A)] */
Expand All @@ -245,10 +274,11 @@ double CurtailmentSharingPostProcessCmd::calculateDensNewAndTotalLmrViolation()
.ValeursHorairesDeDefaillanceNegative[hour];
// check LMR violations
totalLmrViolation += LmrViolationAreaHour(
problemeHebdo_,
totalNodeBalance,
adqPatchParams_.curtailmentSharing.thresholdDisplayViolations,
Area, hour);
problemeHebdo_,
totalNodeBalance,
adqPatchParams_.curtailmentSharing.thresholdDisplayViolations,
Area,
hour);
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/solver/optimisation/post_process_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ class RemixHydroPostProcessCmd : public basePostProcessCommand

class DTGmarginForAdqPatchPostProcessCmd : public basePostProcessCommand
{
using AdqPatchParams = Antares::Data::AdequacyPatch::AdqPatchParams;

public:
DTGmarginForAdqPatchPostProcessCmd(PROBLEME_HEBDO* problemeHebdo,
DTGmarginForAdqPatchPostProcessCmd(const AdqPatchParams& adqPatchParams,
PROBLEME_HEBDO* problemeHebdo,
AreaList& areas,
unsigned int thread_number);

void execute(const optRuntimeData& opt_runtime_data) override;

private:
const AdqPatchParams& adqPatchParams_;
const AreaList& area_list_;
unsigned int thread_number_ = 0;
};
Expand Down Expand Up @@ -91,6 +95,7 @@ class HydroLevelsFinalUpdatePostProcessCmd : public basePostProcessCommand
class CurtailmentSharingPostProcessCmd : public basePostProcessCommand
{
using AdqPatchParams = Antares::Data::AdequacyPatch::AdqPatchParams;

public:
CurtailmentSharingPostProcessCmd(const AdqPatchParams& adqPatchParams,
PROBLEME_HEBDO* problemeHebdo,
Expand Down

0 comments on commit b53e042

Please sign in to comment.