Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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 src/solver/variable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ set(SRC_VARIABLE_ECONOMY
include/antares/solver/variable/economy/all.h
include/antares/solver/variable/economy/economy_base.h
include/antares/solver/variable/economy/links.h
include/antares/solver/variable/economy/economy_base.h

# Variables for Economy
include/antares/solver/variable/economy/max-mrg-utils.h
Expand All @@ -99,8 +100,6 @@ set(SRC_VARIABLE_ECONOMY
include/antares/solver/variable/economy/STStorageWithdrawalByCluster.h
include/antares/solver/variable/economy/STStorageLevelsByCluster.h
include/antares/solver/variable/economy/STStorageCashFlowByCluster.h
include/antares/solver/variable/economy/unsupliedEnergy.h
include/antares/solver/variable/economy/unsupliedEnergyCsr.h
include/antares/solver/variable/economy/priceCSR.h
include/antares/solver/variable/economy/domesticUnsuppliedEnergy.h
include/antares/solver/variable/economy/localMatchingRuleViolations.h
Expand All @@ -124,6 +123,7 @@ set(SRC_VARIABLE_ECONOMY
include/antares/solver/variable/economy/nearPriceCap.h
include/antares/solver/variable/economy/avail-dispatchable-generation.h
include/antares/solver/variable/economy/dispatchable-generation-margin.h
include/antares/solver/variable/economy/unsupliedEnergy.h

# Links
include/antares/solver/variable/economy/links/flowLinear.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
#include "spilledEnergy.h"
#include "thermalAirPollutantEmissions.h"
#include "unsupliedEnergy.h"
#include "unsupliedEnergyCsr.h"
#include "waterValue.h"

namespace Antares::Solver::Variable::Economy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Economy_Base
{
if (Traits::checkCondition(state))
{
pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = Traits::value();
pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = Traits::value(state);
}

// Next variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
#pragma once

#include "economy_base.h"
#include "lold_base.h"

namespace Antares::Solver::Variable::Economy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#pragma once

#include "economy_base.h"

namespace Antares::Solver::Variable::Economy
{

Expand All @@ -44,7 +42,7 @@ struct LOLD_Base_Traits

static constexpr uint8_t spatialAggregate = Category::spatialAggregateSumThen1IfPositive;

static double value()
static double value(const State&)
{
return 1.;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#pragma once

#include "economy_base.h"

namespace Antares::Solver::Variable::Economy
{

Expand All @@ -39,7 +37,7 @@ struct LOLP_Base_Traits

static constexpr uint8_t spatialAggregate = Category::spatialAggregateOr;

static double value()
static double value(const State&)
{
return 100.;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,247 +18,97 @@
* 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/>.
*/
#ifndef __SOLVER_VARIABLE_ECONOMY_UnsupliedEnergy_H__
#define __SOLVER_VARIABLE_ECONOMY_UnsupliedEnergy_H__

#include "antares/solver/variable/variable.h"
#pragma once
#include "antares/solver/variable/categories.h"
#include "antares/solver/variable/state.h"
#include "antares/solver/variable/storage/intermediate.h"
#include "antares/solver/variable/storage/results.h"

namespace Antares::Solver::Variable::Economy
{
struct VCardUnsupliedEnergy

struct UnsuppliedEnergyTrait

Check warning on line 31 in src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergy.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Change this "struct" to a "class" or remove its member functions.

See more on https://sonarcloud.io/project/issues?id=AntaresSimulatorTeam_Antares_Simulator&issues=AZqhPsY4zxXXTuaYBxbw&open=AZqhPsY4zxXXTuaYBxbw&pullRequest=3146
{
//! Caption
static std::string Caption()
{
return "UNSP. ENRG";
}

//! Unit
static std::string Unit()
{
return "MWh";
}

//! The short description of the variable
static std::string Description()
{
return "Unsuplied Energy (demand that cannot be satisfied)";
}

//! The expecte results
typedef Results<R::AllYears::Average< // The average values throughout all years
R::AllYears::StdDeviation< // The standard deviation values throughout all years
R::AllYears::Min< // The minimum values throughout all years
R::AllYears::Max< // The maximum values throughout all years
>>>>>
ResultsType;

//! The VCard to look for for calculating spatial aggregates
typedef VCardUnsupliedEnergy VCardForSpatialAggregate;

//! Data Level
static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
//! File level (provided by the type of the results)
static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
& (Category::FileLevel::id
| Category::FileLevel::va);
//! Precision (views)
static constexpr uint8_t precision = Category::all;
//! Indentation (GUI)
static constexpr uint8_t nodeDepthForGUI = +0;
//! Decimal precision
static constexpr uint8_t decimal = 0;
//! Number of columns used by the variable (One ResultsType per column)
static constexpr int columnCount = 1;
//! The Spatial aggregation
static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
static constexpr uint8_t spatialAggregatePostProcessing = 0;
//! Intermediate values
static constexpr uint8_t hasIntermediateValues = 1;
//! Can this variable be non applicable (0 : no, 1 : yes)
static constexpr uint8_t isPossiblyNonApplicable = 0;

typedef IntermediateValues IntermediateValuesBaseType;
typedef std::vector<IntermediateValues> IntermediateValuesType;

using IntermediateValuesTypeForSpatialAg = std::unique_ptr<IntermediateValuesBaseType[]>;

}; // class VCard

/*!
** \brief C02 Average value of the overrall UnsupliedEnergy emissions expected from all
** the thermal dispatchable clusters
*/
template<class NextT = Container::EndOfList>
class UnsupliedEnergy
: public Variable::IVariable<UnsupliedEnergy<NextT>, NextT, VCardUnsupliedEnergy>
{
public:
//! Type of the next static variable
typedef NextT NextType;
//! VCard
typedef VCardUnsupliedEnergy VCardType;
//! Ancestor
typedef Variable::IVariable<UnsupliedEnergy<NextT>, NextT, VCardType> AncestorType;

//! List of expected results
typedef typename VCardType::ResultsType ResultsType;

typedef VariableAccessor<ResultsType, VCardType::columnCount> VariableAccessorType;

enum
{
//! How many items have we got
count = 1 + NextT::count,
};

template<int CDataLevel, int CFile>
struct Statistics
{
enum
{
count = ((VCardType::categoryDataLevel & CDataLevel
&& VCardType::categoryFileLevel & CFile)
? (NextType::template Statistics<CDataLevel, CFile>::count
+ VCardType::columnCount * ResultsType::count)
: NextType::template Statistics<CDataLevel, CFile>::count),
};
};

public:
void initializeFromStudy(Data::Study& study)
{
pNbYearsParallel = study.maxNbYearsInParallel;

// Intermediate values
InitializeResultsFromStudy(AncestorType::pResults, study);

pValuesForTheCurrentYear.resize(pNbYearsParallel);
for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
{
pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
}

// Next
NextType::initializeFromStudy(study);
}

template<class R>
static void InitializeResultsFromStudy(R& results, Data::Study& study)
{
VariableAccessorType::InitializeAndReset(results, study);
}

void initializeFromArea(Data::Study* study, Data::Area* area)
{
// Next
NextType::initializeFromArea(study, area);
}

void initializeFromLink(Data::Study* study, Data::AreaLink* link)
{
// Next
NextType::initializeFromAreaLink(study, link);
}

void simulationBegin()
{
for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
{
pValuesForTheCurrentYear[numSpace].reset();
}
// Next
NextType::simulationBegin();
}

void simulationEnd()
static void yearBeginLogic(unsigned, IntermediateValues& iv, Data::Area*, unsigned)
{
NextType::simulationEnd();
iv.reset();
}

void yearBegin(unsigned int year, unsigned int numSpace)
static void setValue(const State& state, IntermediateValues& iv, unsigned)
{
// Reset the values for the current year
pValuesForTheCurrentYear[numSpace].reset();

// Next variable
NextType::yearBegin(year, numSpace);
iv[state.hourInTheYear] = state.hourlyResults
->ValeursHorairesDeDefaillancePositive[state.hourInTheWeek];
}

void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
static void computeStats(IntermediateValues& iv)
{
// Next variable
NextType::yearEndBuild(state, year, numSpace);
iv.computeStatisticsForTheCurrentYear();
}

void yearEnd(unsigned int year, unsigned int numSpace)
static bool checkCondition(const State&)
{
// Compute all statistics for the current year (daily,weekly,monthly)
pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();

// Next variable
NextType::yearEnd(year, numSpace);
return true;
}

void computeSummary(unsigned int year, unsigned int numSpace)
static double value(const State& state)
{
// Merge all those values with the global results
AncestorType::pResults.merge(year, pValuesForTheCurrentYear[numSpace]);

// Next variable
NextType::computeSummary(year, numSpace);
return state.hourlyResults->ValeursHorairesDeDefaillancePositive[state.hourInTheWeek];
}
};

void hourBegin(unsigned int hourInTheYear)
struct UnsuppliedEnergyCSRTrait: UnsuppliedEnergyTrait

Check warning on line 84 in src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergy.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Change this "struct" to a "class" or remove its member functions.

See more on https://sonarcloud.io/project/issues?id=AntaresSimulatorTeam_Antares_Simulator&issues=AZqhPsY4zxXXTuaYBxbx&open=AZqhPsY4zxXXTuaYBxbx&pullRequest=3146
{
static std::string Caption()
{
// Next variable
NextType::hourBegin(hourInTheYear);
return "UNSP. ENRG CSR";
}

void hourForEachArea(State& state, unsigned int numSpace)
static std::string Description()
{
// Total UnsupliedEnergy emissions
pValuesForTheCurrentYear[numSpace][state.hourInTheYear] =
// Current Hydro Storage generation
state.hourlyResults->ValeursHorairesDeDefaillancePositive[state.hourInTheWeek];

// Next variable
NextType::hourForEachArea(state, numSpace);
return "Unsuplied Energy after CSR (demand that cannot be satisfied)";
}

Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
unsigned int,
unsigned int numSpace) const
static void setValue(const State& state, IntermediateValues& iv, unsigned)
{
return pValuesForTheCurrentYear[numSpace].hour;
iv[state.hourInTheYear] = state.hourlyResults
->ValeursHorairesDeDefaillancePositiveCSR[state.hourInTheWeek];
}

void localBuildAnnualSurveyReport(SurveyResults& results,
int fileLevel,
int precision,
unsigned int numSpace) const
static double value(const State& state)
{
// Initializing external pointer on current variable non applicable status
results.isCurrentVarNA = AncestorType::isNonApplicable;

if (AncestorType::isPrinted[0])
{
// Write the data for the current year
results.variableCaption = VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace]
.template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
}
return state.hourlyResults->ValeursHorairesDeDefaillancePositiveCSR[state.hourInTheWeek];
}
};

private:
//! Intermediate values for each year
typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
unsigned int pNbYearsParallel;
template<class NextT = Container::EndOfList>
using UnsupliedEnergy = Economy_Base<UnsuppliedEnergyTrait, NextT>;

}; // class UnsupliedEnergy
template<class NextT = Container::EndOfList>
using UnsupliedEnergyCSR = Economy_Base<UnsuppliedEnergyCSRTrait, NextT>;

} // namespace Antares::Solver::Variable::Economy

#endif // __SOLVER_VARIABLE_ECONOMY_UnsupliedEnergy_H__
Loading
Loading