COPASI API  4.16.103
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CExperimentSet Class Reference

#include <CExperimentSet.h>

Inheritance diagram for CExperimentSet:
Inheritance graph
[legend]
Collaboration diagram for CExperimentSet:
Collaboration graph
[legend]

Public Member Functions

CExperimentaddExperiment (const CExperiment &experiment)
 
bool calculateStatistics ()
 
 CExperimentSet (const CCopasiContainer *pParent, const std::string &name="Experiment Set")
 
 CExperimentSet (const CExperimentSet &src, const CCopasiContainer *pParent=NULL)
 
 CExperimentSet (const CCopasiParameterGroup &group, const CCopasiContainer *pParent=NULL)
 
bool compile (const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
 
virtual bool elevateChildren ()
 
void fixBuild55 ()
 
size_t getDataPointCount () const
 
const CMatrix< C_FLOAT64 > & getDependentData (const size_t &index) const
 
const CVector< C_FLOAT64 > & getDependentErrorMean () const
 
const CVector< C_FLOAT64 > & getDependentErrorMeanSD () const
 
const CVector< C_FLOAT64 > & getDependentObjectiveValues () const
 
const CVector< CCopasiObject * > & getDependentObjects () const
 
const CVector< C_FLOAT64 > & getDependentRMS () const
 
CExperimentgetExperiment (const size_t &index)
 
const CExperimentgetExperiment (const size_t &index) const
 
CExperimentgetExperiment (const std::string &name)
 
const CExperimentgetExperiment (const std::string &name) const
 
size_t getExperimentCount () const
 
const CCopasiTask::TypegetExperimentType (const size_t &index) const
 
std::vector< std::string > getFileNames () const
 
const CMatrix< C_FLOAT64 > & getIndependentData (const size_t &index) const
 
const size_t & getValidValueCount () const
 
bool hasDataForTaskType (const CCopasiTask::Type &type) const
 
size_t keyToIndex (const std::string &key) const
 
void removeExperiment (const size_t &index)
 
void sort ()
 
virtual ~CExperimentSet ()
 
- Public Member Functions inherited from CCopasiParameterGroup
bool addGroup (const std::string &name)
 
bool addParameter (const CCopasiParameter &parameter)
 
bool addParameter (const std::string &name, const CCopasiParameter::Type type)
 
template<class CType >
bool addParameter (const std::string &name, const CCopasiParameter::Type type, const CType &value)
 
void addParameter (CCopasiParameter *pParameter)
 
CCopasiParameterGroupassertGroup (const std::string &name)
 
template<class CType >
CCopasiParameterassertParameter (const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
 
index_iterator beginIndex () const
 
name_iterator beginName () const
 
 CCopasiParameterGroup (const CCopasiParameterGroup &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameterGroup (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &objectType="ParameterGroup")
 
void clear ()
 
index_iterator endIndex () const
 
name_iterator endName () const
 
CCopasiParameterGroupgetGroup (const std::string &name)
 
const CCopasiParameterGroupgetGroup (const std::string &name) const
 
CCopasiParameterGroupgetGroup (const size_t &index)
 
const CCopasiParameterGroupgetGroup (const size_t &index) const
 
size_t getIndex (const std::string &name) const
 
std::string getKey (const std::string &name) const
 
std::string getKey (const size_t &index) const
 
virtual const std::string & getName (const size_t &index) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
CCopasiParametergetParameter (const std::string &name)
 
const CCopasiParametergetParameter (const std::string &name) const
 
CCopasiParametergetParameter (const size_t &index)
 
const CCopasiParametergetParameter (const size_t &index) const
 
CCopasiParameter::Type getType (const std::string &name) const
 
CCopasiParameter::Type getType (const size_t &index) const
 
std::string getUniqueParameterName (const CCopasiParameter *pParameter) const
 
const CCopasiParameter::ValuegetValue (const std::string &name) const
 
const CCopasiParameter::ValuegetValue (const size_t &index) const
 
CCopasiParameter::ValuegetValue (const std::string &name)
 
CCopasiParameter::ValuegetValue (const size_t &index)
 
CCopasiParameterGroupoperator= (const CCopasiParameterGroup &rhs)
 
virtual void print (std::ostream *ostream) const
 
bool removeParameter (const std::string &name)
 
bool removeParameter (const size_t &index)
 
template<class CType >
bool setValue (const std::string &name, const CType &value)
 
template<class CType >
bool setValue (const size_t &index, const CType &value)
 
size_t size () const
 
bool swap (const size_t &iFrom, const size_t &iTo)
 
bool swap (index_iterator &from, index_iterator &to)
 
virtual ~CCopasiParameterGroup ()
 
- Public Member Functions inherited from CCopasiParameter
 CCopasiParameter (const CCopasiParameter &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameter (const std::string &name, const Type &type, const void *pValue=NULL, const CCopasiContainer *pParent=NULL, const std::string &objectType="Parameter")
 
virtual CCopasiObjectName getCN () const
 
virtual const std::string & getKey () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const CCopasiParameter::TypegetType () const
 
const ValuegetValue () const
 
ValuegetValue ()
 
virtual voidgetValuePointer () const
 
CCopasiObjectgetValueReference () const
 
bool isValidValue (const C_FLOAT64 &value) const
 
bool isValidValue (const C_INT32 &value) const
 
bool isValidValue (const unsigned C_INT32 &value) const
 
bool isValidValue (const bool &value) const
 
bool isValidValue (const std::string &value) const
 
bool isValidValue (const CCopasiObjectName &value) const
 
bool isValidValue (const std::vector< CCopasiParameter * > &value) const
 
CCopasiParameteroperator= (const CCopasiParameter &rhs)
 
template<class CType >
bool setValue (const CType &value)
 
bool setValue (const std::vector< CCopasiParameter * > &value)
 
virtual ~CCopasiParameter ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Private Member Functions

void initializeParameter ()
 

Private Attributes

CVector< size_t > mDependentDataCount
 
CVector< C_FLOAT64mDependentErrorMean
 
CVector< C_FLOAT64mDependentErrorMeanSD
 
CVector< C_FLOAT64mDependentObjectiveValues
 
CVector< CCopasiObject * > mDependentObjects
 
CVector< C_FLOAT64mDependentRMS
 
size_t mNonExperiments
 
std::vector< CExperiment * > * mpExperiments
 
size_t mValidValueCount
 

Additional Inherited Members

- Public Types inherited from CCopasiParameterGroup
typedef parameterGroup::iterator index_iterator
 
typedef
CCopasiContainer::objectMap::iterator 
name_iterator
 
typedef std::vector
< CCopasiParameter * > 
parameterGroup
 
- Public Types inherited from CCopasiParameter
enum  Type {
  DOUBLE = 0, UDOUBLE, INT, UINT,
  BOOL, GROUP, STRING, CN,
  KEY, FILE, EXPRESSION, INVALID
}
 
- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from CCopasiParameter
static const std::string TypeName []
 
static const char * XMLType []
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Protected Member Functions inherited from CCopasiParameterGroup
 CCopasiParameterGroup ()
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 
- Protected Attributes inherited from CCopasiParameter
std::string mKey
 
CCopasiObjectmpValueReference
 
size_t mSize
 
Value mValue
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 26 of file CExperimentSet.h.

Constructor & Destructor Documentation

CExperimentSet::CExperimentSet ( const CCopasiContainer pParent,
const std::string &  name = "Experiment Set" 
)

Default constructor

Parameters
constCCopasiContainer * pParent
conststd::string & name (default: Experiment Set)

Definition at line 30 of file CExperimentSet.cpp.

References initializeParameter().

31  :
32  CCopasiParameterGroup(name, pParent, "CExperimentSet"),
33  mpExperiments(NULL),
34  mNonExperiments(0),
37  mDependentRMS(0),
CVector< C_FLOAT64 > mDependentRMS
size_t mValidValueCount
CVector< CCopasiObject * > mDependentObjects
CVector< C_FLOAT64 > mDependentErrorMeanSD
void initializeParameter()
CVector< C_FLOAT64 > mDependentObjectiveValues
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
CVector< C_FLOAT64 > mDependentErrorMean
CVector< size_t > mDependentDataCount
CExperimentSet::CExperimentSet ( const CExperimentSet src,
const CCopasiContainer pParent = NULL 
)

Copy constructor

Parameters
constCExperimentSet & src
constCCopasiContainer * pParent (default: src data model)

Definition at line 44 of file CExperimentSet.cpp.

References initializeParameter().

45  :
46  CCopasiParameterGroup(src, static_cast< const CCopasiContainer * >((pParent != NULL) ? pParent : src.getObjectDataModel())),
47  mpExperiments(NULL),
48  mNonExperiments(0),
51  mDependentRMS(0),
CCopasiDataModel * getObjectDataModel()
CVector< C_FLOAT64 > mDependentRMS
size_t mValidValueCount
CVector< CCopasiObject * > mDependentObjects
CVector< C_FLOAT64 > mDependentErrorMeanSD
void initializeParameter()
CVector< C_FLOAT64 > mDependentObjectiveValues
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
CVector< C_FLOAT64 > mDependentErrorMean
CVector< size_t > mDependentDataCount
CExperimentSet::CExperimentSet ( const CCopasiParameterGroup group,
const CCopasiContainer pParent = NULL 
)

Specific constructor used for reading COPASI files

Parameters
constCCopasiParameterGroup & group
constCCopasiContainer * pParent (default: group data model)

Definition at line 58 of file CExperimentSet.cpp.

References initializeParameter().

59  :
60  CCopasiParameterGroup(group, static_cast< const CCopasiContainer * >((pParent != NULL) ? pParent : group.getObjectDataModel())),
61  mpExperiments(NULL),
62  mNonExperiments(0),
65  mDependentRMS(0),
CCopasiDataModel * getObjectDataModel()
CVector< C_FLOAT64 > mDependentRMS
size_t mValidValueCount
CVector< CCopasiObject * > mDependentObjects
CVector< C_FLOAT64 > mDependentErrorMeanSD
void initializeParameter()
CVector< C_FLOAT64 > mDependentObjectiveValues
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
CVector< C_FLOAT64 > mDependentErrorMean
CVector< size_t > mDependentDataCount
CExperimentSet::~CExperimentSet ( )
virtual

Destructor

Definition at line 72 of file CExperimentSet.cpp.

72 {}

Member Function Documentation

CExperiment * CExperimentSet::addExperiment ( const CExperiment experiment)

Add an experiment

Returns
CExperiment * experiment

Definition at line 327 of file CExperimentSet.cpp.

References CCopasiParameterGroup::addParameter(), CCopasiObject::getObjectName(), CCopasiParameterGroup::getParameter(), CCopasiObject::setObjectName(), sort(), and StringPrint().

Referenced by CQFittingWidget::saveTask(), CQExperimentData::slotExperimentAdd(), and CQExperimentData::slotOK().

328 {
329  // We need to make sure that the experiment name is unique.
330  std::string name = experiment.getObjectName();
331 
332  int i = 0;
333 
334  while (getParameter(name))
335  {
336  i++;
337  name = StringPrint("%s_%d", experiment.getObjectName().c_str(), i);
338  }
339 
340  CExperiment * pExperiment = new CExperiment(experiment);
341  pExperiment->setObjectName(name);
342  addParameter(pExperiment);
343 
344  sort();
345 
346  return pExperiment;
347 }
const std::string & getObjectName() const
CCopasiParameter * getParameter(const std::string &name)
std::string StringPrint(const char *format,...)
Definition: utility.cpp:87
bool addParameter(const CCopasiParameter &parameter)
bool setObjectName(const std::string &name)
bool CExperimentSet::calculateStatistics ( )

Calculate statistics across all experiments.

Returns
bool success

Definition at line 177 of file CExperimentSet.cpp.

References COutputInterface::AFTER, CVectorCore< CType >::array(), C_FLOAT64, CCopasiObject::getObjectAncestor(), max, mDependentDataCount, mDependentErrorMean, mDependentErrorMeanSD, mDependentObjectiveValues, mDependentObjects, mDependentRMS, mNonExperiments, mpExperiments, mValidValueCount, CCopasiTask::output(), CVector< CType >::resize(), CVectorCore< CType >::size(), and CCopasiTask::timeCourse.

Referenced by CFitProblem::calculateStatistics().

178 {
181 
183  mDependentRMS = 0.0;
184 
186  mDependentErrorMean = 0.0;
187 
189  mDependentErrorMeanSD = 0.0;
190 
193  mValidValueCount = 0;
194 
195  // calculate the per experiment and per dependent value statistics.
196  std::vector< CExperiment * >::iterator it = mpExperiments->begin() + mNonExperiments;
197  std::vector< CExperiment * >::iterator end = mpExperiments->end();
198 
199  size_t i, Count;
200  C_FLOAT64 Tmp;
201 
202  for (; it != end; ++it)
203  {
204  (*it)->calculateStatistics();
205 
206  CCopasiObject *const* ppObject = mDependentObjects.array();
207  CCopasiObject *const* ppEnd = ppObject + mDependentObjects.size();
208 
209  for (i = 0; ppObject != ppEnd; ++ppObject, ++i)
210  {
211  Count = (*it)->getColumnValidValueCount(*ppObject);
212 
213  if (Count)
214  {
215  mDependentObjectiveValues[i] += (*it)->getObjectiveValue(*ppObject);
216 
217  Tmp = (*it)->getRMS(*ppObject);
218  mDependentRMS[i] += Tmp * Tmp * Count;
219 
220  mDependentErrorMean[i] += (*it)->getErrorSum(*ppObject);
221 
222  mDependentDataCount[i] += Count;
223  mValidValueCount += Count;
224  }
225  }
226  }
227 
228  size_t imax = mDependentObjects.size();
229 
230  for (i = 0; i != imax; i++)
231  {
232  Count = mDependentDataCount[i];
233 
234  if (Count)
235  {
236  mDependentRMS[i] = sqrt(mDependentRMS[i] / Count);
237  mDependentErrorMean[i] /= Count;
238  }
239  else
240  {
241  mDependentRMS[i] = std::numeric_limits<C_FLOAT64>::quiet_NaN();
242  mDependentErrorMean[i] = std::numeric_limits<C_FLOAT64>::quiet_NaN();
243  }
244  }
245 
246  it = mpExperiments->begin() + mNonExperiments;
247 
248  // We need to loop again to calculate the std. deviation.
249  for (; it != end; ++it) //over experiments
250  {
251  CCopasiObject *const* ppObject = mDependentObjects.array();
252  CCopasiObject *const* ppEnd = ppObject + mDependentObjects.size();
253 
254  for (i = 0; ppObject != ppEnd; ++ppObject, ++i)
255  {
256  Count = (*it)->getColumnValidValueCount(*ppObject);
257 
258  if (Count)
260  (*it)->getErrorMeanSD(*ppObject, mDependentErrorMean[i]);
261  }
262  }
263 
264  for (i = 0; i != imax; i++)
265  {
266  Count = mDependentDataCount[i];
267 
268  if (Count)
269  mDependentErrorMeanSD[i] = sqrt(mDependentErrorMeanSD[i] / Count);
270  else
271  mDependentErrorMeanSD[i] = std::numeric_limits<C_FLOAT64>::quiet_NaN();
272  }
273 
274  // This is the time to call the output handler to plot the fitted points.
275  for (it = mpExperiments->begin() + mNonExperiments, imax = 0; it != end; ++it)
276  imax = std::max(imax, (*it)->getDependentData().numRows());
277 
278  CCopasiTask * pParentTask = dynamic_cast< CCopasiTask *>(getObjectAncestor("Task"));
279  assert(pParentTask != NULL);
280 
281  for (i = 0; i < imax; i++)
282  {
283  for (it = mpExperiments->begin() + mNonExperiments; it != end; ++it)
284  (*it)->updateFittedPointValues(i, (*it)->getExperimentType() != CCopasiTask::timeCourse); //false means without simulated data
285 
286  pParentTask->output(COutputInterface::AFTER);
287  }
288 
289  //now the extended time series
290  for (it = mpExperiments->begin() + mNonExperiments, imax = 0; it != end; ++it)
291  imax = std::max(imax, (*it)->extendedTimeSeriesSize());
292 
293  for (i = 0; i < imax; i++)
294  {
295  for (it = mpExperiments->begin() + mNonExperiments; it != end; ++it)
296  {
297  if ((*it)->getExperimentType() == CCopasiTask::timeCourse)
298  {
299  (*it)->updateFittedPointValuesFromExtendedTimeSeries(i);
300  }
301  }
302 
303  pParentTask->output(COutputInterface::AFTER);
304  }
305 
306  return true;
307 }
CCopasiContainer * getObjectAncestor(const std::string &type) const
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
virtual void output(const COutputInterface::Activity &activity)
CVector< C_FLOAT64 > mDependentRMS
size_t mValidValueCount
CVector< CCopasiObject * > mDependentObjects
CVector< C_FLOAT64 > mDependentErrorMeanSD
size_t size() const
Definition: CVector.h:100
CVector< C_FLOAT64 > mDependentObjectiveValues
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
CVector< C_FLOAT64 > mDependentErrorMean
CVector< size_t > mDependentDataCount
#define max(a, b)
Definition: f2c.h:176
bool CExperimentSet::compile ( const std::vector< CCopasiContainer * >  listOfContainer = CCopasiContainer::EmptyList)

Compile the experiment set. This function must be called before any evaluations can be performed.

Parameters
conststd::vector< CCopasiContainer * > listOfContainer
Returns
bool success

Definition at line 96 of file CExperimentSet.cpp.

References CVectorCore< CType >::array(), CCopasiMessage::ERROR, CLocaleString::fromUtf8(), MCFitting, mDependentDataCount, mDependentErrorMean, mDependentErrorMeanSD, mDependentObjectiveValues, mDependentObjects, mDependentRMS, mNonExperiments, mpExperiments, CVector< CType >::resize(), CVectorCore< CType >::size(), and sort().

Referenced by CFitProblem::initialize().

97 {
98  bool success = true;
99 
100  // First we need to sort the experiments so that we can make use of continued
101  // file reading.
102  sort();
103 
104  std::set< CCopasiObject * > DependentObjects;
105 
106  std::ifstream in;
107  std::string CurrentFileName("");
108  size_t CurrentLineNumber = 1;
109 
110  std::vector< CExperiment * >::iterator it = mpExperiments->begin() + mNonExperiments;
111  std::vector< CExperiment * >::iterator end = mpExperiments->end();
112 
113  for (; it != end; ++it)
114  {
115  if (CurrentFileName != (*it)->getFileName())
116  {
117  CurrentFileName = (*it)->getFileName();
118  CurrentLineNumber = 1;
119 
120  if (in.is_open())
121  {
122  in.close();
123  in.clear();
124  }
125 
126  in.open(CLocaleString::fromUtf8(CurrentFileName).c_str(), std::ios::binary);
127 
128  if (in.fail())
129  {
130  CCopasiMessage(CCopasiMessage::ERROR, MCFitting + 8, CurrentFileName.c_str());
131  return false; // File can not be opened.
132  }
133  }
134 
135  if (!(*it)->read(in, CurrentLineNumber)) return false;
136 
137  if (!(*it)->compile(listOfContainer)) return false;
138 
139  const std::map< CCopasiObject *, size_t > & ExpDependentObjects
140  = (*it)->getDependentObjects();
141  std::map< CCopasiObject *, size_t >::const_iterator itObject
142  = ExpDependentObjects.begin();
143  std::map< CCopasiObject *, size_t >::const_iterator endObject
144  = ExpDependentObjects.end();
145 
146  for (; itObject != endObject; ++itObject)
147  DependentObjects.insert(itObject->first);
148  }
149 
150  mDependentObjects.resize(DependentObjects.size());
151  CCopasiObject ** ppInsert = mDependentObjects.array();
152  std::set< CCopasiObject * >::const_iterator itObject = DependentObjects.begin();
153  std::set< CCopasiObject * >::const_iterator endObject = DependentObjects.end();
154 
155  for (; itObject != endObject; ++itObject, ++ppInsert)
156  *ppInsert = *itObject;
157 
158  // Allocation and initialization of statistical information
160  mDependentObjectiveValues = std::numeric_limits<C_FLOAT64>::quiet_NaN();
161 
163  mDependentRMS = std::numeric_limits<C_FLOAT64>::quiet_NaN();
164 
166  mDependentErrorMean = std::numeric_limits<C_FLOAT64>::quiet_NaN();
167 
169  mDependentErrorMeanSD = std::numeric_limits<C_FLOAT64>::quiet_NaN();
170 
172  mDependentDataCount = std::numeric_limits<size_t>::quiet_NaN();
173 
174  return success;
175 }
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
CVector< C_FLOAT64 > mDependentRMS
CVector< CCopasiObject * > mDependentObjects
CVector< C_FLOAT64 > mDependentErrorMeanSD
#define MCFitting
size_t size() const
Definition: CVector.h:100
CVector< C_FLOAT64 > mDependentObjectiveValues
CType * array()
Definition: CVector.h:139
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
static CLocaleString fromUtf8(const std::string &utf8)
CVector< C_FLOAT64 > mDependentErrorMean
CVector< size_t > mDependentDataCount
bool CExperimentSet::elevateChildren ( )
virtual

This methods must be called to elevate subgroups to derived objects. The default implementation does nothing.

Returns
bool success

Reimplemented from CCopasiParameterGroup.

Definition at line 77 of file CExperimentSet.cpp.

References mpExperiments, CCopasiParameter::mValue, CCopasiParameter::Value::pGROUP, CCopasiParameter::Value::pVOID, and sort().

Referenced by initializeParameter(), and CCrossValidationSet::initializeParameter().

78 {
79  index_iterator it = mValue.pGROUP->begin();
80  index_iterator end = mValue.pGROUP->end();
81 
82  for (; it != end; ++it)
83  {
84  if (dynamic_cast< CCopasiParameterGroup * >(*it) == NULL) continue;
85 
86  if (!elevate<CExperiment, CCopasiParameterGroup>(*it)) return false;
87  }
88 
89  mpExperiments = static_cast<std::vector<CExperiment * > * >(mValue.pVOID);
90 
91  sort();
92 
93  return true;
94 }
std::vector< CCopasiParameter * > * pGROUP
std::vector< CExperiment * > * mpExperiments
parameterGroup::iterator index_iterator
void CExperimentSet::fixBuild55 ( )

Fix files written with Version 4.10.55, which wrote the square root of user defined weights for the parameter fitting task

Definition at line 466 of file CExperimentSet.cpp.

References mNonExperiments, and mpExperiments.

Referenced by CFitProblem::fixBuild55().

467 {
468  std::vector< CExperiment * >::iterator it = mpExperiments->begin() + mNonExperiments;
469  std::vector< CExperiment * >::iterator end = mpExperiments->end();
470 
471  for (; it != end; ++it)
472  {
473  (*it)->fixBuild55();
474  }
475 
476  return;
477 }
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
size_t CExperimentSet::getDataPointCount ( ) const

Retrieve the number of data points of all experiments combined.

Returns
size_t dataPointCount

Definition at line 449 of file CExperimentSet.cpp.

References mNonExperiments, and mpExperiments.

Referenced by CFitProblem::calculateCrossValidation(), CFitProblem::initialize(), and CFitProblem::setResidualsRequired().

450 {
451  size_t Count = 0;
452  std::vector< CExperiment * >::iterator it = mpExperiments->begin() + mNonExperiments;
453  std::vector< CExperiment * >::iterator end = mpExperiments->end();
454 
455  for (; it != end; ++it)
456  Count += (*it)->getDependentData().numRows() * (*it)->getDependentData().numCols();
457 
458  return Count;
459 }
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
const CMatrix< C_FLOAT64 > & CExperimentSet::getDependentData ( const size_t &  index) const

Retrieve the dependent data of the indexed experiment.

Parameters
constsize_t & index,
Returns
const CMatrix< C_FLOAT64 > & dependentData

Definition at line 386 of file CExperimentSet.cpp.

References CExperiment::getDependentData(), and getExperiment().

387 {return getExperiment(index)->getDependentData();}
const CMatrix< C_FLOAT64 > & getDependentData() const
CExperiment * getExperiment(const size_t &index)
const CVector< C_FLOAT64 > & CExperimentSet::getDependentErrorMean ( ) const

Retrieve all dependent data error mean values.

Returns
const CVector< C_FLOAT64 > & dependentErrorMean

Definition at line 318 of file CExperimentSet.cpp.

References mDependentErrorMean.

Referenced by CQFittingResult::enterProtected().

319 {return mDependentErrorMean;}
CVector< C_FLOAT64 > mDependentErrorMean
const CVector< C_FLOAT64 > & CExperimentSet::getDependentErrorMeanSD ( ) const

Retrieve all dependent data error mean std. deviations.

Returns
const CVector< C_FLOAT64 > & dependentErrorMeanSD

Definition at line 321 of file CExperimentSet.cpp.

References mDependentErrorMeanSD.

Referenced by CQFittingResult::enterProtected().

322 {return mDependentErrorMeanSD;}
CVector< C_FLOAT64 > mDependentErrorMeanSD
const CVector< C_FLOAT64 > & CExperimentSet::getDependentObjectiveValues ( ) const

Retrieve all dependent data objective values.

Returns
const CVector< C_FLOAT64 > & dependentObjectiveValues

Definition at line 312 of file CExperimentSet.cpp.

References mDependentObjectiveValues.

Referenced by CQFittingResult::enterProtected().

CVector< C_FLOAT64 > mDependentObjectiveValues
const CVector< CCopasiObject * > & CExperimentSet::getDependentObjects ( ) const

Retrieve the list of dependent data objects

Returns
const std::vector< CCopasiObject * > & dependentObjects

Definition at line 309 of file CExperimentSet.cpp.

References mDependentObjects.

Referenced by CQFittingResult::enterProtected().

310 {return mDependentObjects;}
CVector< CCopasiObject * > mDependentObjects
const CVector< C_FLOAT64 > & CExperimentSet::getDependentRMS ( ) const

Retrieve all dependent data objective values.

Returns
const CVector< C_FLOAT64 > & dependentRMS

Definition at line 315 of file CExperimentSet.cpp.

References mDependentRMS.

Referenced by CQFittingResult::enterProtected().

316 {return mDependentRMS;}
CVector< C_FLOAT64 > mDependentRMS
CExperiment * CExperimentSet::getExperiment ( const size_t &  index)
const CExperiment * CExperimentSet::getExperiment ( const size_t &  index) const

Retrieve the indexed experiment

Parameters
constsize_t & index,
Returns
const CExperiment * experiment

Definition at line 355 of file CExperimentSet.cpp.

References mNonExperiments, and mpExperiments.

356 {return (*mpExperiments)[index + mNonExperiments];}
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
CExperiment * CExperimentSet::getExperiment ( const std::string &  name)

Retrieve the indexed experiment

Parameters
conststd::string & name,
Returns
CExperiment * experiment

Definition at line 358 of file CExperimentSet.cpp.

References CCopasiParameterGroup::getGroup().

359 {return static_cast<CExperiment *>(getGroup(name));}
CCopasiParameterGroup * getGroup(const std::string &name)
const CExperiment * CExperimentSet::getExperiment ( const std::string &  name) const

Retrieve the indexed experiment

Parameters
conststd::string & name,
Returns
const CExperiment * experiment

Definition at line 361 of file CExperimentSet.cpp.

References CCopasiParameterGroup::getGroup().

362 {return static_cast<const CExperiment *>(getGroup(name));}
CCopasiParameterGroup * getGroup(const std::string &name)
size_t CExperimentSet::getExperimentCount ( ) const
const CCopasiTask::Type & CExperimentSet::getExperimentType ( const size_t &  index) const

Retrieve the indexed experiment type

Parameters
constsize_t & index,
Returns
const CCopasiTasK::Type & experimentType

Definition at line 380 of file CExperimentSet.cpp.

References getExperiment(), and CExperiment::getExperimentType().

381 {return getExperiment(index)->getExperimentType();}
CExperiment * getExperiment(const size_t &index)
const CCopasiTask::Type & getExperimentType() const
std::vector< std::string > CExperimentSet::getFileNames ( ) const

Retrieve the list of file names

Returns
std::vector< std::string > fileNames

Definition at line 431 of file CExperimentSet.cpp.

References mNonExperiments, and mpExperiments.

Referenced by CQExperimentData::load().

432 {
433  std::vector< std::string > List;
434  std::string currentFile = "";
435 
436  std::vector< CExperiment * >::iterator it = mpExperiments->begin() + mNonExperiments;
437  std::vector< CExperiment * >::iterator end = mpExperiments->end();
438 
439  for (; it != end; ++it)
440  if (currentFile != (*it)->getFileName())
441  {
442  currentFile = (*it)->getFileName();
443  List.push_back(currentFile);
444  }
445 
446  return List;
447 }
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
const CMatrix< C_FLOAT64 > & CExperimentSet::getIndependentData ( const size_t &  index) const

Retrieve the independent data of the indexed experiment.

Parameters
constsize_t & index,
Returns
const CMatrix< C_FLOAT64 > & independentData

Definition at line 383 of file CExperimentSet.cpp.

References getExperiment(), and CExperiment::getIndependentData().

384 {return getExperiment(index)->getIndependentData();}
const CMatrix< C_FLOAT64 > & getIndependentData() const
CExperiment * getExperiment(const size_t &index)
const size_t & CExperimentSet::getValidValueCount ( ) const

Retrieve the count of valid data points of all experiments combined.

Returns
size_t count

Definition at line 461 of file CExperimentSet.cpp.

References mValidValueCount.

Referenced by CFitProblem::calculateStatistics().

462 {
463  return mValidValueCount;
464 }
size_t mValidValueCount
bool CExperimentSet::hasDataForTaskType ( const CCopasiTask::Type type) const

Check whether the set contains data for the the given task type

Parameters
constCCopasiTask::Type & type
Returns
bool hasDataForTaskType

Definition at line 364 of file CExperimentSet.cpp.

References mNonExperiments, and mpExperiments.

Referenced by CFitProblem::initialize().

365 {
366  std::vector< CExperiment * >::const_iterator it = mpExperiments->begin() + mNonExperiments;
367  std::vector< CExperiment * >::const_iterator end = mpExperiments->end();
368 
369  for (; it != end; ++it)
370  {
371  if ((*it)->getExperimentType() == type)
372  {
373  return true;
374  }
375  }
376 
377  return false;
378 }
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
void CExperimentSet::initializeParameter ( )
private

Allocates all group parameters and assures that they are properly initialized.

Definition at line 74 of file CExperimentSet.cpp.

References elevateChildren().

Referenced by CExperimentSet().

75 {elevateChildren();}
virtual bool elevateChildren()
size_t CExperimentSet::keyToIndex ( const std::string &  key) const

Convert an experiment key to an index

Parameters
conststd::string & key
Returns
size_t index

Definition at line 389 of file CExperimentSet.cpp.

References C_INVALID_INDEX, CKeyFactory::get(), getExperiment(), CCopasiRootContainer::getKeyFactory(), and CCopasiParameterGroup::size().

Referenced by CFitProblem::initialize(), CQExperimentData::isLikePreviousExperiment(), CQExperimentData::loadExperiment(), CQExperimentData::saveExperiment(), CQExperimentData::slotCheckNormalizeWeightsPerExperiment(), CQExperimentData::slotCheckTo(), CQExperimentData::slotExperimentDelete(), and CQExperimentData::slotWeightMethod().

390 {
391  const CExperiment * pExp = dynamic_cast<const CExperiment *>(CCopasiRootContainer::getKeyFactory()->get(key));
392 
393  if (!pExp) return C_INVALID_INDEX;
394 
395  size_t i, imax = size();
396 
397  for (i = 0; i < imax; i++)
398  if (pExp == getExperiment(i)) return i;
399 
400  return C_INVALID_INDEX;
401 }
CCopasiObject * get(const std::string &key)
#define C_INVALID_INDEX
Definition: copasi.h:222
CExperiment * getExperiment(const size_t &index)
static CKeyFactory * getKeyFactory()
void CExperimentSet::removeExperiment ( const size_t &  index)

Remove an experiment from the set

Parameters
constsize_t & index

Definition at line 349 of file CExperimentSet.cpp.

References mNonExperiments, and CCopasiParameterGroup::removeParameter().

Referenced by CQFittingWidget::saveTask(), CQExperimentData::slotExperimentDelete(), CQExperimentData::slotFileDelete(), and CQExperimentData::slotOK().

bool removeParameter(const std::string &name)
size_t mNonExperiments
void CExperimentSet::sort ( )

Sort the experiments in the set

Definition at line 403 of file CExperimentSet.cpp.

References CCopasiParameterGroup::beginIndex(), CExperiment::compare(), CCopasiParameterGroup::endIndex(), mNonExperiments, mpExperiments, and CCopasiParameterGroup::swap().

Referenced by addExperiment(), compile(), elevateChildren(), and CExperimentFileInfo::sync().

404 {
405  // First we make sure that all experiments are at the end of the group
406  index_iterator it = beginIndex();
407  index_iterator end = endIndex();
408 
409  index_iterator swapTarget = beginIndex();
410  mNonExperiments = 0;
411 
412  for (; it != end; ++it)
413  if (dynamic_cast< CExperiment * >(*it) == NULL)
414  {
415  if (it != swapTarget)
416  swap(it, swapTarget);
417 
418  swapTarget++;
419  mNonExperiments++;
420  }
421 
422  // Now sort the experiments
423  std::vector< CExperiment * >::iterator startSort = mpExperiments->begin() + mNonExperiments;
424  std::vector< CExperiment * >::iterator endSort = mpExperiments->end();
425 
426  std::sort(startSort, endSort, &CExperiment::compare);
427 
428  return;
429 }
bool swap(const size_t &iFrom, const size_t &iTo)
index_iterator endIndex() const
static bool compare(const CExperiment *lhs, const CExperiment *rhs)
index_iterator beginIndex() const
std::vector< CExperiment * > * mpExperiments
size_t mNonExperiments
parameterGroup::iterator index_iterator

Member Data Documentation

CVector< size_t > CExperimentSet::mDependentDataCount
private

A list of the number of data points for each dependent object;

Definition at line 268 of file CExperimentSet.h.

Referenced by calculateStatistics(), and compile().

CVector< C_FLOAT64 > CExperimentSet::mDependentErrorMean
private

A list of all dependent data error mean values;

Definition at line 258 of file CExperimentSet.h.

Referenced by calculateStatistics(), compile(), and getDependentErrorMean().

CVector< C_FLOAT64 > CExperimentSet::mDependentErrorMeanSD
private

A list of all dependent data error mean std. deviations;

Definition at line 263 of file CExperimentSet.h.

Referenced by calculateStatistics(), compile(), and getDependentErrorMeanSD().

CVector< C_FLOAT64 > CExperimentSet::mDependentObjectiveValues
private

A list of all dependent data objective values;

Definition at line 248 of file CExperimentSet.h.

Referenced by calculateStatistics(), compile(), and getDependentObjectiveValues().

CVector< CCopasiObject * > CExperimentSet::mDependentObjects
private

A set of all dependent data objects;

Definition at line 243 of file CExperimentSet.h.

Referenced by calculateStatistics(), compile(), and getDependentObjects().

CVector< C_FLOAT64 > CExperimentSet::mDependentRMS
private

A list of all dependent data objective values;

Definition at line 253 of file CExperimentSet.h.

Referenced by calculateStatistics(), compile(), and getDependentRMS().

size_t CExperimentSet::mNonExperiments
private
std::vector< CExperiment * >* CExperimentSet::mpExperiments
private
size_t CExperimentSet::mValidValueCount
private

The total count of valid data values.

Definition at line 273 of file CExperimentSet.h.

Referenced by calculateStatistics(), and getValidValueCount().


The documentation for this class was generated from the following files: