Skip to content

Commit

Permalink
Fix Variable::Join
Browse files Browse the repository at this point in the history
Use Join<A, Join<B, C>> instead of Join<A, B, C>
  • Loading branch information
flomnes committed May 24, 2024
1 parent a1d769e commit 43bdb97
Show file tree
Hide file tree
Showing 60 changed files with 163 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ typedef Variable::Join<
// Variables for each area / links attached to the areas
Variable::Areas<VariablesPerArea>,
// Variables for each set of areas
Variable::SetsOfAreas<VariablesPerSetOfAreas>,
Variable::Join<Variable::SetsOfAreas<VariablesPerSetOfAreas>,
// Variables for each binding constraint
Variable::BindingConstraints<VariablesPerBindingConstraints>>
Variable::BindingConstraints<VariablesPerBindingConstraints>>>
ItemList;

/*!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ class OverallCost: public Variable::IVariable<OverallCost<NextT>, NextT, VCardOv
NextType::yearEndBuildForEachThermalCluster(state, year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ class SpilledEnergy: public Variable::IVariable<SpilledEnergy<NextT>, NextT, VCa
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,14 @@ class BindingConstraints
void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
unsigned int nbYearsForCurrentSummary);

void simulationBegin();
void simulationEnd();

void yearBegin(uint year, uint numSpace);
void yearEnd(uint year, uint numSpace);

void yearEndBuild(State& state, uint year, uint numSpace);

void weekBegin(State& state);

void hourBegin(uint hourInTheYear);
Expand All @@ -148,6 +153,12 @@ class BindingConstraints

uint64_t memoryUsage() const;

template<class V>
void yearEndSpatialAggregates(V&, uint, uint)
{
// do nothing
}

template<class I>
static void provideInformations(I& infos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,30 @@ inline void BindingConstraints<NextT>::provideInformations(I& infos)
}
}

template<class NextT>
void BindingConstraints<NextT>::simulationBegin()
{
for (auto& bc : pBindConstraints)
{
bc.simulationBegin();
}
}


template<class NextT>
void BindingConstraints<NextT>::simulationEnd()
{
for (auto& bc : pBindConstraints)
{
bc.simulationEnd();
}
}

template<class NextT>
void BindingConstraints<NextT>::yearEndBuild(State& state, uint year, uint numSpace)
{
}

template<class NextT>
void BindingConstraints<NextT>::initializeFromStudy(Data::Study& study)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ class TimeSeriesValuesHydro
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
31 changes: 8 additions & 23 deletions src/solver/variable/include/antares/solver/variable/commons/join.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,19 @@ struct VCardJoin
/*!
** \brief Join
*/
template<class LeftT, class RightT, class BindConstT>
class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::Default, VCardJoin>,
template<class LeftT, class RightT>
class Join: public Variable::IVariable<Join<LeftT, RightT>, Yuni::Default, VCardJoin>,
public LeftT,
public RightT,
public BindConstT
public RightT
{
public:
typedef LeftT LeftType;
typedef RightT RightType;
typedef BindConstT BindConstType;

//! VCard
typedef VCardJoin VCardType;
//! Ancestor
typedef Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::Default, VCardType>
typedef Variable::IVariable<Join<LeftT, RightT>, Yuni::Default, VCardType>
AncestorType;

//! List of expected results
Expand All @@ -120,8 +118,7 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
{
count = LeftType::template Statistics < CDataLevel,
CFile > ::count + RightType::template Statistics < CDataLevel,
CFile > ::count + BindConstType::template Statistics < CDataLevel,
CFile > ::count,
CFile > ::count
};
};

Expand All @@ -136,15 +133,13 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
{
LeftType::RetrieveVariableList(predicate);
RightType::RetrieveVariableList(predicate);
BindConstType::RetrieveVariableList(predicate);
}

public:
void initializeFromStudy(Data::Study& study)
{
LeftType::initializeFromStudy(study);
RightType::initializeFromStudy(study);
BindConstType::initializeFromStudy(study);
}

void initializeFromArea(Data::Study* study, Data::Area* area)
Expand Down Expand Up @@ -183,7 +178,6 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
{
LeftType::yearBegin(year, numSpace);
RightType::yearBegin(year, numSpace);
BindConstType::yearBegin(year, numSpace);
}

void yearEndBuildPrepareDataForEachThermalCluster(State& state, uint year)
Expand All @@ -203,29 +197,26 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
LeftType::yearEndBuild(state, year, numSpace);
RightType::yearEndBuild(state, year);
RightType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
{
LeftType::yearEnd(year, numSpace);
RightType::yearEnd(year, numSpace);
BindConstType::yearEnd(year, numSpace);
}

