Skip to content

Commit 3ccb3f6

Browse files
committed
Bug 3020: The values of a fitting points are filled correctly.
1 parent 4076c62 commit 3ccb3f6

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

copasi/parameterFitting/CExperiment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void CExperiment::updateFittedPoints()
354354
}
355355
}
356356

357-
void CExperiment::updateFittedPointValues(const size_t & index, bool includeSimulation)
357+
void CExperiment::updateFittedPointValues(const size_t & index)
358358
{
359359
CDataVector< CFittingPoint >::iterator it = mFittingPoints.begin();
360360
CDataVector< CFittingPoint >::iterator end = mFittingPoints.end();
@@ -395,7 +395,7 @@ void CExperiment::updateFittedPointValues(const size_t & index, bool includeSimu
395395

396396
it->setValues(Independent,
397397
*pDataDependent,
398-
includeSimulation ? *pDataDependentCalculated : std::numeric_limits<C_FLOAT64>::quiet_NaN(),
398+
*pDataDependentCalculated,
399399
Residual);
400400
}
401401

copasi/parameterFitting/CExperiment.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019 by Pedro Mendes, Rector and Visitors of the
1+
// Copyright (C) 2019 - 2021 by Pedro Mendes, Rector and Visitors of the
22
// University of Virginia, University of Heidelberg, and University
33
// of Connecticut School of Medicine.
44
// All rights reserved.
@@ -358,13 +358,10 @@ class CExperiment: public CCopasiParameterGroup
358358

359359
/**
360360
* This method is used for output to fill the fitted points
361-
* with the values of the index data record. If index exceedds the
361+
* with the values of the index data record. If index exceeds the
362362
* number of data records all values are set to NaN.
363-
* If includeSimulation = false the entries for the simulation results
364-
* are set to NaN. (This means the simulated time series is not plotted and
365-
* can be output using a different mechanism)
366363
*/
367-
void updateFittedPointValues(const size_t & index, bool includeSimulation);
364+
void updateFittedPointValues(const size_t & index);
368365

369366
/**
370367
* Fill the fitted points with values from the extended time series

copasi/parameterFitting/CExperimentSet.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019 by Pedro Mendes, Rector and Visitors of the
1+
// Copyright (C) 2019 - 2021 by Pedro Mendes, Rector and Visitors of the
22
// University of Virginia, University of Heidelberg, and University
33
// of Connecticut School of Medicine.
44
// All rights reserved.
@@ -288,35 +288,40 @@ bool CExperimentSet::calculateStatistics()
288288
}
289289

290290
// This is the time to call the output handler to plot the fitted points.
291-
for (it = mpExperiments->begin() + mNonExperiments, imax = 0; it != end; ++it)
292-
imax = std::max(imax, (*it)->getDependentData().numRows());
291+
size_t j, jmax;
292+
293+
imax = 0;
294+
295+
for (it = mpExperiments->begin() + mNonExperiments; it != end; ++it)
296+
{
297+
imax = std::max(imax, (*it)->getDependentData().numRows());
298+
}
293299

294300
CCopasiTask * pParentTask = dynamic_cast< CCopasiTask *>(getObjectAncestor("Task"));
295301
assert(pParentTask != NULL);
296302

297-
for (i = 0; i < imax; i++)
303+
for (i = 0, j = 0; i < imax; i++)
298304
{
299305
for (it = mpExperiments->begin() + mNonExperiments; it != end; ++it)
300-
(*it)->updateFittedPointValues(i, (*it)->getExperimentType() != CTaskEnum::Task::timeCourse); //false means without simulated data
306+
(*it)->updateFittedPointValues(i);
301307

302308
pParentTask->output(COutputInterface::AFTER);
303-
}
304309

305-
//now the extended time series
306-
for (it = mpExperiments->begin() + mNonExperiments, imax = 0; it != end; ++it)
307-
imax = std::max(imax, (*it)->extendedTimeSeriesSize());
310+
// TODO the 3 below relies on the fact that currently the number of intermittend point is CFitProblem::numIntermediateSteps
311+
jmax = std::min(j + 3, (imax - 1) * 3);
308312

309-
for (i = 0; i < imax; i++)
310-
{
311-
for (it = mpExperiments->begin() + mNonExperiments; it != end; ++it)
313+
for (; j < jmax; j++)
312314
{
313-
if ((*it)->getExperimentType() == CTaskEnum::Task::timeCourse)
315+
for (it = mpExperiments->begin() + mNonExperiments; it != end; ++it)
314316
{
315-
(*it)->updateFittedPointValuesFromExtendedTimeSeries(i);
317+
if ((*it)->getExperimentType() == CTaskEnum::Task::timeCourse)
318+
{
319+
(*it)->updateFittedPointValuesFromExtendedTimeSeries(j);
320+
}
316321
}
317-
}
318322

319-
pParentTask->output(COutputInterface::AFTER);
323+
pParentTask->output(COutputInterface::AFTER);
324+
}
320325
}
321326

322327
return true;
@@ -340,7 +345,6 @@ const CVector< C_FLOAT64 > & CExperimentSet::getDependentErrorMeanSD() const
340345
const CVector< size_t > & CExperimentSet::getDependentDataCount() const
341346
{return mDependentDataCount;}
342347

343-
344348
size_t CExperimentSet::getExperimentCount() const
345349
{return size() - mNonExperiments;}
346350

copasi/parameterFitting/CFitProblem.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ bool CFitProblem::initialize()
560560
}
561561

562562
mCompleteInitialState = mpContainer->getCompleteInitialState();
563-
mpInitialStateTime = mpContainer->getInitialState().array() + mpContainer->getCountFixedEventTargets();
563+
mpInitialStateTime = mpContainer->getInitialState().array() + mpContainer->getCountFixed() + mpContainer->getCountFixedEventTargets();
564564

565565
success &= mpExperimentSet->compile(mpContainer);
566566

@@ -943,7 +943,7 @@ bool CFitProblem::calculate()
943943

944944
size_t i, imax = mpExperimentSet->getExperimentCount();
945945
size_t j;
946-
size_t kmax;
946+
int kmax;
947947
mCalculateValue = 0.0;
948948

949949
CExperiment * pExp = NULL;
@@ -1063,7 +1063,7 @@ bool CFitProblem::calculate()
10631063
//calculate a reasonable number of intermediate points
10641064
numIntermediateSteps = 4; //TODO
10651065
//resize the storage for the extended time series
1066-
pExp->initExtendedTimeSeries(numIntermediateSteps * (kmax > 0 ? kmax - 1 : 0) + 1);
1066+
pExp->initExtendedTimeSeries(numIntermediateSteps * std::max(kmax - 1, 0));
10671067
}
10681068

10691069
for (j = 0; j < kmax && Continue; j++) // For each data row;
@@ -1145,8 +1145,6 @@ bool CFitProblem::calculate()
11451145
if (mStoreResults)
11461146
{
11471147
mCalculateValue += pExp->sumOfSquaresStore(j, DependentValues);
1148-
//additionally also store the the simulation result for the extended time series
1149-
pExp->storeExtendedTimeSeriesData(pExp->getTimeData()[j]);
11501148
}
11511149
else
11521150
{

0 commit comments

Comments
 (0)