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

ScheduleDay: new timeseries method and interpolation options #5111

Merged
merged 73 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
76f4f41
Introduce new getValues method on ScheduleDay.
joseph-robertson Mar 13, 2024
48ac02d
Stub model test for new method.
joseph-robertson Mar 13, 2024
0242a8c
Formatting.
joseph-robertson Mar 13, 2024
389f6cb
Typo.
joseph-robertson Mar 13, 2024
6e075a3
Update scheduleday files and get new tests passing.
joseph-robertson Mar 14, 2024
27865fa
Return timeseries instead of separate getTimes and getValues.
joseph-robertson Mar 18, 2024
80ef75b
Clean up and try again.
joseph-robertson Mar 18, 2024
f01fba7
Update idd for new interpolation method keys.
joseph-robertson Mar 19, 2024
a365a99
Update model files and tests.
joseph-robertson Mar 19, 2024
d96338a
Update ft and rt files and tests.
joseph-robertson Mar 19, 2024
9fa369a
Get interpolation working on timeseries.
joseph-robertson Mar 19, 2024
3282bda
Stub new AverageInterp in vector files.
joseph-robertson Mar 19, 2024
47d03f3
Take a cut at the average interpolation.
joseph-robertson Mar 21, 2024
aed3dea
One more typo.
joseph-robertson Mar 21, 2024
7bee45b
Move average interp code into AverageInterp.
joseph-robertson Mar 22, 2024
8f1aed5
Formatting.
joseph-robertson Mar 22, 2024
81cfbd0
Cache timeseries results and clear when object changes.
joseph-robertson Mar 25, 2024
07992ed
Add AverageInterp no-op case to matrix cpp.
joseph-robertson Mar 25, 2024
b178a6b
Update docs for new timeseries method.
joseph-robertson Mar 25, 2024
f9a2eae
Set left endpoint of getvalue.
joseph-robertson Mar 25, 2024
d1d7708
Update left endpoint per method and update tests.
joseph-robertson Mar 26, 2024
6c7198e
Merge branch 'develop' into dayschedule-getvalues
joseph-robertson Mar 27, 2024
160585a
Interpolate using seconds instead of days.
joseph-robertson Mar 27, 2024
686b725
Need ti in seconds and not days.
joseph-robertson Mar 27, 2024
e742966
Try updating timestep with cache clear.
joseph-robertson Mar 27, 2024
2ded730
New protected method for clearing ts, and friend timestep.
joseph-robertson Mar 27, 2024
bfb876f
Updates for vt and deprecating interp setter.
joseph-robertson Mar 27, 2024
dd39ffd
Building but tests failing.
joseph-robertson Mar 28, 2024
4af6ee3
Fix the new vt.
joseph-robertson Mar 28, 2024
9be8c90
Remove deprecation of old setter.
joseph-robertson Mar 28, 2024
bb57a4d
Add one more test showing change in getValue for small enough timestep.
joseph-robertson Mar 28, 2024
9b82fed
Merge branch 'develop' into dayschedule-getvalues
joseph-robertson Apr 15, 2024
f8fcada
Merge branch 'develop' into dayschedule-getvalues
jmarrec Apr 18, 2024
6c33a6b
Update comments and release notes.
joseph-robertson Apr 18, 2024
e8b0015
Update ti default to -9999, add assert, update comments.
joseph-robertson Apr 18, 2024
c74f8b6
Few more updates to release notes.
joseph-robertson Apr 18, 2024
d2c195d
Introduce new getValues method on ScheduleDay.
joseph-robertson Mar 13, 2024
5037966
Stub model test for new method.
joseph-robertson Mar 13, 2024
96e9514
Formatting.
joseph-robertson Mar 13, 2024
d55dc20
Typo.
joseph-robertson Mar 13, 2024
a58faef
Update scheduleday files and get new tests passing.
joseph-robertson Mar 14, 2024
94685d5
Return timeseries instead of separate getTimes and getValues.
joseph-robertson Mar 18, 2024
1549488
Clean up and try again.
joseph-robertson Mar 18, 2024
a75a333
Update idd for new interpolation method keys.
joseph-robertson Mar 19, 2024
838df44
Update model files and tests.
joseph-robertson Mar 19, 2024
2b919ab
Update ft and rt files and tests.
joseph-robertson Mar 19, 2024
8eede82
Get interpolation working on timeseries.
joseph-robertson Mar 19, 2024
8da8085
Stub new AverageInterp in vector files.
joseph-robertson Mar 19, 2024
85da8ef
Take a cut at the average interpolation.
joseph-robertson Mar 21, 2024
065d022
One more typo.
joseph-robertson Mar 21, 2024
1104600
Move average interp code into AverageInterp.
joseph-robertson Mar 22, 2024
4af64a0
Formatting.
joseph-robertson Mar 22, 2024
dc202f1
Cache timeseries results and clear when object changes.
joseph-robertson Mar 25, 2024
30fd11d
Add AverageInterp no-op case to matrix cpp.
joseph-robertson Mar 25, 2024
8d50877
Update docs for new timeseries method.
joseph-robertson Mar 25, 2024
825b270
Set left endpoint of getvalue.
joseph-robertson Mar 25, 2024
bbd26f8
Update left endpoint per method and update tests.
joseph-robertson Mar 26, 2024
e257209
Interpolate using seconds instead of days.
joseph-robertson Mar 27, 2024
a22dbb2
Need ti in seconds and not days.
joseph-robertson Mar 27, 2024
1389577
Try updating timestep with cache clear.
joseph-robertson Mar 27, 2024
805f14c
New protected method for clearing ts, and friend timestep.
joseph-robertson Mar 27, 2024
740a0b2
Updates for vt and deprecating interp setter.
joseph-robertson Mar 27, 2024
f20d840
Building but tests failing.
joseph-robertson Mar 28, 2024
881d27c
Fix the new vt.
joseph-robertson Mar 28, 2024
1794d58
Remove deprecation of old setter.
joseph-robertson Mar 28, 2024
e4cef89
Add one more test showing change in getValue for small enough timestep.
joseph-robertson Mar 28, 2024
138cbad
Update comments and release notes.
joseph-robertson Apr 18, 2024
4572fc0
Update ti default to -9999, add assert, update comments.
joseph-robertson Apr 18, 2024
ceba909
Few more updates to release notes.
joseph-robertson Apr 18, 2024
012f076
Missing include
jmarrec Apr 25, 2024
90e86c6
Merge branch 'dayschedule-getvalues' of github.com:NREL/OpenStudio in…
joseph-robertson Apr 25, 2024
fddbc7d
Update assert and get optional timestep object.
joseph-robertson Apr 25, 2024
7493115
Merge branch 'develop' into dayschedule-getvalues
joseph-robertson Apr 25, 2024
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
9 changes: 5 additions & 4 deletions resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -4594,12 +4594,13 @@ OS:Schedule:Day,
\type object-list
\object-list ScheduleTypeLimitsNames
A4, \field Interpolate to Timestep
\note when the interval does not match the user specified timestep a Yes choice will average between the intervals request (to
\note timestep resolution. a No choice will use the interval value at the simulation timestep without regard to if it matches
\note the boundary or not.
\note when the interval does not match the user specified timestep a Average choice will average between the intervals request (to
\note timestep resolution. A No choice will use the interval value at the simulation timestep without regard to if it matches
\note the boundary or not. A Linear choice will interpolate linearly between successive values.
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
\type choice
\default No
\key Yes
\key Average
\key Linear
\key No
N1, \field Hour
\type integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ namespace energyplus {
}
}

if (modelObject.interpolatetoTimestep()) {
scheduleDay.setString(Schedule_Day_IntervalFields::InterpolatetoTimestep, "Average");
} else {
scheduleDay.setString(Schedule_Day_IntervalFields::InterpolatetoTimestep, "No");
}
scheduleDay.setString(Schedule_Day_IntervalFields::InterpolatetoTimestep, modelObject.interpolatetoTimestep());
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved

std::vector<double> values = modelObject.values();
std::vector<openstudio::Time> times = modelObject.times();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,7 @@ namespace energyplus {

s = workspaceObject.getString(Schedule_Day_IntervalFields::InterpolatetoTimestep);
if (s) {
if (openstudio::istringEqual(*s, "No")) {
scheduleDay.setInterpolatetoTimestep(false);
} else if (openstudio::istringEqual(*s, "Linear")) {
scheduleDay.setInterpolatetoTimestep(true);
} else if (openstudio::istringEqual(*s, "Average")) {
scheduleDay.setInterpolatetoTimestep(true);
}
scheduleDay.setInterpolatetoTimestep(*s);
}

//get extensible groups
Expand Down
14 changes: 7 additions & 7 deletions src/energyplus/Test/ScheduleRuleset_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_ScheduleYearWeekDailyToRulesetSimple
EXPECT_EQ(0, scheduleRule.ruleIndex());
ScheduleDay daySchedule = scheduleRule.daySchedule();
EXPECT_EQ(daySchedule.nameString(), "occupants schedule allday1 1");
EXPECT_FALSE(daySchedule.interpolatetoTimestep());
EXPECT_EQ("No", daySchedule.interpolatetoTimestep());
EXPECT_EQ(8u, daySchedule.values().size());
EXPECT_TRUE(scheduleRule.applySunday());
EXPECT_TRUE(scheduleRule.applyMonday());
Expand Down Expand Up @@ -864,7 +864,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_ScheduleYearWeekDailyToRulesetComple
EXPECT_EQ(2, scheduleRule1.ruleIndex());
ScheduleDay daySchedule1 = scheduleRule1.daySchedule();
EXPECT_EQ(daySchedule1.nameString(), "occupants schedule allday1 1");
EXPECT_FALSE(daySchedule1.interpolatetoTimestep());
EXPECT_EQ("No", daySchedule1.interpolatetoTimestep());
EXPECT_EQ(8u, daySchedule1.values().size());
EXPECT_TRUE(scheduleRule1.applySunday());
EXPECT_TRUE(scheduleRule1.applyMonday());
Expand All @@ -888,7 +888,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_ScheduleYearWeekDailyToRulesetComple
EXPECT_EQ(1, scheduleRule2.ruleIndex());
ScheduleDay daySchedule2 = scheduleRule2.daySchedule();
EXPECT_EQ(daySchedule2.nameString(), "occupants schedule allday1 2");
EXPECT_FALSE(daySchedule2.interpolatetoTimestep());
EXPECT_EQ("No", daySchedule2.interpolatetoTimestep());
EXPECT_EQ(8u, daySchedule2.values().size());
EXPECT_TRUE(scheduleRule2.applySunday());
EXPECT_TRUE(scheduleRule2.applyMonday());
Expand All @@ -912,7 +912,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_ScheduleYearWeekDailyToRulesetComple
EXPECT_EQ(0, scheduleRule3.ruleIndex());
ScheduleDay daySchedule3 = scheduleRule3.daySchedule();
EXPECT_EQ(daySchedule3.nameString(), "occupants schedule allday2 1");
EXPECT_FALSE(daySchedule3.interpolatetoTimestep());
EXPECT_EQ("No", daySchedule3.interpolatetoTimestep());
EXPECT_EQ(8u, daySchedule3.values().size());
EXPECT_FALSE(scheduleRule3.applySunday());
EXPECT_FALSE(scheduleRule3.applyMonday());
Expand Down Expand Up @@ -1220,7 +1220,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_ScheduleYearWeekCompactToRulesetComp
EXPECT_EQ(2, scheduleRule1.ruleIndex());
ScheduleDay daySchedule1 = scheduleRule1.daySchedule();
EXPECT_EQ(daySchedule1.nameString(), "occupants schedule allday1 1");
EXPECT_FALSE(daySchedule1.interpolatetoTimestep());
EXPECT_EQ("No", daySchedule1.interpolatetoTimestep());
EXPECT_EQ(8u, daySchedule1.values().size());
EXPECT_TRUE(scheduleRule1.applySunday());
EXPECT_TRUE(scheduleRule1.applyMonday());
Expand All @@ -1244,7 +1244,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_ScheduleYearWeekCompactToRulesetComp
EXPECT_EQ(1, scheduleRule2.ruleIndex());
ScheduleDay daySchedule2 = scheduleRule2.daySchedule();
EXPECT_EQ(daySchedule2.nameString(), "occupants schedule allday1 2");
EXPECT_FALSE(daySchedule2.interpolatetoTimestep());
EXPECT_EQ("No", daySchedule2.interpolatetoTimestep());
EXPECT_EQ(8u, daySchedule2.values().size());
EXPECT_TRUE(scheduleRule2.applySunday());
EXPECT_TRUE(scheduleRule2.applyMonday());
Expand All @@ -1268,7 +1268,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_ScheduleYearWeekCompactToRulesetComp
EXPECT_EQ(0, scheduleRule3.ruleIndex());
ScheduleDay daySchedule3 = scheduleRule3.daySchedule();
EXPECT_EQ(daySchedule3.nameString(), "occupants schedule allday2 1");
EXPECT_FALSE(daySchedule3.interpolatetoTimestep());
EXPECT_EQ("No", daySchedule3.interpolatetoTimestep());
EXPECT_EQ(8u, daySchedule3.values().size());
EXPECT_FALSE(scheduleRule3.applySunday());
EXPECT_FALSE(scheduleRule3.applyMonday());
Expand Down
131 changes: 107 additions & 24 deletions src/model/ScheduleDay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "ScheduleRuleset_Impl.hpp"
#include "ScheduleRule.hpp"
#include "ScheduleRule_Impl.hpp"
#include "Timestep.hpp"
#include "Timestep_Impl.hpp"

#include "../utilities/idf/IdfExtensibleGroup.hpp"
#include <utilities/idd/OS_Schedule_Day_FieldEnums.hxx>
Expand All @@ -25,6 +27,7 @@
#include "../utilities/core/Assert.hpp"

#include "../utilities/time/Time.hpp"
#include "../utilities/data/TimeSeries.hpp"
#include "../utilities/data/Vector.hpp"

namespace openstudio {
Expand Down Expand Up @@ -115,8 +118,10 @@ namespace model {
return !getObject<ScheduleDay>().getModelObjectTarget<ScheduleTypeLimits>(OS_Schedule_DayFields::ScheduleTypeLimitsName);
}

bool ScheduleDay_Impl::interpolatetoTimestep() const {
return getBooleanFieldValue(OS_Schedule_DayFields::InterpolatetoTimestep);
std::string ScheduleDay_Impl::interpolatetoTimestep() const {
boost::optional<std::string> value = getString(OS_Schedule_DayFields::InterpolatetoTimestep, true);
OS_ASSERT(value);
return value.get();
}

bool ScheduleDay_Impl::isInterpolatetoTimestepDefaulted() const {
Expand Down Expand Up @@ -176,42 +181,116 @@ namespace model {
return 0.0;
}

std::vector<double> values = this->values(); // these are already sorted
std::vector<openstudio::Time> times = this->times(); // these are already sorted
TimeSeries ts = this->timeSeries();
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved

unsigned N = times.size();
DateTimeVector dateTimes = ts.dateTimes();
Vector values = ts.values();

unsigned N = dateTimes.size();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmh, starting there you lost me. I hadn't seen this bit when I wrote the comment above, and I hadn't though about a time being requested in between actual timesteps, but this looks wrong to me.

Let me see if I follow:

  • You get timeSeries, which is already something interpolated, but aligns on the Timeseries::timestep
  • Then you scan the entire day for that, and you call another interpolation call

I will go look into Vector/Matrix next, but this doesn't sit right with me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second one (i.e., getValue) is not really an interpolation call. It is a call with HoldNextInterp.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I'm really still not a big fan of this. But I don't think it warrants blocking the PR... I expect most people will just use timeSeries anyways.

joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
OS_ASSERT(values.size() == N);

if (N == 0) {
return 0.0;
}

openstudio::Vector x(N + 2);
openstudio::Vector y(N + 2);
Vector x(N + 2);
Vector y(N + 2);

x[0] = -0.000001;
x[0] = 0.0;
y[0] = 0.0;

for (unsigned i = 0; i < N; ++i) {
x[i + 1] = times[i].totalDays();
openstudio::Time t = dateTimes[i].time();
if (t.totalDays() == 0.0) { // this is 00:00:00 from the next day
t = openstudio::Time(0, 24, 0);
}

x[i + 1] = t.totalDays();
y[i + 1] = values[i];
}

x[N + 1] = 1.000001;
y[N + 1] = 0.0;
x[N + 1] = 1.0;
y[N + 1] = values[N - 1];

InterpMethod interpMethod;
if (this->interpolatetoTimestep()) {
interpMethod = LinearInterp;
} else {
interpMethod = HoldNextInterp;
}

double result = interp(x, y, time.totalDays(), interpMethod, NoneExtrap);
double result = interp(x, y, time.totalDays(), HoldNextInterp, NoneExtrap);
Copy link
Collaborator

@jmarrec jmarrec Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really feel like you ever need to pass two values to that call...

As I wrote on #5001 (comment)

doesn't the getValues routine look inefficient? If I'm understanding correctly, you only need to find the time before and the time after and the corresponding, you can break early. I know, this is a scheduleday, so we're talking about 60 (timestep max in E+ If I recall correctly) * 24 hours datapoints max, so it's not noticeable, but still

And you should probably just do that on values & times, not on timeSeries (which is interpolated already, and contains the entire day)


return result;
}

openstudio::TimeSeries ScheduleDay_Impl::timeSeries() const {
Copy link
Collaborator Author

@joseph-robertson joseph-robertson Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns timeseries with timestamps (i.e., a DateTimeVector) that align with the Timestep object. The values returned (i.e., a Vector) correspond to the "Interpolate to Timestep" choice.

if (!m_cachedTimeSeries) {

auto timestep = this->model().getUniqueModelObject<Timestep>();
int numberOfTimestepsPerHour = timestep.numberOfTimestepsPerHour();
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved

Date startDate(Date(MonthOfYear(MonthOfYear::Jan), 1)); // this is arbitrary
int minutes = 60 / numberOfTimestepsPerHour;
DateTime startDateTime(startDate, Time(0, 0, 0));

DateTimeVector tsDateTimes;
for (size_t hour = 0; hour < 24; ++hour) {
for (size_t minute = minutes; minute <= 60; minute += minutes) {
if (minute == 60) {
openstudio::Time t(0, hour + 1, 0);
tsDateTimes.push_back(startDateTime + t);
} else {
openstudio::Time t(0, hour, minute);
tsDateTimes.push_back(startDateTime + t);
}
}
}

std::vector<double> values = this->values(); // these are already sorted
std::vector<openstudio::Time> times = this->times(); // these are already sorted

unsigned N = times.size();
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
OS_ASSERT(values.size() == N);

TimeSeries result;
if (N == 0) {
return result;
}

Vector x(N + 2);
Vector y(N + 2);

x[0] = -0.000001;
y[0] = 0.0;

for (unsigned i = 0; i < N; ++i) {
x[i + 1] = times[i].totalDays();
y[i + 1] = values[i];
}

x[N + 1] = 1.000001;
y[N + 1] = 0.0;

std::string interpolatetoTimestep = this->interpolatetoTimestep();
Vector tsValues(tsDateTimes.size());
for (unsigned j = 0; j < tsDateTimes.size(); ++j) {
openstudio::Time t = tsDateTimes[j].time();
if (t.totalDays() == 0.0) { // this is 00:00:00 from the next day
t = openstudio::Time(0, 24, 0);
}

if (istringEqual("No", interpolatetoTimestep)) {
tsValues[j] = interp(x, y, t.totalDays(), HoldNextInterp, NoneExtrap);
} else if (istringEqual("Average", interpolatetoTimestep)) {
double minutes = 60.0 / numberOfTimestepsPerHour;
double ti = minutes / (60.0 * 24.0); // total days of the timestep interval
tsValues[j] = interp(x, y, t.totalDays(), AverageInterp, NoneExtrap, ti);
} else if (istringEqual("Linear", interpolatetoTimestep)) {
tsValues[j] = interp(x, y, t.totalDays(), LinearInterp, NoneExtrap);
}
}

result = TimeSeries(tsDateTimes, tsValues, "");
m_cachedTimeSeries = result;
}

return m_cachedTimeSeries.get();
}

bool ScheduleDay_Impl::setScheduleTypeLimits(const ScheduleTypeLimits& scheduleTypeLimits) {
if (scheduleTypeLimits.model() != model()) {
return false;
Expand All @@ -229,9 +308,8 @@ namespace model {
return false;
}

bool ScheduleDay_Impl::setInterpolatetoTimestep(bool interpolatetoTimestep) {
return setBooleanFieldValue(OS_Schedule_DayFields::InterpolatetoTimestep, interpolatetoTimestep);
;
bool ScheduleDay_Impl::setInterpolatetoTimestep(const std::string& interpolatetoTimestep) {
return setString(OS_Schedule_DayFields::InterpolatetoTimestep, interpolatetoTimestep);
}

void ScheduleDay_Impl::resetInterpolatetoTimestep() {
Expand Down Expand Up @@ -369,6 +447,7 @@ namespace model {
void ScheduleDay_Impl::clearCachedVariables() {
m_cachedTimes.reset();
m_cachedValues.reset();
m_cachedTimeSeries.reset();
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
}

} // namespace detail
Expand All @@ -394,7 +473,7 @@ namespace model {
return getImpl<detail::ScheduleDay_Impl>()->isScheduleTypeLimitsDefaulted();
}

bool ScheduleDay::interpolatetoTimestep() const {
std::string ScheduleDay::interpolatetoTimestep() const {
return getImpl<detail::ScheduleDay_Impl>()->interpolatetoTimestep();
}

Expand All @@ -414,7 +493,11 @@ namespace model {
return getImpl<detail::ScheduleDay_Impl>()->getValue(time);
}

bool ScheduleDay::setInterpolatetoTimestep(bool interpolatetoTimestep) {
openstudio::TimeSeries ScheduleDay::timeSeries() const {
return getImpl<detail::ScheduleDay_Impl>()->timeSeries();
}

bool ScheduleDay::setInterpolatetoTimestep(const std::string& interpolatetoTimestep) {
return getImpl<detail::ScheduleDay_Impl>()->setInterpolatetoTimestep(interpolatetoTimestep);
}

Expand Down
10 changes: 7 additions & 3 deletions src/model/ScheduleDay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace model {
* inherits one from a Schedule. */
bool isScheduleTypeLimitsDefaulted() const;

bool interpolatetoTimestep() const;
std::string interpolatetoTimestep() const;
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved

bool isInterpolatetoTimestepDefaulted() const;

Expand All @@ -66,14 +66,18 @@ namespace model {
/// Returns a vector of values in the same order and with the same number of elements as times.
std::vector<double> values() const;

/// Returns the value in effect at the given time. If time is less than 0 days or greater than 1 day, 0 is returned.
/// Returns the value in effect at the given time.
/// If time is less than 0 days or greater than 1 day, 0 is returned.
double getValue(const openstudio::Time& time) const;

/// Returns the values for the timesteps per hour.
openstudio::TimeSeries timeSeries() const;

//@}
/** @name Setters */
//@{

bool setInterpolatetoTimestep(bool interpolatetoTimestep);
bool setInterpolatetoTimestep(const std::string& interpolatetoTimestep);
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved

void resetInterpolatetoTimestep();

Expand Down
14 changes: 11 additions & 3 deletions src/model/ScheduleDay_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
#include "ScheduleBase_Impl.hpp"

#include "../utilities/time/Time.hpp"
#include "../utilities/data/TimeSeries.hpp"

namespace openstudio {

class TimeSeries;

namespace model {

class ScheduleTypeLimits;
Expand Down Expand Up @@ -57,7 +60,7 @@ namespace model {

bool isScheduleTypeLimitsDefaulted() const;

bool interpolatetoTimestep() const;
std::string interpolatetoTimestep() const;

bool isInterpolatetoTimestepDefaulted() const;

Expand All @@ -69,9 +72,13 @@ namespace model {
/// Returns a vector of values in the same order and with the same number of elements as times.
virtual std::vector<double> values() const override;

/// Returns the value in effect at the given time. If time is less than 0 days or greater than 1 day, 0 is returned.
/// Returns the value in effect at the given time.
/// If time is less than 0 days or greater than 1 day, 0 is returned.
double getValue(const openstudio::Time& time) const;

/// Returns the values for the timesteps per hour.
openstudio::TimeSeries timeSeries() const;

//@}
/** @name Setters */
//@{
Expand All @@ -80,7 +87,7 @@ namespace model {

virtual bool resetScheduleTypeLimits() override;

bool setInterpolatetoTimestep(bool interpolatetoTimestep);
bool setInterpolatetoTimestep(const std::string& interpolatetoTimestep);

void resetInterpolatetoTimestep();

Expand Down Expand Up @@ -113,6 +120,7 @@ namespace model {

mutable boost::optional<std::vector<openstudio::Time>> m_cachedTimes;
mutable boost::optional<std::vector<double>> m_cachedValues;
mutable boost::optional<openstudio::TimeSeries> m_cachedTimeSeries;
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
};

} // namespace detail
Expand Down
Loading
Loading