Skip to content

Commit

Permalink
Shift time at the end/Fix #411
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiri Choi committed Sep 22, 2017
1 parent 6a2394d commit f842bfb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions source/rrRoadRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,8 +1332,8 @@ const DoubleMatrix* RoadRunner::simulate(const Dictionary* dict)

applySimulateOptions();

const double timeEnd = self.simulateOpt.duration + self.simulateOpt.start;
const double timeStart = self.simulateOpt.start;
const double timeEnd = self.simulateOpt.duration;
const double timeStart = 0;

// evalute the model with its current state
self.model->getStateVectorRate(timeStart, 0, 0);
Expand Down Expand Up @@ -1563,6 +1563,12 @@ const DoubleMatrix* RoadRunner::simulate(const Dictionary* dict)

Log(Logger::LOG_DEBUG) << "Simulation done..";

for (int i = 0; i < self.simulationResult.numRows(); i++) {
self.simulationResult[i][getTimeRowIndex()] = self.simulationResult[i][getTimeRowIndex()] + self.simulateOpt.start;

This comment has been minimized.

Copy link
@0u812

0u812 Oct 11, 2017

Member

Hi Kiri, I had to revert this commit (#424). Memory corruption. Best guess is this line, which assumes a time row is present, but 'time' may not be in selections. My suggestion: leav 1335 and 1336 as they are. On 1566, check whether a time row exists. If it does, you can add delta t.

}

Log(Logger::LOG_DEBUG) << "Added delta T.";

return &self.simulationResult;
}

Expand Down Expand Up @@ -4049,10 +4055,9 @@ void RoadRunner::applySimulateOptions()
{
get_self();

if (self.simulateOpt.duration < 0 || self.simulateOpt.start < 0
|| self.simulateOpt.steps < 0 )
if (self.simulateOpt.duration < 0 || self.simulateOpt.steps < 0 )
{
throw std::invalid_argument("duration, startTime and steps must be non-negative");
throw std::invalid_argument("duration and steps must be non-negative");
}

// This one creates the list of what we will look at in the result
Expand Down

0 comments on commit f842bfb

Please sign in to comment.