void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
unsigned int nbYearsForCurrentSummary)
{
LeftType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
RightType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
BindConstType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
}

void weekBegin(State& state)
{
LeftType::weekBegin(state);
RightType::weekBegin(state);
BindConstType::weekBegin(state);
}

void weekForEachArea(State& state, unsigned int numSpace)
Expand All @@ -244,7 +235,6 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
{
LeftType::hourBegin(hourInTheYear);
RightType::hourBegin(hourInTheYear);
BindConstType::hourBegin(hourInTheYear);
}

void hourForEachArea(State& state, unsigned int numSpace)
Expand All @@ -263,7 +253,6 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
{
LeftType::hourEnd(state, hourInTheYear);
RightType::hourEnd(state, hourInTheYear);
BindConstType::hourEnd(state, hourInTheYear);
}

void buildSurveyReport(SurveyResults& results,
Expand All @@ -273,7 +262,6 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
{
LeftType::buildSurveyReport(results, dataLevel, fileLevel, precision);
RightType::buildSurveyReport(results, dataLevel, fileLevel, precision);
BindConstType::buildSurveyReport(results, dataLevel, fileLevel, precision);
}

void buildAnnualSurveyReport(SurveyResults& results,
Expand All @@ -284,7 +272,6 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
{
LeftType::buildAnnualSurveyReport(results, dataLevel, fileLevel, precision, numSpace);
RightType::buildAnnualSurveyReport(results, dataLevel, fileLevel, precision, numSpace);
BindConstType::buildAnnualSurveyReport(results, dataLevel, fileLevel, precision, numSpace);
}

void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
Expand Down Expand Up @@ -312,7 +299,7 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
void computeSpatialAggregateWith(O& out, const Data::Area* area, uint numSpace)
{
LeftType ::template computeSpatialAggregateWith<SearchVCardT, O>(out, area, numSpace);
RightType::template computeSpatialAggregateWith<SearchVCardT, O>(out, area);
RightType::template computeSpatialAggregateWith<SearchVCardT, O>(out, area, numSpace);
}

template<class V>
Expand Down Expand Up @@ -344,15 +331,14 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De

uint64_t memoryUsage() const
{
return LeftType::memoryUsage() + RightType::memoryUsage() + BindConstType::memoryUsage();
return LeftType::memoryUsage() + RightType::memoryUsage();
}

template<class I>
static void provideInformations(I& infos)
{
LeftType ::provideInformations(infos);
RightType::provideInformations(infos);
BindConstType::provideInformations(infos);
}

template<class VCardToFindT>
Expand Down Expand Up @@ -393,7 +379,6 @@ class Join: public Variable::IVariable<Join<LeftT, RightT, BindConstT>, Yuni::De
{
LeftType::localBuildAnnualSurveyReport(results, fileLevel, precision);
RightType::localBuildAnnualSurveyReport(results, fileLevel, precision);
BindConstType::localBuildAnnualSurveyReport(results, fileLevel, precision);
}

}; // class Join
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ class TimeSeriesValuesLoad
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ class MiscGenMinusRowPSP
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ class PSP: public Variable::IVariable<PSP<NextT>, NextT, VCardPSP>
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ class RowBalance: public Variable::IVariable<RowBalance<NextT>, NextT, VCardRowB
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ class TimeSeriesValuesSolar
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ class SpatialAggregate
NextType::yearEndBuildForEachThermalCluster(state, year);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(uint year)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ class TimeSeriesValuesWind
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ typedef Variable::Join<
// Variables for each area / links attached to the areas
Variable::Areas<VariablesPerArea>,
// Variables for each set of areas
Variable::SetsOfAreas<VariablesPerSetOfAreas>,
Variable::Join<Variable::SetsOfAreas<VariablesPerSetOfAreas>,
// Variables for each binding constraint
Variable::BindingConstraints<VariablesPerBindingConstraints>>
Variable::BindingConstraints<VariablesPerBindingConstraints>>>
ItemList;

/*!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ class AvailableDispatchGen
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ class Balance: public Variable::IVariable<Balance<NextT>, NextT, VCardBalance>
NextType::yearBegin(year, numSpace);
}

void yearEndBuild(State& state, unsigned int year)
void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
{
// Next variable
NextType::yearEndBuild(state, year);
NextType::yearEndBuild(state, year, numSpace);
}

void yearEnd(unsigned int year, unsigned int numSpace)
Expand Down
Loading

0 comments on commit 43bdb97

Please sign in to comment.