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

New output var : min gen for thermal #2608

Open
wants to merge 7 commits into
base: feature/dynamic-cluster-groups
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ class ThermalCluster final: public Cluster, public std::enable_shared_from_this<
*/
std::vector<double> PthetaInf;

bool hasMinGen() const
{
return anyMinGen_;
}

void anyMinGen(bool minGen)
{
anyMinGen_ = minGen;
}

flomnes marked this conversation as resolved.
Show resolved Hide resolved
//! Data for the preprocessor
std::unique_ptr<PreproAvailability> prepro;

Expand All @@ -307,6 +317,7 @@ class ThermalCluster final: public Cluster, public std::enable_shared_from_this<
CostProvider& getCostProvider();

private:
bool anyMinGen_ = false;
flomnes marked this conversation as resolved.
Show resolved Hide resolved
// Calculation of marketBid and marginal costs hourly time series
//
// Calculation of market bid and marginals costs per hour
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class ThermalClusterList: public ClusterList<ThermalCluster>
| std::views::filter(std::not_fn(&ThermalCluster::isMustRun));
}

auto each_has_min_gen() const
{
return each_enabled_and_not_mustrun() | std::views::filter(&ThermalCluster::hasMinGen);
}
Comment on lines +97 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not necessary

Copy link
Contributor Author

@guilpier-code guilpier-code Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed hasMinGenCount() from class ThermalClusterList.
But for this one (each_has_min_gen()), what do you suggest ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest not using this filter since it's extremely unusual for output variables to be printed based on such a condition. Print the value for every enabled cluster.

Copy link
Contributor Author

@guilpier-code guilpier-code Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cluster list is a business concept, and output variables is not.
So you mean that each_has_min_gen() unnecessarily bloats class ThermalClusterList with a function used only in output ?

If you want each_has_min_gen() to disappear from class ThermalClusterList, we could create instead a free function more in the scope of output variables (utils.h ?) that would do the job and would avoid code duplication.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should produce this variable for all enabled cluster, no matter if they have a min-gen or not

Copy link
Contributor Author

@guilpier-code guilpier-code Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should produce this variable for all enabled cluster, no matter if they have a min-gen or not

it's a change of specification. To be discussed with our PO.


