Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.6.6 #1999

Merged
merged 11 commits into from
Mar 26, 2024
Merged

8.6.6 #1999

Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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
@@ -60,7 +59,6 @@ enum class AdqPatchPTO

}; // enum AdqPatchPTO


struct LocalMatching
{
bool enabled = true;
@@ -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
@@ -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();
@@ -106,10 +105,8 @@ class CurtailmentSharing
void resetThresholds();
};


struct AdqPatchParams
{

bool enabled;
LocalMatching localMatching;
CurtailmentSharing curtailmentSharing;
@@ -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;
10 changes: 6 additions & 4 deletions src/libs/antares/study/scenario-builder/TSnumberData.cpp
Original file line number Diff line number Diff line change
@@ -395,18 +395,20 @@ bool thermalTSNumberData::apply(Study& study)
// WARNING: We may have some thermal clusters with the `mustrun` option
auto clusterCount = (uint)area.thermal.clusterCount();

const uint tsGenCountThermal = get_tsGenCount(study);

for (uint clusterIndex = 0; clusterIndex != clusterCount; ++clusterIndex)
{
auto& cluster = *(area.thermal.clusters[clusterIndex]);
// alias to the current column
assert(clusterIndex < pTSNumberRules.width);
const auto& col = pTSNumberRules[clusterIndex];

logprefix.clear() << "Thermal: Area '" << area.name << "', cluster: '" << cluster.name()
uint tsGenCount = cluster.tsGenBehavior == LocalTSGenerationBehavior::forceNoGen ?
cluster.series->timeSeries.width : get_tsGenCount(study);

logprefix.clear() << "Thermal: area '" << area.name << "', cluster: '" << cluster.name()
<< "': ";
ret = ApplyToMatrix(errors, logprefix, *cluster.series, col, tsGenCountThermal) && ret;
ret = ApplyToMatrix(errors, logprefix, *cluster.series, col, tsGenCount) && ret;

}
return ret;
}
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"
@@ -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)
{
}

@@ -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;
@@ -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)
{
}
@@ -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)] */
@@ -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);
}
}
}
7 changes: 6 additions & 1 deletion src/solver/optimisation/post_process_commands.h
Original file line number Diff line number Diff line change
@@ -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;
};
@@ -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,
22 changes: 12 additions & 10 deletions src/solver/ts-generator/thermal.cpp
Original file line number Diff line number Diff line change
@@ -94,7 +94,6 @@ class GeneratorTempData final
private:
uint nbHoursPerYear;

const uint daysPerYear;

MersenneTwister& rndgenerator;

@@ -125,9 +124,8 @@ class GeneratorTempData final

double bp[366];

double FPOW[366][102];

double PPOW[366][102];
std::vector<std::vector<double>> FPOW;
std::vector<std::vector<double>> PPOW;

String pTempFilename;

@@ -141,7 +139,6 @@ GeneratorTempData::GeneratorTempData(Data::Study& study,
IResultWriter::Ptr writer) :
study(study),
nbHoursPerYear(study.runtime->nbHoursPerYear),
daysPerYear(study.runtime->nbDaysPerYear),
rndgenerator(study.runtime->random[Data::seedTsGenThermal]),
pProgression(progr),
pWriter(writer)
@@ -153,6 +150,9 @@ GeneratorTempData::GeneratorTempData(Data::Study& study,
nbThermalTimeseries = parameters.nbTimeSeriesThermal;

derated = parameters.derated;

FPOW.resize(DAYS_PER_YEAR);
PPOW.resize(DAYS_PER_YEAR);
}

void GeneratorTempData::writeResultsToDisk(const Data::Area& area,
@@ -191,7 +191,7 @@ void GeneratorTempData::prepareIndispoFromLaw(Data::ThermalLaw law,
{
case Data::thermalLawUniform:
{
for (uint d = 0; d < daysPerYear; ++d)
for (uint d = 0; d < DAYS_PER_YEAR; ++d)
{
double D = (double)duration[d];
double xtemp = volatility * (D - 1.);
@@ -202,7 +202,7 @@ void GeneratorTempData::prepareIndispoFromLaw(Data::ThermalLaw law,
}
case Data::thermalLawGeometric:
{
for (uint d = 0; d < daysPerYear; ++d)
for (uint d = 0; d < DAYS_PER_YEAR; ++d)
{
double D = (double)duration[d];
double xtemp = volatility * volatility * D * (D - 1.);
@@ -312,8 +312,11 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust
int FOD_reel = 0;
int POD_reel = 0;

for (uint d = 0; d < daysPerYear; ++d)
for (uint d = 0; d < DAYS_PER_YEAR; ++d)
{
FPOW[d].resize(cluster.unitCount + 1);
PPOW[d].resize(cluster.unitCount + 1);

PODOfTheDay = (int)POD[d];
FODOfTheDay = (int)FOD[d];

@@ -385,9 +388,8 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust
if (tsIndex > 1)
dstSeries = &cluster.series->timeSeries[tsIndex - 2];

for (uint dayInTheYear = 0; dayInTheYear < daysPerYear; ++dayInTheYear)
for (uint dayInTheYear = 0; dayInTheYear < DAYS_PER_YEAR; ++dayInTheYear)
{
assert(AUN <= 100 and "Thermal Prepro: AUN is out of bounds (>=100)");
assert(dayInTheYear < 366);
assert(not(lf[dayInTheYear] < 0.));
assert(not(lp[dayInTheYear] < 0.));
Original file line number Diff line number Diff line change
@@ -385,5 +385,4 @@ BOOST_AUTO_TEST_CASE(on_link_area2_area3_and_on_year_19__ntc_TS_number_6_is_chos
BOOST_CHECK(my_rule.apply());
BOOST_CHECK_EQUAL(link_23->timeseriesNumbers[0][yearNumber.to<uint>()], tsNumber.to<uint>() - 1);
}

BOOST_AUTO_TEST_SUITE_END()