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
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/windows-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ on:
env:
GITHUB_TOKEN: ${{ github.token }}
IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }}
RUN_SIMPLE_TESTS: ${{ github.event_name == 'push' || inputs.run-tests == 'true' }}
RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule' || inputs.run-tests == 'true' }}
RUN_SIMPLE_TESTS: 'false'
RUN_EXTENDED_TESTS: 'false'
REF: ${{ inputs.target_branch =='' && github.ref || inputs.target_branch}}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <map>
#include <memory>
#include <ranges>
#include <set>
#include <vector>

Expand Down Expand Up @@ -293,6 +294,16 @@ class ThermalCluster final: public Cluster, public std::enable_shared_from_this<
*/
std::vector<double> PthetaInf;

bool hasMinGen()
{
if (!hasMinGen_.has_value())
{
hasMinGen_ = std::ranges::any_of(PthetaInf,
[](double& e) { return !Utils::isZero(e); });
}
return hasMinGen_.value();
}

//! Data for the preprocessor
std::unique_ptr<PreproAvailability> prepro;

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

private:
std::optional<bool> hasMinGen_;
// 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
6 changes: 3 additions & 3 deletions src/libs/antares/study/study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,12 +1422,12 @@ 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;
}
}
}
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
8 changes: 5 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,9 +106,11 @@ 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
include/antares/solver/variable/economy/minDispatchableGenByPlant.h
include/antares/solver/variable/economy/productionByRenewablePlant.h
include/antares/solver/variable/economy/npCostByDispatchablePlant.h
include/antares/solver/variable/economy/nbOfDispatchedUnitsByPlant.h
Expand All @@ -129,7 +131,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
75 changes: 40 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,8 @@
#include "lolpCsr.h"
#include "max-mrg-csr.h"
#include "max-mrg.h"
#include "minDispatchableGenByPlant.h"
#include "minOfDispatchableGen.h"
#include "nbOfDispatchedUnits.h"
#include "nonProportionalCost.h"
#include "operatingCost.h"
Expand Down Expand Up @@ -106,6 +108,7 @@ typedef // Prices
<ThermalAirPollutantEmissions // Overall pollutant emissions(from all thermal dispatchable
// clusters) Production by thermal cluster
<ProductionByDispatchablePlant // Energy generated by thermal dispatchable clusters
<MinDispatchableGenByPlant // Minimum generation by dispatchable cluster
<ProductionByRenewablePlant // Energy generated by renewable clusters (must-run)
<Balance // Nodal Energy Balance
// Misc Gen.
Expand All @@ -119,41 +122,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