-
Notifications
You must be signed in to change notification settings - Fork 25
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
Data for modeler (epic 4.1) #2577
base: develop
Are you sure you want to change the base?
Changes from 22 commits
8459ed0
df7656c
d6db716
2c2b769
7701b5b
448ca34
252a670
60cf26b
a12cb4b
99c2a7f
1816792
2ad9df2
965173f
fe02503
a73c08d
ce46a25
12f6d0c
9d4d566
35cd165
62a5437
3eea870
f7829c0
654b97e
6118f76
ea803e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace Antares::Solver::Modeler::Api | ||
{ | ||
|
||
class ILinearProblemData | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Concrete class LinearProblemData now inherits from abstract class ILinearProblemData |
||
{ | ||
virtual double getData(std::string idTimeSeriesSet, | ||
std::string scenarioGroup, | ||
unsigned int scenario, | ||
unsigned int hour) | ||
= 0; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::Api |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
set(SRC_DATA_SERIES | ||
include/antares/solver/modeler/dataSeries/dataSeries.h | ||
include/antares/solver/modeler/dataSeries/timeSeriesSet.h | ||
include/antares/solver/modeler/dataSeries/dataSeriesRepo.h | ||
include/antares/solver/modeler/dataSeries/scenarioGroupRepo.h | ||
include/antares/solver/modeler/dataSeries/linearProblemData.h | ||
|
||
timeSeriesSet.cpp | ||
dataSeriesRepo.cpp | ||
scenarioGroupRepo.cpp | ||
linearProblemData.cpp | ||
) | ||
|
||
add_library(data-series-lib ${SRC_DATA_SERIES}) | ||
set_target_properties(data-series-lib PROPERTIES LINKER_LANGUAGE CXX) | ||
|
||
target_link_libraries(data-series-lib | ||
PUBLIC | ||
modeler_api | ||
) | ||
|
||
target_include_directories(data-series-lib | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "antares/solver/modeler/dataSeries/dataSeriesRepo.h" | ||
|
||
#include <stdexcept> | ||
|
||
namespace Antares::Solver::Modeler::DataSeries | ||
{ | ||
void DataSeriesRepository::addDataSeries(std::unique_ptr<IDataSeries> dataSeries) | ||
{ | ||
std::string name = dataSeries->name(); | ||
dataSeries_[name] = std::move(dataSeries); | ||
} | ||
|
||
IDataSeries& DataSeriesRepository::getDataSeries(std::string setId) | ||
{ | ||
std::string error_message = err_prefix; | ||
if (dataSeries_.empty()) | ||
{ | ||
error_message += "empty"; | ||
throw std::invalid_argument(error_message); | ||
} | ||
if (!dataSeries_.contains(setId)) | ||
{ | ||
error_message += "data series '" + setId + "' does not exist"; | ||
throw std::invalid_argument(error_message); | ||
} | ||
return *(dataSeries_[setId]); | ||
} | ||
} // namespace Antares::Solver::Modeler::DataSeries |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace Antares::Solver::Modeler::DataSeries | ||
{ | ||
|
||
class IDataSeries | ||
{ | ||
public: | ||
IDataSeries(std::string name): | ||
name_(name) | ||
{ | ||
} | ||
|
||
virtual double getData(unsigned int rank, unsigned int hour) = 0; | ||
|
||
std::string name() | ||
{ | ||
return name_; | ||
} | ||
|
||
private: | ||
std::string name_; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::DataSeries |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
#pragma once | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
|
||
#include "dataSeries.h" | ||
|
||
namespace Antares::Solver::Modeler::DataSeries | ||
{ | ||
|
||
class DataSeriesRepository | ||
{ | ||
public: | ||
void addDataSeries(std::unique_ptr<IDataSeries> dataSeries); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About |
||
IDataSeries& getDataSeries(std::string setId); | ||
|
||
private: | ||
std::map<std::string, std::unique_ptr<IDataSeries>> dataSeries_; | ||
std::string err_prefix = "Data series repo : "; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::DataSeries |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
#pragma once | ||
#include <map> | ||
#include <string> | ||
|
||
namespace Antares::Solver::Modeler::DataSeries | ||
{ | ||
class ScenarioGroupRepository | ||
{ | ||
public: | ||
void addPairScenarioRankToGroup(std::string groupId, | ||
std::pair<unsigned, unsigned> scenarioToRank); | ||
|
||
unsigned getDataRank(std::string groupId, unsigned scenario); | ||
|
||
private: | ||
std::map<std::string, std::map<unsigned, unsigned>> scenarioGroups_; | ||
}; | ||
} // namespace Antares::Solver::Modeler::DataSeries |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "dataSeries.h" | ||
|
||
namespace Antares::Solver::Modeler::DataSeries | ||
{ | ||
class TimeSeriesSet: public IDataSeries | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Class TimeSeriesSet is supposed to be out of epic 4.1's scope. |
||
{ | ||
public: | ||
explicit TimeSeriesSet(std::string name, unsigned height); | ||
void add(std::vector<double> ts); | ||
double getData(unsigned rank, unsigned hour) override; | ||
|
||
private: | ||
unsigned height_ = 0; | ||
std::vector<std::vector<double>> tsSet_; | ||
std::string err_prefix_; | ||
}; | ||
|
||
} // namespace Antares::Solver::Modeler::DataSeries |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "include/antares/solver/modeler/dataSeries/scenarioGroupRepo.h" | ||
|
||
#include <stdexcept> | ||
|
||
namespace Antares::Solver::Modeler::DataSeries | ||
{ | ||
void ScenarioGroupRepository::addPairScenarioRankToGroup( | ||
std::string groupId, | ||
std::pair<unsigned, unsigned> scenarioToRank) | ||
{ | ||
scenarioGroups_[groupId] = {scenarioToRank}; | ||
} | ||
|
||
unsigned ScenarioGroupRepository::getDataRank(std::string groupId, unsigned scenario) | ||
{ | ||
if (!scenarioGroups_.contains(groupId)) | ||
{ | ||
std::string error_message = "Group '" + groupId + "' does not exist in group repo."; | ||
throw std::invalid_argument(error_message); | ||
} | ||
|
||
if (!scenarioGroups_.at(groupId).contains(scenario)) | ||
{ | ||
std::string error_message = "In scenario group '" + groupId + "', scenario '" | ||
+ std::to_string(scenario) + "' does not exist."; | ||
throw std::invalid_argument(error_message); | ||
} | ||
|
||
return scenarioGroups_.at(groupId).at(scenario); | ||
} | ||
} // namespace Antares::Solver::Modeler::DataSeries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class LinearProblemData was moved from here (src/solver/modeler/api) to src/solver/modeler/dataSeries