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

Feature/ant 361 new link var reduced cost #227

Open
wants to merge 3 commits into
base: New-Antares-Emulator-4
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
2 changes: 2 additions & 0 deletions src/solver/cmake/variable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ set(SRC_VARIABLE_ECONOMY
variable/economy/links/hurdleCosts.h
variable/economy/links/congestionFee.h
variable/economy/links/congestionFeeAbs.h
variable/economy/links/linkBaseCost.h
variable/economy/links/marginalCost.h
variable/economy/links/reducedCost.h
variable/economy/links/congestionProbability.h
)
source_group("variable\\economy" FILES ${SRC_VARIABLE_ECONOMY})
Expand Down
4 changes: 3 additions & 1 deletion src/solver/variable/adequacy/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
# include "../economy/links/congestionFee.h"
# include "../economy/links/congestionFeeAbs.h"
# include "../economy/links/marginalCost.h"
# include "../economy/links/reducedCost.h"
# include "../economy/links/congestionProbability.h"


Expand All @@ -95,9 +96,10 @@ namespace Adequacy
< Variable::Economy::CongestionFee // Congestion Fee
< Variable::Economy::CongestionFeeAbs // Congestion Fee (Abs)
< Variable::Economy::MarginalCost // Marginal Cost
< Variable::Economy::ReducedCost // Reduced Cost
< Variable::Economy::CongestionProbability // Congestion Probability (+/-)
< Variable::Economy::HurdleCosts // Hurdle costs
< > > > > > > > > VariablePerLink;
< > > > > > > > > > VariablePerLink;
// forward declaration
class Links;

Expand Down
4 changes: 3 additions & 1 deletion src/solver/variable/economy/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
# include "links/congestionFee.h"
# include "links/congestionFeeAbs.h"
# include "links/marginalCost.h"
# include "links/reducedCost.h"
# include "links/congestionProbability.h"


Expand All @@ -106,9 +107,10 @@ namespace Economy
< CongestionFee // Congestion Fee
< CongestionFeeAbs // Congestion Fee (Abs)
< MarginalCost // Marginal Cost
< ReducedCost // Reduced Cost
< CongestionProbability // Congestion Probability (+/-)
< HurdleCosts // Hurdle costs
< > > > > > > > > > VariablePerLink;
< > > > > > > > > > > VariablePerLink;
// forward declaration
class Links;

Expand Down
289 changes: 289 additions & 0 deletions src/solver/variable/economy/links/linkBaseCost.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
/*
** Copyright 2007-2018 RTE
** Authors: Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** There are special exceptions to the terms and conditions of the
** license as they are applied to this software. View the full text of
** the exceptions in file COPYING.txt in the directory of this software
** distribution
**
** 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
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>.
**
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
*/
#ifndef __SOLVER_VARIABLE_ECONOMY_LinkBaseCost_H__
# define __SOLVER_VARIABLE_ECONOMY_LinkBaseCost_H__

# include "../../variable.h"


namespace Antares
{
namespace Solver
{
namespace Variable
{
namespace Economy
{
struct VCardLinkBaseCost
{
//! 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;

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

typedef IntermediateValues IntermediateValuesBaseType;
typedef IntermediateValues* IntermediateValuesType;

}; // class VCard


/*!
** \brief LinkBase LinkBaseCost
*/
template<class NextT = Container::EndOfList, class VCardChild = VCardLinkBaseCost>
class LinkBaseCost : public Variable::IVariable<LinkBaseCost<NextT, VCardChild>, NextT, VCardChild>
{
public:
//! Type of the next static variable
typedef NextT NextType;
//! VCard
typedef VCardChild VCardType;
//! Ancestor
typedef Variable::IVariable<LinkBaseCost<NextT, VCardChild>, 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:

~LinkBaseCost()
{
delete[] pValuesForTheCurrentYear;
}

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

// Average on all years
AncestorType::pResults.initializeFromStudy(study);
AncestorType::pResults.reset();
AncestorType::pResults.averageMaxValue(study.runtime->rangeLimits.year[Data::rangeCount]);
AncestorType::pResults.stdDeviationMaxValue(study.runtime->rangeLimits.year[Data::rangeCount]);

// Intermediate values
pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel];
for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);

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

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

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

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

void simulationBegin()
{
// Next
NextType::simulationBegin();
}

void simulationEnd()
{
NextType::simulationEnd();
}


void yearBegin(uint year, unsigned int numSpace)
{
// Reset
pValuesForTheCurrentYear[numSpace].reset();
// Next variable
NextType::yearBegin(year, numSpace);
}

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

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

void yearEndBuild(State& state, unsigned int year)
{

// Next variable
NextType::yearEndBuild(state, year);
}

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

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

void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear, unsigned int nbYearsForCurrentSummary)
{
for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
{
// Merge all those values with the global results
AncestorType::pResults.merge(numSpaceToYear[numSpace], pValuesForTheCurrentYear[numSpace]);
}

// Next variable
NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
}

void hourBegin(uint hourInTheYear)
{
// Next variable
NextType::hourBegin(hourInTheYear);
}

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

void hourForEachThermalCluster(State& state, unsigned int numSpace)
{
// Next item in the list
NextType::hourForEachThermalCluster(state, numSpace);
}

void hourEnd(State& state, uint hourInTheYear)
{
// Next
NextType::hourEnd(state, hourInTheYear);
}

void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
{
// Next
NextType::buildDigest(results, digestLevel, dataLevel);
}

Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(uint, uint numSpace) const
{
return pValuesForTheCurrentYear[numSpace].hour;
}

void localBuildAnnualSurveyReport(SurveyResults& results, int fileLevel, int precision, uint numSpace) const
{
// 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();
pValuesForTheCurrentYear[numSpace].template
buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
}
}


protected:
//! Intermediate values for each year
typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
unsigned int pNbYearsParallel;

}; // class LinkBaseCost





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

#endif // __SOLVER_VARIABLE_ECONOMY_LinkBaseCost_H__

Loading