-
Notifications
You must be signed in to change notification settings - Fork 394
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
Performance refactor for Schedule:File #8795
Changes from 19 commits
c672e80
7c3eada
f7345b3
3b0ad93
e8759fb
572729f
c3d9613
ddad276
f68ec73
d81d886
9ed3f00
88cc194
43a26f3
69518f2
70f3713
ca7692e
0654156
f06a6fc
c1dc928
5a4a046
5a60d62
5a8a285
bd12208
f760a95
c2c88f8
cc095be
b0acb76
6d21e92
5e6ef79
fe51879
5e8ed20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,9 @@ | |
#ifndef ScheduleManager_hh_INCLUDED | ||
#define ScheduleManager_hh_INCLUDED | ||
|
||
// C++ Headers | ||
#include <set> | ||
|
||
// ObjexxFCL Headers | ||
#include <ObjexxFCL/Array1D.hh> | ||
#include <ObjexxFCL/Array1S.hh> | ||
|
@@ -328,6 +331,109 @@ namespace ScheduleManager { | |
|
||
int GetNumberOfSchedules(EnergyPlusData &state); | ||
|
||
struct CSVRow | ||
{ | ||
std::string_view operator[](std::size_t index) const; | ||
std::size_t rowEnd(); | ||
std::string delimiter{'*'}; // eg. comma in CSV | ||
void readNextRow(std::istream &str); | ||
|
||
private: | ||
std::string m_line; | ||
std::vector<int> m_data; | ||
}; | ||
|
||
std::istream &operator>>(std::istream &str, CSVRow &data); | ||
|
||
void PreProcessIDF(EnergyPlus::EnergyPlusData &state, int &SchNum, int NumCommaFileSchedules); | ||
|
||
struct schedInputIdfPreprocessObject | ||
{ | ||
std::string name; // <- can inherit from parent sched class | ||
std::string fileName; // <- can inherit from parent sched class | ||
int ScheduleTypePtr{-1}; | ||
int columnOfInterest{-1}; | ||
int numHourlyValues{-1}; | ||
int MinutesPerItem{-1}; | ||
int rowsToSkip{-1}; | ||
bool FileIntervalInterpolated{false}; | ||
std::basic_string<char> columnSeperator{"*"}; | ||
int columnarDataIndex{-1}; // TODO : Figure out what to do here (size_t to int conversion) | ||
int SchNum{-1}; | ||
|
||
schedInputIdfPreprocessObject(std::string name, // <- can inherit from parent sched class | ||
std::string fileName, // <- can inherit from parent sched class | ||
int ScheduleTypePtr = -1, | ||
int columnOfInterest = -1, | ||
int numHourlyValues = -1, | ||
int MinutesPerItem = -1, | ||
int rowsToSkip = -1, | ||
bool FileIntervalInterpolated = false, | ||
std::basic_string<char> columnSeperator = "*", | ||
int SchNum = -1) | ||
{ | ||
|
||
this->name = name; | ||
this->fileName = fileName; | ||
this->ScheduleTypePtr = ScheduleTypePtr; | ||
this->columnOfInterest = columnOfInterest - 1; // - 1 to get index to match with c++ containers (start at 0) | ||
this->numHourlyValues = numHourlyValues; | ||
this->MinutesPerItem = MinutesPerItem; | ||
this->rowsToSkip = rowsToSkip; | ||
this->FileIntervalInterpolated = FileIntervalInterpolated; | ||
this->columnSeperator = columnSeperator; | ||
this->SchNum = SchNum; | ||
} | ||
void setColumnarDataIndex(int incomingData) | ||
{ | ||
this->columnarDataIndex = incomingData; | ||
} | ||
}; | ||
|
||
void PopulateSetOfFilenames(const std::vector<schedInputIdfPreprocessObject> &allIdfSchedData, std::set<std::string> &setOfFilenames); | ||
|
||
struct PreProcessedColumn | ||
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. Objects of this struct will have a vector (vals) that holds the actual schedule values from the CSV file. |
||
{ | ||
std::string name; | ||
int columnOfInterest = -1; | ||
int numHourlyValues = -1; | ||
int MinutesPerItem = -1; | ||
int rowsToSkip = -1; | ||
bool FileIntervalInterpolated = false; | ||
int ScheduleTypePtr = -1; | ||
int SchNum = -1; | ||
int rowCnt = 0; | ||
int numerrors = 0; | ||
std::string fileName; | ||
std::string delimiter; | ||
std::vector<Real64> vals; // rows to skip + number of hours*items/hour | ||
|
||
PreProcessedColumn(std::string name, // <- can inherit from parent sched class | ||
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. We implement constructors here, so emplace_back can be called, which is better than push_back because creating a copy is avoided. |
||
int columnOfInterest, | ||
int numHourlyValues, | ||
int MinutesPerItem, | ||
int rowsToSkip, | ||
bool FileIntervalInterpolated, | ||
std::string fileName, | ||
std::string delimiter, | ||
int ScheduleTypePtr, | ||
int SchNum, | ||
std::vector<Real64> vals) | ||
{ | ||
this->name = name; // <- can inherit from parent sched class | ||
this->columnOfInterest = columnOfInterest; | ||
this->numHourlyValues = numHourlyValues; | ||
this->MinutesPerItem = MinutesPerItem; | ||
this->rowsToSkip = rowsToSkip; | ||
this->FileIntervalInterpolated = FileIntervalInterpolated; | ||
this->fileName = fileName; | ||
this->delimiter = delimiter; | ||
this->ScheduleTypePtr = ScheduleTypePtr; | ||
this->SchNum = SchNum; | ||
this->vals = vals; | ||
} | ||
}; | ||
|
||
} // namespace ScheduleManager | ||
|
||
struct ScheduleManagerData : BaseGlobalStruct | ||
|
@@ -355,6 +461,10 @@ struct ScheduleManagerData : BaseGlobalStruct | |
Array1D<ScheduleManager::WeekScheduleData> WeekSchedule; // Week Schedule Storage | ||
Array1D<ScheduleManager::ScheduleData> Schedule; // Schedule Storage | ||
|
||
// Schedule:File variables | ||
std::vector<ScheduleManager::schedInputIdfPreprocessObject> allIdfSchedData; | ||
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. A vector of schedInputIdfPreprocessObject type. We will add the IDF data about each Schedule:File object to this vector as schedInputIdfPreprocessObject elements. |
||
std::vector<ScheduleManager::PreProcessedColumn> columnarData; | ||
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. A vector of PreProcessedColumn objects. This will hold the schedule data that will be later inserted into the schedule data structure. |
||
|
||
void clear_state() override | ||
{ | ||
CheckScheduleValueMinMaxRunOnceOnly = true; | ||
|
@@ -376,6 +486,9 @@ struct ScheduleManagerData : BaseGlobalStruct | |
DaySchedule.clear(); // Day Schedule Storage | ||
WeekSchedule.clear(); // Week Schedule Storage | ||
Schedule.clear(); // Schedule Storage | ||
|
||
allIdfSchedData.clear(); | ||
columnarData.clear(); | ||
} | ||
}; | ||
|
||
|
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.
Objects of this struct will hold the IDF file info about a particular Schedule:File that is read by the getObjectItem function. Implementing it like this hoping to bring a more object-oriented approach to this module.