/*!
** \brief Ensure data for the prepro are initialized
** \ingroup thermalclusters
Expand Down
8 changes: 5 additions & 3 deletions src/libs/antares/study/study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,13 +1422,15 @@ void Study::computePThetaInfForThermalClusters() const
// Alias de la zone courant
const auto& area = *(this->areas.byIndex[i]);

for (auto& cluster: area.thermal.list.each_enabled_and_not_mustrun())
for (auto& c: area.thermal.list.each_enabled_and_not_mustrun())
{
for (uint k = 0; k < HOURS_PER_YEAR; k++)
{
cluster->PthetaInf[k] = cluster->modulation[Data::thermalMinGenModulation][k]
* cluster->unitCount * cluster->nominalCapacity;
c->PthetaInf[k] = c->modulation[Data::thermalMinGenModulation][k] * c->unitCount
* c->nominalCapacity;
}

c->anyMinGen(std::ranges::any_of(c->PthetaInf, [](double& e) { return e > 0.5; }));
flomnes marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/solver/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ void Application::readDataForTheStudy(Data::StudyLoadOptions& options)
ScenarioBuilderOwner(study).callScenarioBuilder();
}

// gp : here we don't "start simulation", but we mainly read input data for the simulation to
// gp : be executed a bit later.
void Application::startSimulation(Data::StudyLoadOptions& options)
{
// Starting !
Expand Down
3 changes: 3 additions & 0 deletions src/solver/optimisation/opt_restaurer_les_donnees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ void OPT_RestaurerLesDonnees(PROBLEME_HEBDO* problemeHebdo)
PuissanceDisponibleEtCout.PuissanceDisponibleDuPalierThermique[pdt]
= PuissanceDisponibleEtCout.PuissanceDisponibleDuPalierThermiqueRef[pdt];

// gp : how is this case possible (after what's in
// gp : BuildThermalPartOfWeeklyProblem(...)) ??
// gp : In other words, do we have dead code here ?
if (PuissanceDisponibleEtCout.PuissanceMinDuPalierThermique[pdt]
> PuissanceDisponibleEtCout.PuissanceDisponibleDuPalierThermique[pdt])
{
Expand Down
3 changes: 3 additions & 0 deletions src/solver/simulation/simulation-run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Benchmarking::OptimizationInfo simulationRun(Antares::Data::Study& study,
IResultWriter& resultWriter,
Simulation::ISimulationObserver& simulationObserver)
{
// gp : is there a reason why we do that here and not inside the clusters and
// gp : right after the read step ?
// gp : It would allow to move a piece of code out of the Study.
study.computePThetaInfForThermalClusters();

switch (study.runtime.mode)
Expand Down
7 changes: 4 additions & 3 deletions src/solver/variable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ set(SRC_VARIABLE_ECONOMY
include/antares/solver/variable/economy/links.h

# Variables for Economy
include/antares/solver/variable/economy/max-mrg-utils.h
max-mrg-utils.cpp
include/antares/solver/variable/economy/max-mrg-utils.h
max-mrg-utils.cpp
include/antares/solver/variable/economy/max-mrg.h
include/antares/solver/variable/economy/price.h
include/antares/solver/variable/economy/balance.h
Expand All @@ -106,6 +106,7 @@ set(SRC_VARIABLE_ECONOMY
include/antares/solver/variable/economy/dtgMarginAfterCsr.h
include/antares/solver/variable/economy/spilledEnergy.h
include/antares/solver/variable/economy/dispatchableGeneration.h
include/antares/solver/variable/economy/minOfDispatchableGen.h
include/antares/solver/variable/economy/renewableGeneration.h
include/antares/solver/variable/economy/thermalAirPollutantEmissions.h
include/antares/solver/variable/economy/productionByDispatchablePlant.h
Expand All @@ -129,7 +130,7 @@ set(SRC_VARIABLE_ECONOMY
include/antares/solver/variable/economy/links/congestionFeeAbs.h
include/antares/solver/variable/economy/links/marginalCost.h
include/antares/solver/variable/economy/links/congestionProbability.h
include/antares/solver/variable/economy/overallCostCsr.h
include/antares/solver/variable/economy/overallCostCsr.h

# Binding constraints
include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h
Expand Down
73 changes: 38 additions & 35 deletions src/solver/variable/include/antares/solver/variable/economy/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "lolpCsr.h"
#include "max-mrg-csr.h"
#include "max-mrg.h"
#include "minOfDispatchableGen.h"
#include "nbOfDispatchedUnits.h"
#include "nonProportionalCost.h"
#include "operatingCost.h"
Expand Down Expand Up @@ -119,41 +120,43 @@ typedef // Prices
<TimeSeriesValuesSolar // Solar
// Other
<DispatchableGeneration // All dispatchable generation
<RenewableGeneration // All renewable generation
<HydroStorage // Hydro Storage Generation
<Pumping // Pumping generation
<ReservoirLevel // Reservoir levels
<Inflows // Hydraulic inflows
<Overflows // Hydraulic overflows
<WaterValue // Water values
<HydroCost // Hydro costs
<STSbyGroup<STstorageInjectionByCluster<STstorageWithdrawalByCluster<
STstorageLevelsByCluster<STstorageCashFlowByCluster<
UnsupliedEnergy // Unsuplied Energy
<UnsupliedEnergyCSR // Unsupplied energy CSR
<DomesticUnsuppliedEnergy // Domestic Unsupplied Energy
<LMRViolations // LMR Violations
<SpilledEnergy // Spilled Energy
<LOLD // LOLD
<LOLD_CSR<
LOLP // LOLP
<LOLP_CSR<AvailableDispatchGen<DispatchableGenMargin<
DtgMarginCsr // DTG MRG CSR
<Marge<MaxMrgCsr<NonProportionalCost<
NonProportionalCostByDispatchablePlant // Startup
// cost +
// Fixed cost
// per
// thermal
// plant
// detail
<NbOfDispatchedUnits // Number of Units Dispatched
<NbOfDispatchedUnitsByPlant // Number of Units
// Dispatched by plant
<ProfitByPlant
// Links
<Variable::Economy::Links // All links
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<MinOfDispatchableGen // = min(thermal production,
// minGenModulation * unit count * nominal capacity)
<RenewableGeneration // All renewable generation
<HydroStorage // Hydro Storage Generation
<Pumping // Pumping generation
<ReservoirLevel // Reservoir levels
<Inflows // Hydraulic inflows
<Overflows // Hydraulic overflows
<WaterValue // Water values
<HydroCost // Hydro costs
<STSbyGroup<STstorageInjectionByCluster<STstorageWithdrawalByCluster<
STstorageLevelsByCluster<STstorageCashFlowByCluster<
UnsupliedEnergy // Unsuplied Energy
<UnsupliedEnergyCSR // Unsupplied energy CSR
<DomesticUnsuppliedEnergy // Domestic Unsupplied Energy
<LMRViolations // LMR Violations
<SpilledEnergy // Spilled Energy
<LOLD // LOLD
<LOLD_CSR<
LOLP // LOLP
<LOLP_CSR<AvailableDispatchGen<DispatchableGenMargin<
DtgMarginCsr // DTG MRG CSR
<Marge<MaxMrgCsr<NonProportionalCost<
NonProportionalCostByDispatchablePlant // Startup
// cost +
// Fixed cost
// per
// thermal
// plant
// detail
<NbOfDispatchedUnits // Number of Units Dispatched
<NbOfDispatchedUnitsByPlant // Number of Units
// Dispatched by plant
<ProfitByPlant
// Links
<Variable::Economy::Links // All links
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
VariablesPerArea;

/*!
Expand Down
Loading
Loading