COPASI API  4.16.103
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
CExperiment Class Reference

#include <CExperiment.h>

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

Public Types

enum  Type { ignore = 0, independent, dependent, time }
 
enum  WeightMethod { MEAN = 0, MEAN_SQUARE, SD, VALUE_SCALING }
 
- 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
 

Public Member Functions

bool calculateStatistics ()
 
bool calculateWeights ()
 
 CExperiment (const CCopasiContainer *pParent, const std::string &name="Experiment")
 
 CExperiment (const CExperiment &src, const CCopasiContainer *pParent=NULL)
 
 CExperiment (const CCopasiParameterGroup &group, const CCopasiContainer *pParent=NULL)
 
bool compile (const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
 
virtual bool elevateChildren ()
 
size_t extendedTimeSeriesSize () const
 
void fixBuild55 ()
 
const std::vector< std::string > & getColumnNames () const
 
size_t getColumnValidValueCount (CCopasiObject *const &pObject) const
 
C_FLOAT64 getDefaultScale (const CCopasiObject *const &pObject) const
 
const CMatrix< C_FLOAT64 > & getDependentData () const
 
const std::map< CCopasiObject
*, size_t > & 
getDependentObjects () const
 
const C_FLOAT64getErrorMean () const
 
const C_FLOAT64getErrorMeanSD () const
 
C_FLOAT64 getErrorMeanSD (CCopasiObject *const &pObject, const C_FLOAT64 &errorMean) const
 
C_FLOAT64 getErrorSum (CCopasiObject *const &pObject) const
 
const CCopasiTask::TypegetExperimentType () const
 
const std::string & getFileName () const
 
const unsigned C_INT32getFirstRow () const
 
const CCopasiVector
< CFittingPoint > & 
getFittingPoints () const
 
const unsigned C_INT32getHeaderRow () const
 
const CMatrix< C_FLOAT64 > & getIndependentData () const
 
const std::set< const
CCopasiObject * > & 
getIndependentObjects () const
 
const unsigned C_INT32getLastRow () const
 
bool getNormalizeWeightsPerExperiment () const
 
const unsigned C_INT32getNumColumns () const
 
size_t getNumDataRows () const
 
const C_FLOAT64getObjectiveValue () const
 
C_FLOAT64 getObjectiveValue (CCopasiObject *const &pObject) const
 
CExperimentObjectMapgetObjectMap ()
 
const C_FLOAT64getRMS () const
 
C_FLOAT64 getRMS (CCopasiObject *const &pObject) const
 
const std::string & getSeparator () const
 
const CVector< C_FLOAT64 > & getTimeData () const
 
const WeightMethodgetWeightMethod () const
 
size_t guessColumnNumber () const
 
void initExtendedTimeSeries (size_t s)
 
const bool & isRowOriented () const
 
CExperimentoperator= (const CExperiment &rhs)
 
virtual void printResult (std::ostream *ostream) const
 
bool read (std::istream &in, size_t &currentLine)
 
bool readColumnNames ()
 
bool restoreModelIndependentData ()
 
bool setExperimentType (const CCopasiTask::Type &type)
 
bool setFileName (const std::string &fileName)
 
bool setFirstRow (const unsigned C_INT32 &firstRow)
 
bool setHeaderRow (const unsigned C_INT32 &headerRow)
 
bool setIsRowOriented (const bool &isRowOriented)
 
bool setLastRow (const unsigned C_INT32 &lastRow)
 
void setNormalizeWeightsPerExperiment (bool flag)
 
bool setNumColumns (const unsigned C_INT32 &cols)
 
bool setSeparator (const std::string &seperator)
 
bool setWeightMethod (const WeightMethod &weightMethod)
 
void storeExtendedTimeSeriesData (C_FLOAT64 time)
 
C_FLOAT64 sumOfSquares (const size_t &index, C_FLOAT64 *&residuals) const
 
C_FLOAT64 sumOfSquaresStore (const size_t &index, C_FLOAT64 *&dependentValues)
 
void updateFittedPoints ()
 
void updateFittedPointValues (const size_t &index, bool includeSimulation)
 
void updateFittedPointValuesFromExtendedTimeSeries (const size_t &index)
 
bool updateModelWithIndependentData (const size_t &index)
 
virtual ~CExperiment ()
 
- 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 ()
 

Static Public Member Functions

static bool compare (const CExperiment *lhs, const CExperiment *rhs)
 
- 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

static const std::string TypeName []
 
static const std::string WeightMethodName []
 
static const char * WeightMethodType []
 
static const char * XMLType []
 
- 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
 

Private Member Functions

void initializeParameter ()
 
void initializeScalingMatrix ()
 

Private Attributes

std::vector< std::string > mColumnName
 
CVector< C_FLOAT64mColumnObjectiveValue
 
CVector< C_FLOAT64mColumnRMS
 
CVector< C_FLOAT64mColumnScale
 
CVector< size_t > mColumnValidValueCount
 
CMatrix< C_FLOAT64mDataDependent
 
CMatrix< C_FLOAT64mDataIndependent
 
CVector< C_FLOAT64mDataTime
 
CVector< C_FLOAT64mDefaultColumnScale
 
std::map< CCopasiObject *, size_t > mDependentObjects
 
CVector< C_FLOAT64 * > mDependentValues
 
CVector< C_FLOAT64mExtendedTimeSeries
 
size_t mExtendedTimeSeriesSize
 
CCopasiVector< CFittingPointmFittingPoints
 
std::set< const CCopasiObject * > mIndependentObjects
 
CVector< UpdateMethod * > mIndependentUpdateMethods
 
CVector< C_FLOAT64mIndependentValues
 
C_FLOAT64 mMean
 
CVector< C_FLOAT64mMeans
 
C_FLOAT64 mMeanSD
 
bool mMissingData
 
size_t mNumDataRows
 
C_FLOAT64 mObjectiveValue
 
C_FLOAT64mpDataDependentCalculated
 
std::string * mpFileName
 
unsigned C_INT32mpFirstRow
 
unsigned C_INT32mpHeaderRow
 
unsigned C_INT32mpLastRow
 
bool * mpNormalizeWeightsPerExperiment
 
unsigned C_INT32mpNumColumns
 
CExperimentObjectMapmpObjectMap
 
bool * mpRowOriented
 
std::string * mpSeparator
 
CCopasiTask::TypempTaskType
 
WeightMethodmpWeightMethod
 
std::vector< Refresh * > mRefreshMethods
 
C_FLOAT64 mRMS
 
CVector< C_FLOAT64mRowObjectiveValue
 
CVector< C_FLOAT64mRowRMS
 
CMatrix< C_FLOAT64mScale
 
C_FLOAT64mStorageIt
 

Friends

bool operator== (const CExperiment &lhs, const CExperiment &rhs)
 

Additional Inherited Members

- 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 61 of file CExperiment.h.

Member Enumeration Documentation

Enumeration of the types of columns known to COPASI.

Enumerator
ignore 
independent 
dependent 
time 

Definition at line 67 of file CExperiment.h.

Enumeration of methods to calculate the weight.

Enumerator
MEAN 
MEAN_SQUARE 
SD 
VALUE_SCALING 

Definition at line 89 of file CExperiment.h.

Constructor & Destructor Documentation

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

Default constructor

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

Definition at line 76 of file CExperiment.cpp.

References CVectorCore< CType >::array(), initializeParameter(), mExtendedTimeSeries, and mStorageIt.

77  :
78  CCopasiParameterGroup(name, pParent),
79  mpFileName(NULL),
80  mpFirstRow(NULL),
81  mpLastRow(NULL),
82  mpTaskType(NULL),
84  mpSeparator(NULL),
85  mpWeightMethod(NULL),
86  mpRowOriented(NULL),
87  mpHeaderRow(NULL),
88  mpNumColumns(NULL),
89  mColumnName(),
90  mpObjectMap(NULL),
91  mDataTime(0),
92  mDataIndependent(0, 0),
93  mDataDependent(0, 0),
94  mScale(0, 0),
95  mMissingData(false),
96  mMeans(0),
97  mColumnScale(0),
101  mRefreshMethods(),
104  mNumDataRows(0),
106  mMean(0),
107  mMeanSD(0),
108  mObjectiveValue(0),
109  mRMS(0),
111  mRowRMS(0),
113  mColumnRMS(0),
116  mFittingPoints("Fitted Points", this),
118  mStorageIt(NULL),
120 {
122 
124 }
std::vector< std::string > mColumnName
Definition: CExperiment.h:610
C_FLOAT64 mMean
Definition: CExperiment.h:665
CVector< C_FLOAT64 > mDefaultColumnScale
Definition: CExperiment.h:646
CVector< C_FLOAT64 > mColumnRMS
Definition: CExperiment.h:674
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 > mRowObjectiveValue
Definition: CExperiment.h:670
CVector< C_FLOAT64 * > mDependentValues
Definition: CExperiment.h:648
bool mMissingData
Definition: CExperiment.h:640
CVector< size_t > mColumnValidValueCount
Definition: CExperiment.h:675
std::string * mpSeparator
Definition: CExperiment.h:585
size_t mNumDataRows
Definition: CExperiment.h:658
std::string * mpFileName
Definition: CExperiment.h:560
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
C_FLOAT64 mObjectiveValue
Definition: CExperiment.h:667
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
C_FLOAT64 * mStorageIt
Definition: CExperiment.h:688
CCopasiVector< CFittingPoint > mFittingPoints
Definition: CExperiment.h:682
std::vector< Refresh * > mRefreshMethods
Definition: CExperiment.h:652
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
CMatrix< C_FLOAT64 > mDataIndependent
Definition: CExperiment.h:625
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
CVector< C_FLOAT64 > mRowRMS
Definition: CExperiment.h:671
std::set< const CCopasiObject * > mIndependentObjects
Definition: CExperiment.h:654
CVector< C_FLOAT64 > mMeans
Definition: CExperiment.h:642
C_FLOAT64 mMeanSD
Definition: CExperiment.h:666
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
CVector< C_FLOAT64 > mColumnScale
Definition: CExperiment.h:644
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
size_t mExtendedTimeSeriesSize
Definition: CExperiment.h:691
bool * mpRowOriented
Definition: CExperiment.h:595
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
CVector< C_FLOAT64 > mDataTime
Definition: CExperiment.h:620
CVector< C_FLOAT64 > mColumnObjectiveValue
Definition: CExperiment.h:673
CType * array()
Definition: CVector.h:139
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
bool * mpNormalizeWeightsPerExperiment
Definition: CExperiment.h:580
C_FLOAT64 mRMS
Definition: CExperiment.h:668
CVector< C_FLOAT64 > mExtendedTimeSeries
Definition: CExperiment.h:685
CVector< C_FLOAT64 > mIndependentValues
Definition: CExperiment.h:656
CVector< UpdateMethod * > mIndependentUpdateMethods
Definition: CExperiment.h:650
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
void initializeParameter()
CExperiment::CExperiment ( const CExperiment src,
const CCopasiContainer pParent = NULL 
)

Copy constructor

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

Definition at line 126 of file CExperiment.cpp.

References CVectorCore< CType >::array(), initializeParameter(), mExtendedTimeSeries, and mStorageIt.

127  :
128  CCopasiParameterGroup(src, static_cast< const CCopasiContainer * >((pParent != NULL) ? pParent : src.getObjectDataModel())),
129  mpFileName(NULL),
130  mpFirstRow(NULL),
131  mpLastRow(NULL),
132  mpTaskType(NULL),
134  mpSeparator(NULL),
135  mpWeightMethod(NULL),
136  mpRowOriented(NULL),
137  mpHeaderRow(NULL),
138  mpNumColumns(NULL),
140  mpObjectMap(NULL),
141  mDataTime(src.mDataTime),
144  mScale(src.mScale),
146  mMeans(src.mMeans),
156  mMean(src.mMean),
157  mMeanSD(src.mMeanSD),
158  mObjectiveValue(0),
159  mRMS(src.mRMS),
161  mRowRMS(src.mRowRMS),
163  mColumnRMS(src.mColumnRMS),
166  mFittingPoints(src.mFittingPoints, this),
168  mStorageIt(src.mStorageIt),
170 
171 {
173 
175 }
CCopasiDataModel * getObjectDataModel()
std::vector< std::string > mColumnName
Definition: CExperiment.h:610
C_FLOAT64 mMean
Definition: CExperiment.h:665
CVector< C_FLOAT64 > mDefaultColumnScale
Definition: CExperiment.h:646
CVector< C_FLOAT64 > mColumnRMS
Definition: CExperiment.h:674
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 > mRowObjectiveValue
Definition: CExperiment.h:670
CVector< C_FLOAT64 * > mDependentValues
Definition: CExperiment.h:648
bool mMissingData
Definition: CExperiment.h:640
CVector< size_t > mColumnValidValueCount
Definition: CExperiment.h:675
std::string * mpSeparator
Definition: CExperiment.h:585
size_t mNumDataRows
Definition: CExperiment.h:658
std::string * mpFileName
Definition: CExperiment.h:560
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
C_FLOAT64 mObjectiveValue
Definition: CExperiment.h:667
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
C_FLOAT64 * mStorageIt
Definition: CExperiment.h:688
CCopasiVector< CFittingPoint > mFittingPoints
Definition: CExperiment.h:682
std::vector< Refresh * > mRefreshMethods
Definition: CExperiment.h:652
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
CMatrix< C_FLOAT64 > mDataIndependent
Definition: CExperiment.h:625
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
CVector< C_FLOAT64 > mRowRMS
Definition: CExperiment.h:671
std::set< const CCopasiObject * > mIndependentObjects
Definition: CExperiment.h:654
CVector< C_FLOAT64 > mMeans
Definition: CExperiment.h:642
C_FLOAT64 mMeanSD
Definition: CExperiment.h:666
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
CVector< C_FLOAT64 > mColumnScale
Definition: CExperiment.h:644
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
size_t mExtendedTimeSeriesSize
Definition: CExperiment.h:691
bool * mpRowOriented
Definition: CExperiment.h:595
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
CVector< C_FLOAT64 > mDataTime
Definition: CExperiment.h:620
CVector< C_FLOAT64 > mColumnObjectiveValue
Definition: CExperiment.h:673
CType * array()
Definition: CVector.h:139
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
bool * mpNormalizeWeightsPerExperiment
Definition: CExperiment.h:580
C_FLOAT64 mRMS
Definition: CExperiment.h:668
CVector< C_FLOAT64 > mExtendedTimeSeries
Definition: CExperiment.h:685
CVector< C_FLOAT64 > mIndependentValues
Definition: CExperiment.h:656
CVector< UpdateMethod * > mIndependentUpdateMethods
Definition: CExperiment.h:650
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
void initializeParameter()
CExperiment::CExperiment ( 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 177 of file CExperiment.cpp.

References CVectorCore< CType >::array(), initializeParameter(), mExtendedTimeSeries, and mStorageIt.

178  :
179  CCopasiParameterGroup(group, static_cast< const CCopasiContainer * >((pParent != NULL) ? pParent : group.getObjectDataModel())),
180  mpFileName(NULL),
181  mpFirstRow(NULL),
182  mpLastRow(NULL),
183  mpTaskType(NULL),
185  mpSeparator(NULL),
186  mpWeightMethod(NULL),
187  mpRowOriented(NULL),
188  mpHeaderRow(NULL),
189  mpNumColumns(NULL),
190  mColumnName(),
191  mpObjectMap(NULL),
192  mDataTime(0),
193  mDataIndependent(0, 0),
194  mDataDependent(0, 0),
195  mScale(0, 0),
196  mMissingData(false),
197  mMeans(0),
198  mColumnScale(0),
200  mDependentValues(0),
202  mRefreshMethods(),
205  mNumDataRows(0),
207  mMean(0),
208  mMeanSD(0),
209  mObjectiveValue(0),
210  mRMS(0),
212  mRowRMS(0),
214  mColumnRMS(0),
217  mFittingPoints("Fitted Points", this),
219  mStorageIt(NULL),
221 {
223 
225 }
CCopasiDataModel * getObjectDataModel()
std::vector< std::string > mColumnName
Definition: CExperiment.h:610
C_FLOAT64 mMean
Definition: CExperiment.h:665
CVector< C_FLOAT64 > mDefaultColumnScale
Definition: CExperiment.h:646
CVector< C_FLOAT64 > mColumnRMS
Definition: CExperiment.h:674
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 > mRowObjectiveValue
Definition: CExperiment.h:670
CVector< C_FLOAT64 * > mDependentValues
Definition: CExperiment.h:648
bool mMissingData
Definition: CExperiment.h:640
CVector< size_t > mColumnValidValueCount
Definition: CExperiment.h:675
std::string * mpSeparator
Definition: CExperiment.h:585
size_t mNumDataRows
Definition: CExperiment.h:658
std::string * mpFileName
Definition: CExperiment.h:560
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
C_FLOAT64 mObjectiveValue
Definition: CExperiment.h:667
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
C_FLOAT64 * mStorageIt
Definition: CExperiment.h:688
CCopasiVector< CFittingPoint > mFittingPoints
Definition: CExperiment.h:682
std::vector< Refresh * > mRefreshMethods
Definition: CExperiment.h:652
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
CMatrix< C_FLOAT64 > mDataIndependent
Definition: CExperiment.h:625
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
CVector< C_FLOAT64 > mRowRMS
Definition: CExperiment.h:671
std::set< const CCopasiObject * > mIndependentObjects
Definition: CExperiment.h:654
CVector< C_FLOAT64 > mMeans
Definition: CExperiment.h:642
C_FLOAT64 mMeanSD
Definition: CExperiment.h:666
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
CVector< C_FLOAT64 > mColumnScale
Definition: CExperiment.h:644
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
size_t mExtendedTimeSeriesSize
Definition: CExperiment.h:691
bool * mpRowOriented
Definition: CExperiment.h:595
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
CVector< C_FLOAT64 > mDataTime
Definition: CExperiment.h:620
CVector< C_FLOAT64 > mColumnObjectiveValue
Definition: CExperiment.h:673
CType * array()
Definition: CVector.h:139
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
bool * mpNormalizeWeightsPerExperiment
Definition: CExperiment.h:580
C_FLOAT64 mRMS
Definition: CExperiment.h:668
CVector< C_FLOAT64 > mExtendedTimeSeries
Definition: CExperiment.h:685
CVector< C_FLOAT64 > mIndependentValues
Definition: CExperiment.h:656
CVector< UpdateMethod * > mIndependentUpdateMethods
Definition: CExperiment.h:650
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
void initializeParameter()
CExperiment::~CExperiment ( )
virtual

Destructor

Definition at line 227 of file CExperiment.cpp.

227 {}

Member Function Documentation

bool CExperiment::calculateStatistics ( )

Calculate statistics by comparing the stored calculated values with the measurements.

Returns
bool success

Definition at line 601 of file CExperiment.cpp.

References CMatrix< CType >::array(), C_FLOAT64, CCopasiDataModel::getModel(), CCopasiObject::getObjectDataModel(), CModel::getTime(), max, mColumnObjectiveValue, mColumnRMS, mColumnValidValueCount, mDataDependent, mMean, mMeanSD, mObjectiveValue, mpDataDependentCalculated, mpTaskType, mRMS, mRowObjectiveValue, mRowRMS, mScale, CMatrix< CType >::numCols(), CMatrix< CType >::numRows(), CVector< CType >::resize(), and CCopasiTask::timeCourse.

602 {
603  C_FLOAT64 * pTime = NULL;
604  C_FLOAT64 SavedTime = 0.0;
605 
607  {
608  pTime = const_cast<C_FLOAT64 *>(&getObjectDataModel()->getModel()->getTime());
609  SavedTime = *pTime;
610  }
611 
612  size_t numRows = mDataDependent.numRows();
613  size_t numCols = mDataDependent.numCols();
614 
615  // Overall statistic;
616  mMean = 0.0;
617  mMeanSD = 0.0;
618  mObjectiveValue = 0.0;
619  mRMS = 0.0;
620  size_t ValidValueCount = 0;
621 
622  // per row statistic;
623  mRowObjectiveValue.resize(numRows);
624  mRowObjectiveValue = 0.0;
625  mRowRMS.resize(numRows);
626  mRowRMS = 0.0;
627  CVector< size_t > RowCount;
628  RowCount.resize(numRows);
629  RowCount = 0;
630 
631  // per column statistic;
632  mColumnObjectiveValue.resize(numCols);
633  mColumnObjectiveValue = 0.0;
634  mColumnRMS.resize(numCols);
635  mColumnRMS = 0.0;
638 
639  size_t i, j;
640  C_FLOAT64 Residual;
641 
642  if (mpDataDependentCalculated == NULL)
643  return false;
644 
645  C_FLOAT64 * pDataDependentCalculated = mpDataDependentCalculated;
646  C_FLOAT64 * pDataDependent = mDataDependent.array();
647  C_FLOAT64 * pScale = mScale.array();
648 
649  for (i = 0; i < numRows; i++)
650  {
651  for (j = 0; j < numCols; j++, pDataDependentCalculated++, pDataDependent++, pScale++)
652  {
653 
654 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
655  Residual = (*pDataDependentCalculated - *pDataDependent) * std::max(1.0, *pDataDependentCalculated);
656 #else
657  Residual = (*pDataDependentCalculated - *pDataDependent) * *pScale;
658 #endif
659 
660  if (isnan(Residual)) continue;
661 
662  mMean += Residual;
663 
664  Residual = Residual * Residual;
665 
666  mObjectiveValue += Residual;
667  ValidValueCount++;
668 
669  mRowObjectiveValue[i] += Residual;
670  RowCount[i]++;
671 
672  mColumnObjectiveValue[j] += Residual;
674  }
675  }
676 
677  if (ValidValueCount)
678  {
679  mMean /= ValidValueCount;
680  mRMS = sqrt(mObjectiveValue / ValidValueCount);
681  }
682  else
683  {
684  mMean = std::numeric_limits<C_FLOAT64>::quiet_NaN();
685  mRMS = std::numeric_limits<C_FLOAT64>::quiet_NaN();
686  }
687 
688  for (i = 0; i < numRows; i++)
689  {
690  if (RowCount[i])
691  mRowRMS[i] = sqrt(mRowObjectiveValue[i] / RowCount[i]);
692  else
693  mRowRMS[i] = std::numeric_limits<C_FLOAT64>::quiet_NaN();
694  }
695 
696  for (j = 0; j < numCols; j++)
697  {
698  if (mColumnValidValueCount[j])
700  else
701  mColumnRMS[j] = std::numeric_limits<C_FLOAT64>::quiet_NaN();
702  }
703 
704  pDataDependentCalculated = mpDataDependentCalculated;
705  pDataDependent = mDataDependent.array();
706  pScale = mScale.array();
707 
708  for (i = 0; i < numRows; i++)
709  {
710  for (j = 0; j < numCols; j++, pDataDependentCalculated++, pDataDependent++, pScale++)
711  {
712 
713 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
714  Residual = mMean - (*pDataDependentCalculated - *pDataDependent) / std::max(1.0, *pDataDependentCalculated);
715 #else
716  Residual = mMean - (*pDataDependentCalculated - *pDataDependent) * *pScale;
717 #endif
718 
719  if (isnan(Residual)) continue;
720 
721  mMeanSD += Residual * Residual;
722  }
723  }
724 
725  if (ValidValueCount)
726  mMeanSD = sqrt(mMeanSD / ValidValueCount);
727  else
728  mMeanSD = std::numeric_limits<C_FLOAT64>::quiet_NaN();
729 
730  if (*mpTaskType == CCopasiTask::timeCourse) *pTime = SavedTime;
731 
732  return true;
733 }
CCopasiDataModel * getObjectDataModel()
C_FLOAT64 mMean
Definition: CExperiment.h:665
CVector< C_FLOAT64 > mColumnRMS
Definition: CExperiment.h:674
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 > mRowObjectiveValue
Definition: CExperiment.h:670
virtual size_t numRows() const
Definition: CMatrix.h:138
CVector< size_t > mColumnValidValueCount
Definition: CExperiment.h:675
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
C_FLOAT64 mObjectiveValue
Definition: CExperiment.h:667
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
CVector< C_FLOAT64 > mRowRMS
Definition: CExperiment.h:671
C_FLOAT64 mMeanSD
Definition: CExperiment.h:666
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
const C_FLOAT64 & getTime() const
Definition: CModel.cpp:1190
CVector< C_FLOAT64 > mColumnObjectiveValue
Definition: CExperiment.h:673
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 mRMS
Definition: CExperiment.h:668
virtual size_t numCols() const
Definition: CMatrix.h:144
virtual CType * array()
Definition: CMatrix.h:337
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
#define max(a, b)
Definition: f2c.h:176
bool CExperiment::calculateWeights ( )

Calculate/set the weights used in the sum of squares.

Returns
bool success

Definition at line 1051 of file CExperiment.cpp.

References CVectorCore< CType >::array(), C_FLOAT64, max, mColumnValidValueCount, mDataDependent, mDefaultColumnScale, MEAN, MEAN_SQUARE, mMeans, mMissingData, mNumDataRows, mpNormalizeWeightsPerExperiment, mpWeightMethod, SD, CVectorCore< CType >::size(), and VALUE_SCALING.

Referenced by read(), CQExperimentData::slotCheckNormalizeWeightsPerExperiment(), and CQExperimentData::slotWeightMethod().

1052 {
1053  // We need to calculate the means and the weights
1055 
1056  size_t DependentCount = mMeans.size();
1057  CVector< C_FLOAT64 > MeanSquares(DependentCount);
1058  CVector< C_FLOAT64 > ColumnEpsilons(DependentCount);
1059  C_FLOAT64 * pColumnEpsilon;
1060  size_t i, j;
1061 
1062  mMeans = 0.0;
1063  MeanSquares = 0.0;
1064  ColumnEpsilons = std::numeric_limits< C_FLOAT64 >::infinity();
1065 
1067  mMissingData = false;
1068 
1069  // Calculate the means
1070  for (i = 0; i < mNumDataRows; i++)
1071  for (j = 0, pColumnEpsilon = ColumnEpsilons.array(); j < DependentCount; j++, pColumnEpsilon++)
1072  {
1073  C_FLOAT64 & Data = mDataDependent[i][j];
1074 
1075  if (!isnan(Data))
1076  {
1078  mMeans[j] += Data;
1079  MeanSquares[j] += Data * Data;
1080 
1081  if (Data != 0.0 && fabs(Data) < *pColumnEpsilon)
1082  {
1083  *pColumnEpsilon = fabs(Data);
1084  }
1085  }
1086  else
1087  mMissingData = true;
1088  }
1089 
1090  // calculate the means;
1091  for (j = 0, pColumnEpsilon = ColumnEpsilons.array(); j < DependentCount; j++, pColumnEpsilon++)
1092  {
1093  if (*pColumnEpsilon == std::numeric_limits< C_FLOAT64 >::infinity())
1094  {
1095  // TODO CRITICAL We need to create a preference for this.
1096  *pColumnEpsilon = 1e8 * std::numeric_limits< C_FLOAT64 >::epsilon();
1097  }
1098 
1099  if (mColumnValidValueCount[j])
1100  {
1101  mMeans[j] /= mColumnValidValueCount[j];
1102  MeanSquares[j] /= mColumnValidValueCount[j];
1103  }
1104  else
1105  {
1106  // :TODO: We need to create an error message here to instruct the user
1107  // :TODO: to mark this column as ignored as it contains no data.
1108  mMeans[j] = std::numeric_limits<C_FLOAT64>::quiet_NaN();
1109  MeanSquares[j] = std::numeric_limits<C_FLOAT64>::quiet_NaN();
1110  }
1111  }
1112 
1113  for (i = 0; i < DependentCount; i++)
1114  {
1115  C_FLOAT64 & DefaultColumScale = mDefaultColumnScale[i];
1116 
1117  switch (*mpWeightMethod)
1118  {
1119  case SD:
1120  DefaultColumScale = MeanSquares[i] - mMeans[i] * mMeans[i];
1121  break;
1122 
1123  case MEAN:
1124  DefaultColumScale = mMeans[i] * mMeans[i];
1125  break;
1126 
1127  case MEAN_SQUARE:
1128  DefaultColumScale = MeanSquares[i];
1129  break;
1130 
1131  case VALUE_SCALING:
1132  DefaultColumScale = ColumnEpsilons[i] * ColumnEpsilons[i] * 1e-12;
1133  break;
1134  }
1135 
1136  if (DefaultColumScale < MinWeight) MinWeight = DefaultColumScale;
1137  }
1138 
1140  {
1141  MinWeight = 1.0;
1142  }
1143 
1144  if (*mpWeightMethod != VALUE_SCALING)
1145  {
1146  // We have to calculate the default weights
1147  for (i = 0; i < DependentCount; i++)
1148  mDefaultColumnScale[i] =
1149  (MinWeight + sqrt(std::numeric_limits< C_FLOAT64 >::epsilon()))
1150  / (mDefaultColumnScale[i] + sqrt(std::numeric_limits< C_FLOAT64 >::epsilon()));
1151  }
1152 
1153  return true;
1154 }
CVector< C_FLOAT64 > mDefaultColumnScale
Definition: CExperiment.h:646
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
bool mMissingData
Definition: CExperiment.h:640
CVector< size_t > mColumnValidValueCount
Definition: CExperiment.h:675
size_t mNumDataRows
Definition: CExperiment.h:658
CVector< C_FLOAT64 > mMeans
Definition: CExperiment.h:642
size_t size() const
Definition: CVector.h:100
#define C_FLOAT64
Definition: copasi.h:92
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
bool * mpNormalizeWeightsPerExperiment
Definition: CExperiment.h:580
#define max(a, b)
Definition: f2c.h:176
bool CExperiment::compare ( const CExperiment lhs,
const CExperiment rhs 
)
static

Comparison used to evaluate the order of the experiment based on the filename and starting line number.

Parameters
constCExperiment * lhs;
constCExperiment * rhs;
Returns
bool isLess

Definition at line 1386 of file CExperiment.cpp.

References mpFileName, and mpFirstRow.

Referenced by CExperimentSet::sort().

1388 {
1389  return (*lhs->mpFileName < *rhs->mpFileName ||
1390  (*lhs->mpFileName == *rhs->mpFileName &&
1391  *lhs->mpFirstRow < *rhs->mpFirstRow));
1392 }
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
std::string * mpFileName
Definition: CExperiment.h:560
bool CExperiment::compile ( const std::vector< CCopasiContainer * >  listOfContainer = CCopasiContainer::EmptyList)

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

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

Definition at line 735 of file CExperiment.cpp.

References CCopasiObject::buildUpdateSequence(), C_FLOAT64, C_INVALID_INDEX, CExperimentObjectMap::compile(), dependent, CCopasiMessage::ERROR, CCopasiObjectName::escape(), CExperimentObjectMap::getLastColumn(), CExperimentObjectMap::getLastNotIgnoredColumn(), CExperimentObjectMap::getMappedObjects(), CCopasiObject::getObjectDataModel(), CCopasiParameter::getObjectDisplayName(), CCopasiObject::getObjectName(), CExperimentObjectMap::getRole(), CExperimentObjectMap::getScale(), CModel::getUptoDateObjects(), CCopasiContainer::getValueObject(), CCopasiParameter::getValuePointer(), ignore, independent, initializeScalingMatrix(), CCopasiObject::isValueDbl(), MCFitting, mColumnObjectiveValue, mColumnRMS, mColumnScale, mColumnValidValueCount, mDataDependent, mDataIndependent, mDependentObjects, mDependentValues, mIndependentObjects, mIndependentUpdateMethods, mIndependentValues, mMean, mMeanSD, mObjectiveValue, mpNumColumns, mpObjectMap, mpTaskType, mRefreshMethods, mRMS, mRowObjectiveValue, mRowRMS, CMatrix< CType >::numCols(), CMatrix< CType >::numRows(), CCopasiDataModel::ObjectFromName(), CVector< CType >::resize(), time, and CCopasiTask::timeCourse.

Referenced by CQExperimentData::slotCheckNormalizeWeightsPerExperiment(), CQExperimentData::slotExperimentChanged(), CQExperimentData::slotWeightMethod(), and CQExperimentData::updateScales().

736 {
737  bool success = true;
738 
739  if (!mpObjectMap->compile(listOfContainer))
740  success = false;
741 
742  size_t LastMappedColumn = mpObjectMap->getLastColumn();
744 
745  size_t i, imax = mpObjectMap->getLastNotIgnoredColumn();
746 
747  if (*mpNumColumns < imax)
748  *mpNumColumns = imax;
749 
750  //if (*mpNumColumns <= imax)
751  // {
752  // CCopasiMessage(CCopasiMessage::ERROR, MCFitting + 4, imax + 1, *mpNumColumns + 1);
753  // return false; // More column types specified than we have data columns
754  // }
755 
756  if (LastMappedColumn < imax || LastMappedColumn == C_INVALID_INDEX)
757  {
759  return false; // More column types specified than we have mapped columns
760  }
761 
762  size_t IndependentCount = mDataIndependent.numCols();
763  size_t DependentCount = mDataDependent.numCols();
764 
765  mDependentValues.resize(DependentCount);
766  mIndependentUpdateMethods.resize(IndependentCount);
767  mIndependentValues.resize(IndependentCount);
768  mIndependentObjects.clear();
769  mDependentObjects.clear();
770  std::set< const CCopasiObject * > Dependencies;
771 
772  IndependentCount = 0;
773  DependentCount = 0;
774 
775  bool TimeFound = false;
776 
777  for (i = 0; i <= imax; i++)
778  switch (mpObjectMap->getRole(i))
779  {
780  case ignore:
781  break;
782 
783  case independent:
784 
785  if (!Objects[i]) // Object not found
786  {
788  return false;
789  }
790 
791  if (!Objects[i]->isValueDbl())
792  {
793  CCopasiMessage(CCopasiMessage::ERROR, MCFitting + 6, Objects[i]->getObjectDisplayName().c_str(), i + 1);
794  return false;
795  }
796 
797  mIndependentObjects.insert(Objects[i]);
798  mIndependentUpdateMethods[IndependentCount] =
799  Objects[i]->getUpdateMethod();
800  mIndependentValues[IndependentCount] =
801  *(C_FLOAT64 *)Objects[i]->getValuePointer();
802  // :TODO: do we have to check if getValuePointer() return a valid pointer?
803 
804  IndependentCount++;
805  break;
806 
807  case dependent:
808 
809  if (!Objects[i]) // Object not found
810  {
812  return false;
813  }
814 
815  if (!Objects[i]->isValueDbl())
816  {
817  CCopasiMessage(CCopasiMessage::ERROR, MCFitting + 6, Objects[i]->getObjectDisplayName().c_str(), i + 1);
818  return false;
819  }
820 
821  mDependentValues[DependentCount] =
822  (C_FLOAT64 *) Objects[i]->getValuePointer();
823  // :TODO: do we have to check if getValuePointer() return a valid pointer?
824  mDependentObjects[Objects[i]] = DependentCount;
825  mColumnScale[DependentCount] = mpObjectMap->getScale(i);
826  Dependencies.insert(Objects[i]->getValueObject());
827 
828  DependentCount++;
829  break;
830 
831  case time:
832  TimeFound = true;
833  break;
834  }
835 
836  /* We need to check whether a column is mapped to time */
837  if (!TimeFound && *mpTaskType == CCopasiTask::timeCourse)
838  success = false;
839 
840  // Allocation and initialization of statistical information
841  size_t numRows = mDataDependent.numRows();
842  size_t numCols = mDataDependent.numCols();
843 
844  // Overall statistic;
845  mMean = std::numeric_limits<C_FLOAT64>::quiet_NaN();
846  mMeanSD = std::numeric_limits<C_FLOAT64>::quiet_NaN();
847  mObjectiveValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
848  mRMS = std::numeric_limits<C_FLOAT64>::quiet_NaN();
849 
850  // per row statistic;
851  mRowObjectiveValue.resize(numRows);
852  mRowObjectiveValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
853  mRowRMS.resize(numRows);
854  mRowRMS = std::numeric_limits<C_FLOAT64>::quiet_NaN();
855 
856  // per column statistic;
857  mColumnObjectiveValue.resize(numCols);
858  mColumnObjectiveValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
859  mColumnRMS.resize(numCols);
860  mColumnRMS = std::numeric_limits<C_FLOAT64>::quiet_NaN();
862  mColumnValidValueCount = std::numeric_limits<size_t>::quiet_NaN();
863 
864  CModel * pModel =
865  dynamic_cast< CModel * >(getObjectDataModel()->ObjectFromName(listOfContainer, CCopasiObjectName("Model=" + CCopasiObjectName::escape(getObjectDataModel()->getModel()->getObjectName()))));
866 
868 
870 
871  return success;
872 }
CCopasiDataModel * getObjectDataModel()
C_FLOAT64 getScale(const size_t &index) const
C_FLOAT64 mMean
Definition: CExperiment.h:665
const std::string & getObjectName() const
bool compile(const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
CVector< C_FLOAT64 > mColumnRMS
Definition: CExperiment.h:674
CExperiment::Type getRole(const size_t &index) const
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 > mRowObjectiveValue
Definition: CExperiment.h:670
CVector< C_FLOAT64 * > mDependentValues
Definition: CExperiment.h:648
virtual size_t numRows() const
Definition: CMatrix.h:138
CVector< size_t > mColumnValidValueCount
Definition: CExperiment.h:675
virtual void * getValuePointer() const
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
const std::set< const CCopasiObject * > & getUptoDateObjects() const
Definition: CModel.cpp:1178
#define C_INVALID_INDEX
Definition: copasi.h:222
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
static std::string escape(const std::string &name)
C_FLOAT64 mObjectiveValue
Definition: CExperiment.h:667
std::vector< Refresh * > mRefreshMethods
Definition: CExperiment.h:652
CMatrix< C_FLOAT64 > mDataIndependent
Definition: CExperiment.h:625
const CVector< CCopasiObject * > & getMappedObjects() const
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
const size_t & getLastColumn() const
CVector< C_FLOAT64 > mRowRMS
Definition: CExperiment.h:671
virtual const CCopasiObject * getValueObject() const
#define MCFitting
std::set< const CCopasiObject * > mIndependentObjects
Definition: CExperiment.h:654
C_FLOAT64 mMeanSD
Definition: CExperiment.h:666
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
CVector< C_FLOAT64 > mColumnScale
Definition: CExperiment.h:644
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
CVector< C_FLOAT64 > mColumnObjectiveValue
Definition: CExperiment.h:673
void initializeScalingMatrix()
#define C_FLOAT64
Definition: copasi.h:92
static std::vector< Refresh * > buildUpdateSequence(const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
bool isValueDbl() const
Definition: CModel.h:50
C_FLOAT64 mRMS
Definition: CExperiment.h:668
virtual size_t numCols() const
Definition: CMatrix.h:144
CVector< C_FLOAT64 > mIndependentValues
Definition: CExperiment.h:656
CVector< UpdateMethod * > mIndependentUpdateMethods
Definition: CExperiment.h:650
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
size_t getLastNotIgnoredColumn() const
bool CExperiment::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 300 of file CExperiment.cpp.

References CCopasiParameterGroup::clear(), CCopasiParameterGroup::getGroup(), CExperimentObjectMap::getObjectCN(), CCopasiParameterGroup::getValue(), mpObjectMap, mpWeightMethod, CCopasiParameter::Value::pUINT, CCopasiParameterGroup::removeParameter(), SD, CExperimentObjectMap::setNumCols(), CExperimentObjectMap::setObjectCN(), CExperimentObjectMap::setRole(), CCopasiParameterGroup::size(), StringPrint(), and updateFittedPoints().

Referenced by initializeParameter(), and operator=().

301 {
302  mpObjectMap =
303  elevate<CExperimentObjectMap, CCopasiParameterGroup>(getGroup("Object Map"));
304 
305  if (!mpObjectMap) return false;
306 
307  CCopasiParameterGroup *pGroup = getGroup("Column Role");
308 
309  if (pGroup) // We have an old data format
310  {
311  size_t i, imax = pGroup->size();
312  CExperimentObjectMap Roles;
313  Roles.setNumCols(imax);
314 
315  for (i = 0; i < imax; i++)
316  {
317  Roles.setRole(i, *(Type *) pGroup->getValue(StringPrint("%d", i)).pUINT);
318  Roles.setObjectCN(i, mpObjectMap->getObjectCN(i));
319  }
320 
321  mpObjectMap->clear();
322  *mpObjectMap = Roles;
323  mpObjectMap =
324  elevate<CExperimentObjectMap, CCopasiParameterGroup>(getGroup("Object Map"));
325 
326  removeParameter("Column Role");
327 
328  *mpWeightMethod = SD;
329  }
330 
332 
333  return true;
334 }
bool removeParameter(const std::string &name)
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
bool setRole(const size_t &index, const CExperiment::Type &role)
unsigned C_INT32 * pUINT
void updateFittedPoints()
std::string StringPrint(const char *format,...)
Definition: utility.cpp:87
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
const CCopasiParameter::Value & getValue(const std::string &name) const
std::string getObjectCN(const size_t &index) const
CCopasiParameterGroup * getGroup(const std::string &name)
bool setNumCols(const size_t &numCols)
bool setObjectCN(const size_t &index, const std::string &objectCN)
size_t CExperiment::extendedTimeSeriesSize ( ) const

Definition at line 596 of file CExperiment.cpp.

References mExtendedTimeSeriesSize.

Referenced by updateFittedPointValuesFromExtendedTimeSeries().

597 {
599 }
size_t mExtendedTimeSeriesSize
Definition: CExperiment.h:691
void CExperiment::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 1711 of file CExperiment.cpp.

References CExperimentObjectMap::fixBuild55(), and mpObjectMap.

1712 {
1714 }
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
const std::vector< std::string > & CExperiment::getColumnNames ( ) const

Retrieve the column names

Returns
const std::vector< std::string > & columnNames;

Definition at line 1214 of file CExperiment.cpp.

References mColumnName.

Referenced by CQExperimentData::loadTable().

1215 {return mColumnName;}
std::vector< std::string > mColumnName
Definition: CExperiment.h:610
size_t CExperiment::getColumnValidValueCount ( CCopasiObject *const &  pObject) const

Retrieve the data point count for the object.

Parameters
CCopasiObject* const & pObject
Returns
size_t count

Definition at line 1665 of file CExperiment.cpp.

References mColumnValidValueCount, and mDependentObjects.

1666 {
1667  std::map< CCopasiObject *, size_t>::const_iterator it
1668  = mDependentObjects.find(pObject);
1669 
1670  if (it != mDependentObjects.end())
1671  return mColumnValidValueCount[it->second];
1672  else
1673  return 0;
1674 }
CVector< size_t > mColumnValidValueCount
Definition: CExperiment.h:675
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
C_FLOAT64 CExperiment::getDefaultScale ( const CCopasiObject *const &  pObject) const

Retrieve the default scaling factor for the object.

Parameters
CCopasiObject*const& pObject
Returns
C_FLOAT64 defaultScale

Definition at line 1573 of file CExperiment.cpp.

References mDefaultColumnScale, and mDependentObjects.

Referenced by CExperimentObjectMap::CDataColumn::getDefaultScale().

1574 {
1575  std::map< CCopasiObject *, size_t>::const_iterator it
1576  = mDependentObjects.find(const_cast<CCopasiObject*>(pObject));
1577 
1578  if (it == mDependentObjects.end())
1579  return std::numeric_limits<C_FLOAT64>::quiet_NaN();
1580 
1581  return mDefaultColumnScale[it->second];
1582 }
CVector< C_FLOAT64 > mDefaultColumnScale
Definition: CExperiment.h:646
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
const CMatrix< C_FLOAT64 > & CExperiment::getDependentData ( ) const

Retrieve the dependent data of the experiment.

Returns
const CMatrix< C_FLOAT64 > & dependentData

Definition at line 1276 of file CExperiment.cpp.

References mDataDependent.

Referenced by CExperimentSet::getDependentData(), and initExtendedTimeSeries().

1277 {return mDataDependent;}
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
const std::map< CCopasiObject *, size_t > & CExperiment::getDependentObjects ( ) const

Retrieve the list of dependent data objects

Returns
const std::map< CCopasiObject *, size_t > & dependentObjects

Definition at line 1156 of file CExperiment.cpp.

References mDependentObjects.

1157 {return mDependentObjects;}
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
const C_FLOAT64 & CExperiment::getErrorMean ( ) const

Retrieve the mean of the error

Parameters
constC_FLOAT64 & errorMean

Definition at line 1556 of file CExperiment.cpp.

References mMean.

Referenced by CQFittingResult::enterProtected().

1557 {return mMean;}
C_FLOAT64 mMean
Definition: CExperiment.h:665
const C_FLOAT64 & CExperiment::getErrorMeanSD ( ) const

Retrieve the std. deviation of the error

Parameters
constC_FLOAT64 & errorMeanSD

Definition at line 1559 of file CExperiment.cpp.

References mMeanSD.

Referenced by CQFittingResult::enterProtected().

1560 {return mMeanSD;}
C_FLOAT64 mMeanSD
Definition: CExperiment.h:666
C_FLOAT64 CExperiment::getErrorMeanSD ( CCopasiObject *const &  pObject,
const C_FLOAT64 errorMean 
) const

Retrieve the error mean std. deviations for the object. More specifically this is the sum of the squared deviations of the residuals from the provided errorMean. The sum is over all data points for the object.

Parameters
CCopasiObject*const& pObject
C_FLOAT64errorMean
Returns
C_FLOAT64 errorMeanSD

Definition at line 1627 of file CExperiment.cpp.

References CMatrix< CType >::array(), C_FLOAT64, max, mDataDependent, mDependentObjects, mpDataDependentCalculated, mScale, CMatrix< CType >::numCols(), and CMatrix< CType >::numRows().

1629 {
1630  std::map< CCopasiObject *, size_t>::const_iterator it
1631  = mDependentObjects.find(pObject);
1632 
1633  if (it == mDependentObjects.end() ||
1634  mpDataDependentCalculated == NULL)
1635  return std::numeric_limits<C_FLOAT64>::quiet_NaN();
1636 
1637  C_FLOAT64 MeanSD = 0;
1638  C_FLOAT64 Residual;
1639  size_t numRows = mDataDependent.numRows();
1640  size_t numCols = mDataDependent.numCols();
1641 
1642  const C_FLOAT64 *pDataDependentCalculated = mpDataDependentCalculated + it->second;
1643  const C_FLOAT64 *pEnd = pDataDependentCalculated + numRows * numCols;
1644  const C_FLOAT64 *pDataDependent = mDataDependent.array() + it->second;
1645  const C_FLOAT64 *pScale = mScale.array() + it->second;
1646 
1647  for (; pDataDependentCalculated != pEnd;
1648  pDataDependentCalculated += numCols, pDataDependent += numCols)
1649  {
1650 
1651 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
1652  Residual = errorMean - (*pDataDependentCalculated - *pDataDependent) / std::max(1.0, *pDataDependentCalculated);
1653 #else
1654  Residual = errorMean - (*pDataDependentCalculated - *pDataDependent) * *pScale;
1655 #endif
1656 
1657  if (isnan(Residual)) continue;
1658 
1659  MeanSD += Residual * Residual;
1660  }
1661 
1662  return MeanSD;
1663 }
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
virtual size_t numRows() const
Definition: CMatrix.h:138
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
#define C_FLOAT64
Definition: copasi.h:92
virtual size_t numCols() const
Definition: CMatrix.h:144
virtual CType * array()
Definition: CMatrix.h:337
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
#define max(a, b)
Definition: f2c.h:176
C_FLOAT64 CExperiment::getErrorSum ( CCopasiObject *const &  pObject) const

Retrieve the sum of errors (scaled residuals) for the object.

Parameters
CCopasiObject*const& pObject
Returns
C_FLOAT64 errorSum

Definition at line 1595 of file CExperiment.cpp.

References CMatrix< CType >::array(), C_FLOAT64, mColumnScale, mDataDependent, mDependentObjects, mpDataDependentCalculated, CMatrix< CType >::numCols(), and CMatrix< CType >::numRows().

1596 {
1597  std::map< CCopasiObject *, size_t>::const_iterator it
1598  = mDependentObjects.find(pObject);
1599 
1600  if (it == mDependentObjects.end() ||
1601  mpDataDependentCalculated == NULL)
1602  return std::numeric_limits<C_FLOAT64>::quiet_NaN();
1603 
1604  C_FLOAT64 Mean = 0;
1605  C_FLOAT64 Residual;
1606  size_t numRows = mDataDependent.numRows();
1607  size_t numCols = mDataDependent.numCols();
1608 
1609  const C_FLOAT64 *pDataDependentCalculated = mpDataDependentCalculated + it->second;
1610  const C_FLOAT64 *pEnd = pDataDependentCalculated + numRows * numCols;
1611  const C_FLOAT64 *pDataDependent = mDataDependent.array() + it->second;
1612  const C_FLOAT64 & Weight = sqrt(mColumnScale[it->second]);
1613 
1614  for (; pDataDependentCalculated != pEnd;
1615  pDataDependentCalculated += numCols, pDataDependent += numCols)
1616  {
1617  Residual = Weight * (*pDataDependentCalculated - *pDataDependent);
1618 
1619  if (isnan(Residual)) continue;
1620 
1621  Mean += Residual;
1622  }
1623 
1624  return Mean;
1625 }
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
virtual size_t numRows() const
Definition: CMatrix.h:138
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
CVector< C_FLOAT64 > mColumnScale
Definition: CExperiment.h:644
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
#define C_FLOAT64
Definition: copasi.h:92
virtual size_t numCols() const
Definition: CMatrix.h:144
virtual CType * array()
Definition: CMatrix.h:337
const CCopasiTask::Type & CExperiment::getExperimentType ( ) const
const std::string & CExperiment::getFileName ( ) const

Retrieve the file name

Returns
const std::string & fileName

Definition at line 1279 of file CExperiment.cpp.

References CDirEntry::fileName(), CCopasiObject::getObjectDataModel(), CDirEntry::isRelativePath(), CDirEntry::makePathAbsolute(), and mpFileName.

Referenced by guessColumnNumber(), printResult(), readColumnNames(), CQExperimentData::slotCheckNormalizeWeightsPerExperiment(), CQExperimentData::slotExperimentChanged(), CQExperimentData::slotFileDelete(), CQExperimentData::slotWeightMethod(), CExperimentFileInfo::sync(), and CQExperimentData::updateScales().

1280 {
1281  std::string * pFileName = const_cast<CExperiment *>(this)->mpFileName;
1282 
1283  if (CDirEntry::isRelativePath(*pFileName) &&
1284  !CDirEntry::makePathAbsolute(*pFileName,
1286  *pFileName = CDirEntry::fileName(*pFileName);
1287 
1288  return *mpFileName;
1289 }
CCopasiDataModel * getObjectDataModel()
const std::string & getFileName() const
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
std::string * mpFileName
Definition: CExperiment.h:560
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
static bool makePathAbsolute(std::string &relativePath, const std::string &absoluteTo)
Definition: CDirEntry.cpp:481
const unsigned C_INT32 & CExperiment::getFirstRow ( ) const

Retrieve the first row

Returns
const unsigned C_INT32 & firstRow

Definition at line 1303 of file CExperiment.cpp.

References mpFirstRow.

Referenced by CQExperimentData::loadExperiment(), and CQExperimentData::slotCheckFrom().

1304 {return *mpFirstRow;}
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
const CCopasiVector< CFittingPoint > & CExperiment::getFittingPoints ( ) const

Retrieve the list of fitting points

Returns
const CCopasiVector< CFittingPoint > & fittingPoints

Definition at line 1300 of file CExperiment.cpp.

References mFittingPoints.

Referenced by COutputAssistant::createDefaultOutput().

1301 {return mFittingPoints;}
CCopasiVector< CFittingPoint > mFittingPoints
Definition: CExperiment.h:682
const unsigned C_INT32 & CExperiment::getHeaderRow ( ) const

Retrieve the header row

Returns
const unsigned C_INT32 & headerRow

Definition at line 1327 of file CExperiment.cpp.

References mpHeaderRow.

Referenced by CQExperimentData::isLikePreviousExperiment(), and CQExperimentData::loadExperiment().

1328 {return *mpHeaderRow;}
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
const CMatrix< C_FLOAT64 > & CExperiment::getIndependentData ( ) const

Retrieve the independent data of the experiment.

Returns
const CMatrix< C_FLOAT64 > & independentData

Definition at line 1273 of file CExperiment.cpp.

References mDataIndependent.

Referenced by CExperimentSet::getIndependentData().

1274 {return mDataIndependent;}
CMatrix< C_FLOAT64 > mDataIndependent
Definition: CExperiment.h:625
const std::set< const CCopasiObject * > & CExperiment::getIndependentObjects ( ) const

Retrieve the list of independent objects

Returns
const std::set< const CCopasiObject * > & independentObjects

Definition at line 1676 of file CExperiment.cpp.

References mIndependentObjects.

Referenced by CFitProblem::initialize().

1677 {
1678  return mIndependentObjects;
1679 }
std::set< const CCopasiObject * > mIndependentObjects
Definition: CExperiment.h:654
const unsigned C_INT32 & CExperiment::getLastRow ( ) const

Retrieve the last row

Returns
const unsigned C_INT32 & lastRow

Definition at line 1315 of file CExperiment.cpp.

References mpLastRow.

Referenced by CQExperimentData::loadExperiment(), CQExperimentData::slotCheckFrom(), and CQExperimentDataValidator::validate().

1316 {return *mpLastRow;}
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
bool CExperiment::getNormalizeWeightsPerExperiment ( ) const

Definition at line 1262 of file CExperiment.cpp.

References mpNormalizeWeightsPerExperiment.

Referenced by CQExperimentData::isLikePreviousExperiment(), and CQExperimentData::loadExperiment().

1263 {
1266  else
1267  return true;
1268 }
bool * mpNormalizeWeightsPerExperiment
Definition: CExperiment.h:580
const unsigned C_INT32 & CExperiment::getNumColumns ( ) const

Retrieve the number of columns

Returns
const unsigned C_INT32 & numColumns

Definition at line 1338 of file CExperiment.cpp.

References mpNumColumns.

1339 {return *mpNumColumns;}
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
size_t CExperiment::getNumDataRows ( ) const

Retrieve the number of data rows

Returns
const size_t numDataRows

Definition at line 1347 of file CExperiment.cpp.

References mNumDataRows.

Referenced by CFitProblem::calculate(), and CFitProblem::calculateCrossValidation().

1348 {return mNumDataRows;}
size_t mNumDataRows
Definition: CExperiment.h:658
const C_FLOAT64 & CExperiment::getObjectiveValue ( ) const

Retrieve the value of the objective function

Parameters
constC_FLOAT64 & errorMean

Definition at line 1550 of file CExperiment.cpp.

References mObjectiveValue.

Referenced by CQFittingResult::enterProtected().

1551 {return mObjectiveValue;}
C_FLOAT64 mObjectiveValue
Definition: CExperiment.h:667
C_FLOAT64 CExperiment::getObjectiveValue ( CCopasiObject *const &  pObject) const

Retrieve the objective value for the object.

Parameters
CCopasiObject*const& pObject
Returns
C_FLOAT64 objectiveValue

Definition at line 1562 of file CExperiment.cpp.

References mColumnObjectiveValue, and mDependentObjects.

1563 {
1564  std::map< CCopasiObject *, size_t >::const_iterator it
1565  = mDependentObjects.find(pObject);
1566 
1567  if (it != mDependentObjects.end())
1568  return mColumnObjectiveValue[it->second];
1569  else
1570  return std::numeric_limits<C_FLOAT64>::quiet_NaN();
1571 }
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
CVector< C_FLOAT64 > mColumnObjectiveValue
Definition: CExperiment.h:673
CExperimentObjectMap & CExperiment::getObjectMap ( )

Retrieve the object map

Returns
CExperimentObjectMap & mpObjectMap

Definition at line 1297 of file CExperiment.cpp.

References mpObjectMap.

Referenced by CQExperimentData::isLikePreviousExperiment(), CQExperimentData::loadTable(), CQExperimentData::saveTable(), CQExperimentData::slotExprimentType(), and CQExperimentData::updateScales().

1298 {return * mpObjectMap;}
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
const C_FLOAT64 & CExperiment::getRMS ( ) const

Retrieve the RMS

Parameters
constC_FLOAT64 & RMS

Definition at line 1553 of file CExperiment.cpp.

References mRMS.

Referenced by CQFittingResult::enterProtected().

1554 {return mRMS;}
C_FLOAT64 mRMS
Definition: CExperiment.h:668
C_FLOAT64 CExperiment::getRMS ( CCopasiObject *const &  pObject) const

Retrieve the RMS for the object.

Parameters
CCopasiObject*const& pObject
Returns
C_FLOAT64 RMS

Definition at line 1584 of file CExperiment.cpp.

References mColumnRMS, and mDependentObjects.

1585 {
1586  std::map< CCopasiObject *, size_t>::const_iterator it
1587  = mDependentObjects.find(pObject);
1588 
1589  if (it != mDependentObjects.end())
1590  return mColumnRMS[it->second];
1591  else
1592  return std::numeric_limits<C_FLOAT64>::quiet_NaN();
1593 }
CVector< C_FLOAT64 > mColumnRMS
Definition: CExperiment.h:674
std::map< CCopasiObject *, size_t > mDependentObjects
Definition: CExperiment.h:680
const std::string & CExperiment::getSeparator ( ) const

Retrieve the separator

Returns
const std::string & separator

Definition at line 1350 of file CExperiment.cpp.

References mpSeparator.

Referenced by CQExperimentData::isLikePreviousExperiment(), and CQExperimentData::loadExperiment().

1351 {return *mpSeparator;}
std::string * mpSeparator
Definition: CExperiment.h:585
const CVector< C_FLOAT64 > & CExperiment::getTimeData ( ) const

Retrieve the time data of the experiment.

Returns
const CVector< C_FLOAT64 > & timeData

Definition at line 1270 of file CExperiment.cpp.

References mDataTime.

Referenced by CFitProblem::calculate(), and CFitProblem::calculateCrossValidation().

1271 {return mDataTime;}
CVector< C_FLOAT64 > mDataTime
Definition: CExperiment.h:620
const CExperiment::WeightMethod & CExperiment::getWeightMethod ( ) const

Retrieve the method used for calculating the default weights.

Returns
const WeightMethod & weightMethod

Definition at line 1359 of file CExperiment.cpp.

References mpWeightMethod.

Referenced by CQExperimentData::isLikePreviousExperiment(), CQExperimentData::loadExperiment(), CQExperimentData::slotCheckTo(), and CQExperimentData::slotWeightMethod().

1360 {return *mpWeightMethod;}
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
size_t CExperiment::guessColumnNumber ( ) const

Try to guess the number of columns

Returns
size_t numColumns

Definition at line 1190 of file CExperiment.cpp.

References CLocaleString::fromUtf8(), getFileName(), CTableRow::guessColumnNumber(), mpFirstRow, mpLastRow, mpSeparator, and skipLine().

Referenced by CQExperimentData::slotExperimentAdd(), and CQExperimentData::slotSeparator().

1191 {
1192  size_t tmp, count = 0;
1193 
1194  std::ifstream in;
1195  in.open(CLocaleString::fromUtf8(getFileName()).c_str(), std::ios::binary);
1196 
1197  if (in.fail()) return false;
1198 
1199  // Forwind to first row.
1200  size_t i;
1201 
1202  for (i = 1; i < *mpFirstRow && !in.fail(); i++)
1203  skipLine(in);
1204 
1205  CTableRow Row(0, (*mpSeparator)[0]);
1206 
1207  for (i--; i < *mpLastRow; i++)
1208  if ((tmp = Row.guessColumnNumber(in, false)) > count)
1209  count = tmp;
1210 
1211  return count;
1212 }
const std::string & getFileName() const
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
std::string * mpSeparator
Definition: CExperiment.h:585
std::istream & skipLine(std::istream &in)
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
static CLocaleString fromUtf8(const std::string &utf8)
void CExperiment::initExtendedTimeSeries ( size_t  s)

Initialize the storage of an extended time series for plotting. This clears the storage, resizes it to the given size and sets the iterator to the start of the storage. The size given is the number of time points, not the number of data

Definition at line 569 of file CExperiment.cpp.

References CVectorCore< CType >::array(), getDependentData(), mExtendedTimeSeries, mExtendedTimeSeriesSize, mStorageIt, and CVector< CType >::resize().

Referenced by CFitProblem::calculate(), and CFitProblem::calculateCrossValidation().

570 {
572  mExtendedTimeSeries.resize(s * (this->getDependentData().numCols() + 1)); //+1 for time
574 }
const CMatrix< C_FLOAT64 > & getDependentData() const
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
C_FLOAT64 * mStorageIt
Definition: CExperiment.h:688
size_t mExtendedTimeSeriesSize
Definition: CExperiment.h:691
CType * array()
Definition: CVector.h:139
CVector< C_FLOAT64 > mExtendedTimeSeries
Definition: CExperiment.h:685
void CExperiment::initializeParameter ( )
private

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

Definition at line 256 of file CExperiment.cpp.

References CKeyFactory::add(), CCopasiParameterGroup::assertGroup(), CCopasiParameterGroup::assertParameter(), CCopasiParameter::BOOL, C_INT32, elevateChildren(), CCopasiParameter::FILE, CCopasiRootContainer::getKeyFactory(), CCopasiParameterGroup::getParameter(), CCopasiParameter::getValue(), InvalidIndex, CCopasiParameter::KEY, MEAN_SQUARE, CCopasiParameter::mKey, mpFileName, mpFirstRow, mpHeaderRow, mpLastRow, mpNormalizeWeightsPerExperiment, mpNumColumns, mpRowOriented, mpSeparator, mpTaskType, mpWeightMethod, CCopasiParameter::Value::pBOOL, CCopasiParameter::Value::pFILE, CCopasiParameter::Value::pSTRING, CCopasiParameter::Value::pUINT, CKeyFactory::remove(), CCopasiParameterGroup::removeParameter(), CCopasiParameter::setValue(), CCopasiParameter::STRING, CCopasiParameter::UINT, and CCopasiTask::unset.

Referenced by CExperiment().

257 {
259  mKey = CCopasiRootContainer::getKeyFactory()->add("Experiment", this);
260 
262 
263  mpFileName =
264  assertParameter("File Name", CCopasiParameter::FILE, std::string(""))->getValue().pFILE;
265  mpFirstRow =
267  mpLastRow =
271 
273  assertParameter("Normalize Weights per Experiment", CCopasiParameter::BOOL, true)->getValue().pBOOL;
274 
275  mpSeparator =
276  assertParameter("Separator", CCopasiParameter::STRING, std::string("\t"))->getValue().pSTRING;
278  assertParameter("Weight Method", CCopasiParameter::UINT, (unsigned C_INT32) MEAN_SQUARE)->getValue().pUINT;
279  mpRowOriented =
280  assertParameter("Data is Row Oriented", CCopasiParameter::BOOL, (bool) true)->getValue().pBOOL;
281  mpHeaderRow =
282  assertParameter("Row containing Names", CCopasiParameter::UINT, (unsigned C_INT32) InvalidIndex)->getValue().pUINT;
283  mpNumColumns =
284  assertParameter("Number of Columns", CCopasiParameter::UINT, (unsigned C_INT32) 0)->getValue().pUINT;
285 
286  assertGroup("Object Map");
287 
288  // Old files have a typo in the name of the separator parameter.
289  CCopasiParameter * pParameter = getParameter("Seperator");
290 
291  if (pParameter != NULL)
292  {
293  *mpSeparator = *pParameter->getValue().pSTRING;
294  removeParameter("Seperator");
295  }
296 
297  elevateChildren();
298 }
bool remove(const std::string &key)
virtual bool elevateChildren()
bool setValue(const CType &value)
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
std::string * mpSeparator
Definition: CExperiment.h:585
std::string * mpFileName
Definition: CExperiment.h:560
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
#define InvalidIndex
Definition: CExperiment.cpp:38
#define C_INT32
Definition: copasi.h:90
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
bool removeParameter(const std::string &name)
const Value & getValue() const
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
unsigned C_INT32 * pUINT
CCopasiParameterGroup * assertGroup(const std::string &name)
CCopasiParameter * getParameter(const std::string &name)
std::string add(const std::string &prefix, CCopasiObject *pObject)
bool * mpRowOriented
Definition: CExperiment.h:595
static CKeyFactory * getKeyFactory()
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
bool * mpNormalizeWeightsPerExperiment
Definition: CExperiment.h:580
CCopasiParameter * assertParameter(const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
void CExperiment::initializeScalingMatrix ( )
private

Initialize the scaling matrix

Definition at line 1681 of file CExperiment.cpp.

References CVectorCore< CType >::array(), CMatrix< CType >::array(), C_FLOAT64, max, mColumnScale, mDataDependent, mpWeightMethod, mScale, CMatrix< CType >::numCols(), CMatrix< CType >::numRows(), CMatrix< CType >::resize(), CVectorCore< CType >::size(), CMatrix< CType >::size(), and VALUE_SCALING.

Referenced by compile().

1682 {
1684 
1685  // We need to initialize the scaling factors for the residuals
1686  C_FLOAT64 * pData = mDataDependent.array();
1687  C_FLOAT64 * pScale = mScale.array();
1688  C_FLOAT64 * pScaleEnd = pScale + mScale.size();
1689 
1690  C_FLOAT64 * pColumnScale = mColumnScale.array();
1691  C_FLOAT64 * pColumnScaleEnd = pColumnScale + mColumnScale.size();
1692 
1693  for (; pScale < pScaleEnd;)
1694  {
1695  for (pColumnScale = mColumnScale.array(); pColumnScale < pColumnScaleEnd; ++pColumnScale, ++pScale, ++pData)
1696  {
1697  switch (*mpWeightMethod)
1698  {
1699  case VALUE_SCALING:
1700  *pScale = 1.0 / std::max(fabs(*pData), *pColumnScale);
1701  break;
1702 
1703  default:
1704  *pScale = sqrt(*pColumnScale);
1705  break;
1706  }
1707  }
1708  }
1709 }
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
virtual size_t numRows() const
Definition: CMatrix.h:138
CVector< C_FLOAT64 > mColumnScale
Definition: CExperiment.h:644
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
size_t size() const
Definition: CVector.h:100
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
virtual size_t size() const
Definition: CMatrix.h:132
virtual size_t numCols() const
Definition: CMatrix.h:144
virtual CType * array()
Definition: CMatrix.h:337
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
#define max(a, b)
Definition: f2c.h:176
const bool & CExperiment::isRowOriented ( ) const

Check whter the data is row oriented.

Returns
const bool & isRowOriented

Definition at line 1377 of file CExperiment.cpp.

References mpRowOriented.

Referenced by setIsRowOriented().

1378 {return *mpRowOriented;}
bool * mpRowOriented
Definition: CExperiment.h:595
CExperiment & CExperiment::operator= ( const CExperiment rhs)

Assignment operator

Parameters
constCExperiment & rhs
Returns
CExperiment & lhs

Definition at line 229 of file CExperiment.cpp.

References CCopasiParameterGroup::clear(), elevateChildren(), CCopasiParameter::getValue(), mpFileName, mpFirstRow, mpHeaderRow, mpLastRow, mpNormalizeWeightsPerExperiment, mpNumColumns, mpRowOriented, mpSeparator, mpTaskType, mpWeightMethod, CCopasiParameter::Value::pBOOL, CCopasiParameter::Value::pFILE, CCopasiParameter::Value::pKEY, CCopasiParameter::Value::pSTRING, CCopasiParameter::Value::pUINT, and CCopasiParameterGroup::setValue().

230 {
231  std::string Key = *getValue("Key").pKEY;
232 
233  clear();
234 
235  *static_cast<CCopasiParameterGroup *>(this) =
236  *static_cast<const CCopasiParameterGroup *>(&rhs);
237 
238  setValue("Key", Key);
239 
240  mpFileName = getValue("File Name").pFILE;
241  mpFirstRow = getValue("First Row").pUINT;
242  mpLastRow = getValue("Last Row").pUINT;
243  mpTaskType = (CCopasiTask::Type *) getValue("Experiment Type").pUINT;
244  mpNormalizeWeightsPerExperiment = getValue("Normalize Weights per Experiment").pBOOL;
245  mpSeparator = getValue("Separator").pSTRING;
246  mpWeightMethod = (WeightMethod *) getValue("Weight Method").pUINT;
247  mpRowOriented = getValue("Data is Row Oriented").pBOOL;
248  mpHeaderRow = getValue("Row containing Names").pUINT;
249  mpNumColumns = getValue("Number of Columns").pUINT;
250 
251  elevateChildren();
252 
253  return *this;
254 }
virtual bool elevateChildren()
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
std::string * mpSeparator
Definition: CExperiment.h:585
std::string * mpFileName
Definition: CExperiment.h:560
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
const Value & getValue() const
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
bool setValue(const std::string &name, const CType &value)
unsigned C_INT32 * pUINT
bool * mpRowOriented
Definition: CExperiment.h:595
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
bool * mpNormalizeWeightsPerExperiment
Definition: CExperiment.h:580
void CExperiment::printResult ( std::ostream *  ostream) const
virtual

This is the output method for the statistics for the experiment. This method is called from CFitProblem::printResult.

Parameters
std::ostream* ostream

Definition at line 1409 of file CExperiment.cpp.

References C_FLOAT64, dependent, getFileName(), CExperimentObjectMap::getLastNotIgnoredColumn(), CExperimentObjectMap::getMappedObjects(), CCopasiParameter::getObjectDisplayName(), CCopasiObject::getObjectName(), CExperimentObjectMap::getRole(), mColumnObjectiveValue, mColumnRMS, mColumnScale, mDataDependent, mDataTime, mMean, mNumDataRows, mObjectiveValue, mpDataDependentCalculated, mpObjectMap, mpTaskType, mRMS, mRowObjectiveValue, mRowRMS, mScale, CMatrix< CType >::numCols(), CVectorCore< CType >::size(), and CCopasiTask::timeCourse.

Referenced by CFitProblem::printResult().

1410 {
1411  std::ostream & os = *ostream;
1412 
1413  os << "File Name:\t" << getFileName() << std::endl;
1414  os << "Experiment:\t" << getObjectName() << std::endl;
1415 
1416  os << "Mean:\t" << mMean << std::endl;
1417  os << "Objective Value:\t" << mObjectiveValue << std::endl;
1418  os << "Root Mean Square:\t" << mRMS << std::endl;
1419 
1420  size_t i, imax = mNumDataRows;
1421  size_t j, jmax = mDataDependent.numCols();
1422  size_t k, kmax = mpObjectMap->getLastNotIgnoredColumn() + 1;
1423 
1424  const CVector<CCopasiObject *> & Objects =
1426 
1427  os << "Row\t";
1428 
1430  os << "Time\t";
1431 
1432  for (k = 0; k < kmax; k++)
1434  {
1435  std::string Name;
1436 
1437  if (k < Objects.size() && Objects[k] != NULL)
1438  Name = Objects[k]->getObjectDisplayName();
1439  else
1440  Name = "unknown";
1441 
1442  os << Name << "(Data)\t";
1443  os << Name << "(Fit)\t";
1444  os << Name << "(Weighted Error)\t";
1445  }
1446 
1447  os << "Objective Value\tRoot Mean Square" << std::endl << std::endl;
1448 
1449  C_FLOAT64 * pDataDependentCalculated = mpDataDependentCalculated;
1450 
1451  if (pDataDependentCalculated)
1452  for (i = 0; i < imax; i++)
1453  {
1454  os << i + 1 << ".\t";
1455 
1457  os << mDataTime[i] << "\t";
1458 
1459  for (j = 0; j < jmax; j++, pDataDependentCalculated++)
1460  {
1461  os << mDataDependent(i, j) << "\t";
1462  os << *pDataDependentCalculated << "\t";
1463  os << mScale(i, j) *(*pDataDependentCalculated - mDataDependent(i, j)) << "\t";
1464  }
1465 
1466  os << mRowObjectiveValue[i] << "\t" << mRowRMS[i] << std::endl;
1467  }
1468  else
1469  for (i = 0; i < imax; i++)
1470  {
1471  os << i + 1 << ".\t";
1472 
1474  os << mDataTime[i] << "\t";
1475 
1476  for (j = 0; j < jmax; j++)
1477  {
1478  os << mDataDependent(i, j) << "\tNaN\tNaN\t";
1479  }
1480 
1481  if (i < mRowObjectiveValue.size())
1482  {
1483  os << mRowObjectiveValue[i] << "\t";
1484  }
1485  else
1486  {
1487  os << "NaN\t";
1488  }
1489 
1490  if (i < mRowRMS.size())
1491  {
1492  os << mRowRMS[i];
1493  }
1494  else
1495  {
1496  os << "NaN";
1497  }
1498 
1499  os << std::endl;
1500  }
1501 
1502  os << "Objective Value";
1503 
1505  os << "\t";
1506 
1507  for (j = 0; j < jmax; j++)
1508  {
1509  if (j < mColumnObjectiveValue.size())
1510  os << "\t\t\t" << mColumnObjectiveValue[j];
1511  else
1512  os << "\t\t\tNaN";
1513  }
1514 
1515  os << std::endl;
1516 
1517  os << "Root Mean Square";
1518 
1520  os << "\t";
1521 
1522  for (j = 0; j < jmax; j++)
1523  {
1524  if (j < mColumnRMS.size())
1525  os << "\t\t\t" << mColumnRMS[j];
1526  else
1527  os << "\t\t\tNaN";
1528  }
1529 
1530  os << std::endl;
1531 
1532  os << "Weight";
1533 
1535  os << "\t";
1536 
1537  for (j = 0; j < jmax; j++)
1538  {
1539  if (j < mColumnScale.size())
1540  os << "\t\t\t" << mColumnScale[j];
1541  else
1542  os << "\t\t\tNaN";
1543  }
1544 
1545  os << std::endl;
1546 
1547  return;
1548 }
const std::string & getFileName() const
C_FLOAT64 mMean
Definition: CExperiment.h:665
const std::string & getObjectName() const
CVector< C_FLOAT64 > mColumnRMS
Definition: CExperiment.h:674
CExperiment::Type getRole(const size_t &index) const
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 > mRowObjectiveValue
Definition: CExperiment.h:670
size_t mNumDataRows
Definition: CExperiment.h:658
C_FLOAT64 mObjectiveValue
Definition: CExperiment.h:667
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
const CVector< CCopasiObject * > & getMappedObjects() const
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
CVector< C_FLOAT64 > mRowRMS
Definition: CExperiment.h:671
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
CVector< C_FLOAT64 > mColumnScale
Definition: CExperiment.h:644
size_t size() const
Definition: CVector.h:100
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
CVector< C_FLOAT64 > mDataTime
Definition: CExperiment.h:620
CVector< C_FLOAT64 > mColumnObjectiveValue
Definition: CExperiment.h:673
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 mRMS
Definition: CExperiment.h:668
virtual size_t numCols() const
Definition: CMatrix.h:144
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
size_t getLastNotIgnoredColumn() const
bool CExperiment::read ( std::istream &  in,
size_t &  currentLine 
)

Reads the experiment data form a the given stream

Parameters
std::istream& in
size_t& currentLine
Returns
bool success

Definition at line 874 of file CExperiment.cpp.

References CVectorCore< CType >::applyPivot(), CMatrix< CType >::applyPivot(), CVectorCore< CType >::array(), C_INVALID_INDEX, calculateWeights(), dependent, CCopasiMessage::ERROR, CTableRow::getCells(), CCopasiParameterGroup::getName(), CCopasiObject::getObjectName(), CExperimentObjectMap::getRole(), ignore, independent, MCFitting, mColumnName, mColumnScale, mColumnValidValueCount, mDataDependent, mDataIndependent, mDataTime, mDefaultColumnScale, mMeans, mNumDataRows, mpDataDependentCalculated, mpFileName, mpFirstRow, mpHeaderRow, mpLastRow, mpNumColumns, mpObjectMap, mpSeparator, mpTaskType, CMatrix< CType >::resize(), CVector< CType >::resize(), CVectorCore< CType >::size(), CCopasiParameterGroup::size(), skipLine(), sortWithPivot(), time, and CCopasiTask::timeCourse.

Referenced by CQExperimentData::slotCheckNormalizeWeightsPerExperiment(), CQExperimentData::slotExperimentChanged(), CQExperimentData::slotWeightMethod(), and CQExperimentData::updateScales().

876 {
877  // Allocate for reading
878  size_t i, imax = mpObjectMap->size();
879 
880  if (*mpNumColumns < imax)
881  *mpNumColumns = imax;
882  //if (*mpNumColumns < imax)
883  // {
884  // CCopasiMessage(CCopasiMessage::ERROR, MCFitting + 4, imax, *mpNumColumns);
885  // return false; // More column types specified than we have data columns
886  // }
887 
888  size_t IndependentCount = 0;
889  size_t DependentCount = 0;
890  size_t TimeCount = 0;
891  size_t IgnoreCount = 0;
892 
893  for (i = 0; i < imax; i++)
894  switch (mpObjectMap->getRole(i))
895  {
896  case ignore:
897  IgnoreCount++;
898  break;
899 
900  case independent:
901  IndependentCount++;
902  break;
903 
904  case dependent:
905  DependentCount++;
906  break;
907 
908  case time:
909  TimeCount++;
910  break;
911  }
912 
914  ((*mpHeaderRow < *mpFirstRow || *mpLastRow < *mpHeaderRow) ? 1 : 0);
915 
916  mDataTime.resize(TimeCount ? mNumDataRows : 0);
917  mDataIndependent.resize(mNumDataRows, IndependentCount);
918  mDataDependent.resize(mNumDataRows, DependentCount);
920  mColumnName.resize(IndependentCount + DependentCount + TimeCount);
921 
922  // resize the vectors for the statistics
923  mMeans.resize(DependentCount);
924  mColumnScale.resize(DependentCount);
925  mDefaultColumnScale.resize(DependentCount);
926  mColumnValidValueCount.resize(DependentCount);
927 
928  if (!TimeCount && *mpTaskType == CCopasiTask::timeCourse)
929  {
931  return false;
932  }
933 
934  if (DependentCount == 0)
935  {
937  return false;
938  }
939 
940  if (mNumDataRows == 0)
941  {
943  return false;
944  }
945 
946  CTableRow Row(*mpNumColumns, (*mpSeparator)[0]);
947  const std::vector< CTableCell > & Cells = Row.getCells();
948 
949  size_t j;
950 
951  if (currentLine > *mpFirstRow) return false; // We are past our first line
952 
953  // forwind to our first line
954  for (j = currentLine; j < *mpFirstRow && !in.fail(); j++)
955  {
956  skipLine(in);
957  currentLine++;
958  }
959 
960  for (j = 0; j < mNumDataRows && !in.fail(); j++, currentLine++)
961  {
962  in >> Row;
963 
964  if (currentLine == *mpHeaderRow)
965  {
966  j--;
967 
968  size_t Column = 0;
969 
970  for (i = 0; i < *mpNumColumns; i++)
971  if (mpObjectMap->getRole(i) != ignore)
972  mColumnName[Column++] = Cells[i].getName();
973 
974  continue;
975  }
976 
977  IndependentCount = 0;
978  DependentCount = 0;
979 
980  for (i = 0; i < imax; i++)
981  {
982  switch (mpObjectMap->getRole(i))
983  {
984  case ignore:
985  break;
986 
987  case independent:
988 
989  if (!Cells[i].isValue())
990  {
992  getObjectName().c_str(), currentLine, i + 1);
993  return false;
994  }
995 
996  mDataIndependent[j][IndependentCount++] =
997  Cells[i].getValue();
998  break;
999 
1000  case dependent:
1001  mDataDependent[j][DependentCount++] =
1002  Cells[i].getValue();
1003  break;
1004 
1005  case time:
1006 
1007  if (!Cells[i].isValue())
1008  {
1010  getObjectName().c_str(), currentLine, i + 1);
1011  return false;
1012  }
1013 
1014  mDataTime[j] = Cells[i].getValue();
1015  break;
1016  }
1017  }
1018  }
1019 
1020  if ((in.fail() && !in.eof()))
1021  {
1023  return false;
1024  }
1025 
1026  if (j != mNumDataRows)
1027  {
1028  CCopasiMessage(CCopasiMessage::ERROR, MCFitting + 7, mNumDataRows, j - 1);
1029  return false;
1030  }
1031 
1032  // If it is a time course this is the place to assert that it is sorted.
1034  {
1035  CVector<size_t> Pivot;
1037 
1038  mDataTime.applyPivot(Pivot);
1040  mDataDependent.applyPivot(Pivot);
1041 
1042  for (mNumDataRows--; mNumDataRows != C_INVALID_INDEX; mNumDataRows--)
1043  if (!isnan(mDataTime[mNumDataRows])) break;
1044 
1045  mNumDataRows++;
1046  }
1047 
1048  return calculateWeights();
1049 }
void sortWithPivot(RandomAccessIterator first, RandomAccessIterator last, CVector< size_t > &pivot)
Definition: CSort.h:77
std::vector< std::string > mColumnName
Definition: CExperiment.h:610
virtual const std::string & getName(const size_t &index) const
const std::string & getObjectName() const
CVector< C_FLOAT64 > mDefaultColumnScale
Definition: CExperiment.h:646
CExperiment::Type getRole(const size_t &index) const
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< size_t > mColumnValidValueCount
Definition: CExperiment.h:675
std::string * mpSeparator
Definition: CExperiment.h:585
size_t mNumDataRows
Definition: CExperiment.h:658
std::string * mpFileName
Definition: CExperiment.h:560
std::istream & skipLine(std::istream &in)
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
#define C_INVALID_INDEX
Definition: copasi.h:222
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
CMatrix< C_FLOAT64 > mDataIndependent
Definition: CExperiment.h:625
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
#define MCFitting
CVector< C_FLOAT64 > mMeans
Definition: CExperiment.h:642
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
CVector< C_FLOAT64 > mColumnScale
Definition: CExperiment.h:644
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
size_t size() const
Definition: CVector.h:100
bool calculateWeights()
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
CVector< C_FLOAT64 > mDataTime
Definition: CExperiment.h:620
CType * array()
Definition: CVector.h:139
bool applyPivot(const CVector< size_t > &pivot)
Definition: CMatrix.h:351
bool applyPivot(const CVectorCore< size_t > &pivot)
Definition: CVector.h:172
bool CExperiment::readColumnNames ( )

Reads the header row for the experiment data

Returns
bool success

Definition at line 1159 of file CExperiment.cpp.

References CLocaleString::fromUtf8(), CTableRow::getCells(), getFileName(), CCopasiParameterGroup::getName(), InvalidIndex, mColumnName, mpHeaderRow, mpNumColumns, mpSeparator, and skipLine().

Referenced by CQExperimentData::loadTable(), and CQExperimentData::slotSeparator().

1160 {
1161  mColumnName.resize(*mpNumColumns);
1162 
1163  if (*mpHeaderRow == InvalidIndex) return false;
1164 
1165  // Open the file
1166  std::ifstream in;
1167  in.open(CLocaleString::fromUtf8(getFileName()).c_str(), std::ios::binary);
1168 
1169  if (in.fail()) return false;
1170 
1171  // Forwind to header row.
1172  size_t i;
1173 
1174  for (i = 1; i < *mpHeaderRow && !in.fail(); i++)
1175  skipLine(in);
1176 
1177  // Read row
1178  CTableRow Row(*mpNumColumns, (*mpSeparator)[0]);
1179  const std::vector< CTableCell > & Cells = Row.getCells();
1180  in >> Row;
1181 
1182  if (in.fail() && !in.eof()) return false;
1183 
1184  for (i = 0; i < *mpNumColumns; i++)
1185  mColumnName[i] = Cells[i].getName();
1186 
1187  return true;
1188 }
const std::string & getFileName() const
std::vector< std::string > mColumnName
Definition: CExperiment.h:610
virtual const std::string & getName(const size_t &index) const
std::string * mpSeparator
Definition: CExperiment.h:585
std::istream & skipLine(std::istream &in)
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
#define InvalidIndex
Definition: CExperiment.cpp:38
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
static CLocaleString fromUtf8(const std::string &utf8)
bool CExperiment::restoreModelIndependentData ( )

Restore the model with the independent data from before the experiment

Returns
bool success

Definition at line 1227 of file CExperiment.cpp.

References mIndependentUpdateMethods, mIndependentValues, and CVectorCore< CType >::size().

Referenced by CFitProblem::calculate(), and CFitProblem::calculateCrossValidation().

1228 {
1229  size_t i, imax = mIndependentUpdateMethods.size();
1230 
1231  for (i = 0; i < imax; i++)
1233 
1234  return true;
1235 }
size_t size() const
Definition: CVector.h:100
CVector< C_FLOAT64 > mIndependentValues
Definition: CExperiment.h:656
CVector< UpdateMethod * > mIndependentUpdateMethods
Definition: CExperiment.h:650
bool CExperiment::setExperimentType ( const CCopasiTask::Type type)

set the experiment type

Parameters
constCCopasiTask::Type & experimentType
Returns
bool success

Definition at line 1240 of file CExperiment.cpp.

References mpTaskType, CCopasiTask::steadyState, and CCopasiTask::timeCourse.

Referenced by CQExperimentData::saveExperiment(), and CQExperimentData::slotExprimentType().

1241 {
1242  switch (type)
1243  {
1246  *mpTaskType = type;
1247  return true;
1248  break;
1249 
1250  default:
1251  break;
1252  }
1253 
1254  return false;
1255 }
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
bool CExperiment::setFileName ( const std::string &  fileName)

Set the file name

Parameters
conststd::string & fileName
Returns
bool success

Definition at line 1291 of file CExperiment.cpp.

References mpFileName.

Referenced by CQExperimentData::slotExperimentAdd().

1292 {
1293  *mpFileName = fileName;
1294  return true;
1295 }
std::string * mpFileName
Definition: CExperiment.h:560
bool CExperiment::setFirstRow ( const unsigned C_INT32 firstRow)

Set the first row containing data

Parameters
constunsigned C_INT32 & firstRow
Returns
bool success

Definition at line 1306 of file CExperiment.cpp.

References mpFirstRow, mpHeaderRow, and mpLastRow.

Referenced by CQExperimentData::saveExperiment(), CQExperimentData::slotExperimentAdd(), and CQExperimentDataValidator::validate().

1307 {
1308  if (first > *mpLastRow ||
1309  (first == *mpLastRow && first == *mpHeaderRow)) return false;
1310 
1311  *mpFirstRow = first;
1312  return true;
1313 }
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
bool CExperiment::setHeaderRow ( const unsigned C_INT32 headerRow)

Set the header row containing data

Parameters
constunsigned C_INT32 & headerRow
Returns
bool success

Definition at line 1330 of file CExperiment.cpp.

References mpFirstRow, mpHeaderRow, and mpLastRow.

Referenced by CQExperimentData::saveExperiment(), CQExperimentData::slotExperimentAdd(), and CQExperimentDataValidator::validate().

1331 {
1332  if (header == *mpFirstRow && header == *mpLastRow) return false;
1333 
1334  *mpHeaderRow = header;
1335  return true;
1336 }
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
bool CExperiment::setIsRowOriented ( const bool &  isRowOriented)

Set whether the data is row oriented. This only impacts reading the data from a stream

Parameters
constbool & isRowOriented
Returns
bool success

Definition at line 1380 of file CExperiment.cpp.

References isRowOriented(), and mpRowOriented.

1381 {
1383  return true;
1384 }
const bool & isRowOriented() const
bool * mpRowOriented
Definition: CExperiment.h:595
bool CExperiment::setLastRow ( const unsigned C_INT32 lastRow)

Set the last row containing data

Parameters
constunsigned C_INT32 & lastRow
Returns
bool success

Definition at line 1318 of file CExperiment.cpp.

References mpFirstRow, mpHeaderRow, and mpLastRow.

Referenced by CQExperimentData::saveExperiment(), CQExperimentData::slotExperimentAdd(), and CQExperimentDataValidator::validate().

1319 {
1320  if (*mpFirstRow > last ||
1321  (*mpFirstRow == last && last == *mpHeaderRow)) return false;
1322 
1323  *mpLastRow = last;
1324  return true;
1325 }
unsigned C_INT32 * mpFirstRow
Definition: CExperiment.h:565
unsigned C_INT32 * mpLastRow
Definition: CExperiment.h:570
unsigned C_INT32 * mpHeaderRow
Definition: CExperiment.h:600
void CExperiment::setNormalizeWeightsPerExperiment ( bool  flag)
bool CExperiment::setNumColumns ( const unsigned C_INT32 cols)

Set the number of columns in a stream

Parameters
constunsigned C_INT32 & cols
Returns
bool success

Definition at line 1341 of file CExperiment.cpp.

References mpNumColumns.

Referenced by CQExperimentData::slotExperimentAdd(), and CQExperimentData::slotSeparator().

1342 {
1343  *mpNumColumns = cols;
1344  return true;
1345 }
unsigned C_INT32 * mpNumColumns
Definition: CExperiment.h:605
bool CExperiment::setSeparator ( const std::string &  seperator)

Set the seperator used when reading a stream

Parameters
conststd::string & separator
Returns
bool success

Definition at line 1353 of file CExperiment.cpp.

References mpSeparator.

Referenced by CQExperimentData::saveExperiment(), and CQExperimentData::slotSeparator().

1354 {
1355  *mpSeparator = separator;
1356  return true;
1357 }
std::string * mpSeparator
Definition: CExperiment.h:585
bool CExperiment::setWeightMethod ( const WeightMethod weightMethod)

Set the weight calculation method and resets manual adjusted weights

Parameters
constWeightMethod & weightMethod
Returns
bool success

Definition at line 1362 of file CExperiment.cpp.

References mpObjectMap, mpWeightMethod, and CExperimentObjectMap::setScale().

Referenced by CQExperimentData::saveExperiment(), and CQExperimentData::slotWeightMethod().

1363 {
1364  if (*mpWeightMethod == weightMethod) return true;
1365 
1366  // Reset to default weights
1367  *mpWeightMethod = weightMethod;
1368  std::vector< CCopasiParameter * >::iterator it = mpObjectMap->CCopasiParameter::getValue().pGROUP->begin();
1369  std::vector< CCopasiParameter * >::iterator end = mpObjectMap->CCopasiParameter::getValue().pGROUP->end();
1370 
1371  for (; it != end; ++ it)
1372  static_cast< CExperimentObjectMap::CDataColumn * >(*it)->setScale(std::numeric_limits<C_FLOAT64>::quiet_NaN());
1373 
1374  return true;
1375 }
bool setScale(const size_t &index, const C_FLOAT64 &scale)
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
WeightMethod * mpWeightMethod
Definition: CExperiment.h:590
void CExperiment::storeExtendedTimeSeriesData ( C_FLOAT64  time)

Add one dataset to the extended time series. The time and the simulated dependent values are stored and the iterator is increased

Definition at line 576 of file CExperiment.cpp.

References CVectorCore< CType >::array(), C_FLOAT64, mDataDependent, mDependentValues, mRefreshMethods, mStorageIt, CMatrix< CType >::numCols(), and time.

Referenced by CFitProblem::calculate(), and CFitProblem::calculateCrossValidation().

577 {
578  //first store time
579  *mStorageIt = time; ++mStorageIt;
580 
581  //do all necessary refreshs
582  std::vector< Refresh * >::const_iterator it = mRefreshMethods.begin();
583  std::vector< Refresh * >::const_iterator end = mRefreshMethods.end();
584 
585  for (; it != end; ++it)
586  (**it)();
587 
588  //store the calculated data
589  C_FLOAT64 * const * ppDependentValues = mDependentValues.array();
590  size_t i, imax = mDataDependent.numCols();
591 
592  for (i = 0; i < imax; ++i, ++ppDependentValues, ++mStorageIt)
593  *mStorageIt = **ppDependentValues;
594 }
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 * > mDependentValues
Definition: CExperiment.h:648
C_FLOAT64 * mStorageIt
Definition: CExperiment.h:688
std::vector< Refresh * > mRefreshMethods
Definition: CExperiment.h:652
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
virtual size_t numCols() const
Definition: CMatrix.h:144
C_FLOAT64 CExperiment::sumOfSquares ( const size_t &  index,
C_FLOAT64 *&  residuals 
) const

Calculate the sum of squares for the indexed row of the experiment. If residuals is not NULL residuals will contain the differences between the calculated and the experiment values.

Parameters
constsize_t & index
C_FLOAT64*& residuals (may be NULL)
Returns
C_FLOAT64 sumOfSquares

Definition at line 426 of file CExperiment.cpp.

References CVectorCore< CType >::array(), C_FLOAT64, max, mDataDependent, mDependentValues, mMissingData, mRefreshMethods, mScale, and CMatrix< CType >::numCols().

Referenced by CFitProblem::calculate(), and CFitProblem::calculateCrossValidation().

428 {
429  C_FLOAT64 Residual;
430  C_FLOAT64 s = 0.0;
431 
432  C_FLOAT64 const * pDataDependent = mDataDependent[index];
433  C_FLOAT64 const * pEnd = pDataDependent + mDataDependent.numCols();
434  C_FLOAT64 * const * ppDependentValues = mDependentValues.array();
435  C_FLOAT64 const * pScale = mScale[index];
436 
437  std::vector< Refresh * >::const_iterator it = mRefreshMethods.begin();
438  std::vector< Refresh * >::const_iterator end = mRefreshMethods.end();
439 
440  for (; it != end; ++it)
441  (**it)();
442 
443  if (mMissingData)
444  {
445  if (residuals)
446  for (; pDataDependent != pEnd;
447  pDataDependent++, ppDependentValues++, pScale++, residuals++)
448  {
449  if (isnan(*pDataDependent))
450  {
451  // We ignore missing data, i.e., the residual is 0.
452  *residuals = 0.0;
453  continue;
454  }
455 
456 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
457  *residuals = (*pDataDependent - **ppDependentValues) / std::max(1.0, **ppDependentValues);
458 #else
459  *residuals = (*pDataDependent - **ppDependentValues) * *pScale;
460 #endif
461 
462  s += *residuals * *residuals;
463  }
464  else
465  for (; pDataDependent != pEnd;
466  pDataDependent++, ppDependentValues++, pScale++)
467  {
468  if (isnan(*pDataDependent)) continue;
469 
470 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
471  Residual = (*pDataDependent - **ppDependentValues) / std::max(1.0, **ppDependentValues);
472 #else
473  Residual = (*pDataDependent - **ppDependentValues) * *pScale;
474 #endif
475 
476  s += Residual * Residual;
477  }
478  }
479  else
480  {
481  if (residuals)
482  for (; pDataDependent != pEnd;
483  pDataDependent++, ppDependentValues++, pScale++, residuals++)
484  {
485 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
486  *residuals = (*pDataDependent - **ppDependentValues) / std::max(1.0, **ppDependentValues);
487 #else
488  *residuals = (*pDataDependent - **ppDependentValues) * *pScale;
489 #endif
490 
491  s += *residuals * *residuals;
492  }
493  else
494  for (; pDataDependent != pEnd;
495  pDataDependent++, ppDependentValues++, pScale++)
496  {
497 
498 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
499  Residual = (*pDataDependent - **ppDependentValues) / std::max(1.0, **ppDependentValues);
500 #else
501  Residual = (*pDataDependent - **ppDependentValues) * *pScale;
502 #endif
503 
504  s += Residual * Residual;
505  }
506  }
507 
508  return s;
509 }
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 * > mDependentValues
Definition: CExperiment.h:648
bool mMissingData
Definition: CExperiment.h:640
std::vector< Refresh * > mRefreshMethods
Definition: CExperiment.h:652
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
virtual size_t numCols() const
Definition: CMatrix.h:144
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
#define max(a, b)
Definition: f2c.h:176
C_FLOAT64 CExperiment::sumOfSquaresStore ( const size_t &  index,
C_FLOAT64 *&  dependentValues 
)

Calculate the sum of squares for the indexed row of the experiment. On return dependentValues contains the calculated values. If residuals is not NULL residuals will contain the differences between the calculated and the experiment values.

Parameters
constsize_t & index
C_FLOAT64*& dependentValues (must not be NULL)
Returns
C_FLOAT64 sumOfSquares

Definition at line 511 of file CExperiment.cpp.

References CVectorCore< CType >::array(), C_FLOAT64, max, mDataDependent, mDependentValues, mMissingData, mpDataDependentCalculated, mRefreshMethods, mScale, and CMatrix< CType >::numCols().

Referenced by CFitProblem::calculate(), and CFitProblem::calculateCrossValidation().

513 {
514  if (index == 0)
515  mpDataDependentCalculated = dependentValues;
516 
517  C_FLOAT64 Residual;
518  C_FLOAT64 s = 0.0;
519 
520  C_FLOAT64 const * pDataDependent = mDataDependent[index];
521  C_FLOAT64 const * pEnd = pDataDependent + mDataDependent.numCols();
522  C_FLOAT64 * const * ppDependentValues = mDependentValues.array();
523  C_FLOAT64 const * pScale = mScale[index];
524 
525  std::vector< Refresh * >::const_iterator it = mRefreshMethods.begin();
526  std::vector< Refresh * >::const_iterator end = mRefreshMethods.end();
527 
528  for (; it != end; ++it)
529  (**it)();
530 
531  if (mMissingData)
532  {
533  for (; pDataDependent != pEnd;
534  pDataDependent++, ppDependentValues++, pScale++, dependentValues++)
535  {
536  *dependentValues = **ppDependentValues;
537 
538  if (isnan(*pDataDependent)) continue;
539 
540 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
541  Residual = (*pDataDependent - *dependentValues) / std::max(1.0, *dependentValues);
542 #else
543  Residual = (*pDataDependent - *dependentValues) * *pScale;
544 #endif
545 
546  s += Residual * Residual;
547  }
548  }
549  else
550  {
551  for (; pDataDependent != pEnd;
552  pDataDependent++, ppDependentValues++, pScale++, dependentValues++)
553  {
554  *dependentValues = **ppDependentValues;
555 
556 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
557  Residual = (*pDataDependent - *dependentValues) / std::max(1.0, *dependentValues);
558 #else
559  Residual = (*pDataDependent - *dependentValues) * *pScale;
560 #endif
561 
562  s += Residual * Residual;
563  }
564  }
565 
566  return s;
567 }
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
CVector< C_FLOAT64 * > mDependentValues
Definition: CExperiment.h:648
bool mMissingData
Definition: CExperiment.h:640
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
std::vector< Refresh * > mRefreshMethods
Definition: CExperiment.h:652
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
virtual size_t numCols() const
Definition: CMatrix.h:144
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
#define max(a, b)
Definition: f2c.h:176
void CExperiment::updateFittedPoints ( )

This method needs to be called whenever the Object Map is changed

Definition at line 336 of file CExperiment.cpp.

References CCopasiVector< T >::add(), CCopasiVector< T >::clear(), dependent, CExperimentObjectMap::getObjectCN(), CExperimentObjectMap::getRole(), mFittingPoints, mpObjectMap, and CCopasiParameterGroup::size().

Referenced by elevateChildren(), and CQExperimentData::saveTable().

337 {
338  size_t i, imax = mpObjectMap->size();
339 
341  CFittingPoint * pPoint;
342 
343  for (i = 0; i < imax; i++)
344  if (mpObjectMap->getRole(i) == dependent)
345  {
346  pPoint = new CFittingPoint(mpObjectMap->getObjectCN(i));
347  mFittingPoints.add(pPoint, true);
348  }
349 }
CExperiment::Type getRole(const size_t &index) const
CCopasiVector< CFittingPoint > mFittingPoints
Definition: CExperiment.h:682
CExperimentObjectMap * mpObjectMap
Definition: CExperiment.h:615
virtual bool add(const CType &src)
virtual void clear()
std::string getObjectCN(const size_t &index) const
void CExperiment::updateFittedPointValues ( const size_t &  index,
bool  includeSimulation 
)

This method is used for output to fill the fitted points with the values of the index data record. If index exceedds the number of data records all values are set to NaN. If includeSimulation = false the entries for the simulation results are set to NaN. (This means the simulated time series is not plotted and can be output using a different mechanism)

Definition at line 351 of file CExperiment.cpp.

References CCopasiVector< T >::begin(), C_FLOAT64, CCopasiVector< T >::end(), mDataDependent, mDataTime, mFittingPoints, mNumDataRows, mpDataDependentCalculated, mpTaskType, mScale, CMatrix< CType >::numCols(), and CCopasiTask::timeCourse.

352 {
355 
356  if (index >= mNumDataRows ||
358  {
359  for (; it != end; ++it)
360  (*it)->setValues(std::numeric_limits<C_FLOAT64>::quiet_NaN(),
361  std::numeric_limits<C_FLOAT64>::quiet_NaN(),
362  std::numeric_limits<C_FLOAT64>::quiet_NaN(),
363  std::numeric_limits<C_FLOAT64>::quiet_NaN());
364 
365  return;
366  }
367 
368  C_FLOAT64 Independent;
369 
371  Independent = mDataTime[index];
372  else
373  Independent = (C_FLOAT64) index;
374 
375  C_FLOAT64 Residual;
376 
377  C_FLOAT64 * pDataDependentCalculated =
379  C_FLOAT64 * pDataDependent = mDataDependent[index];
380  C_FLOAT64 * pScale = mScale[index];
381 
382  for (; it != end; ++it, ++pScale, ++pDataDependentCalculated, ++pDataDependent)
383  {
384 #ifdef COPASI_PARAMETERFITTING_RESIDUAL_SCALING
385  Residual = (*pDataDependentCalculated - *pDataDependent) / (*pDataDependentCalculated > 1 ? *pDataDependentCalculated : 1.0);
386 #else
387  Residual = (*pDataDependentCalculated - *pDataDependent) * *pScale;
388 #endif
389 
390  (*it)->setValues(Independent,
391  *pDataDependent,
392  includeSimulation ? *pDataDependentCalculated : std::numeric_limits<C_FLOAT64>::quiet_NaN(),
393  Residual);
394  }
395 
396  return;
397 }
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
iterator begin()
size_t mNumDataRows
Definition: CExperiment.h:658
C_FLOAT64 * mpDataDependentCalculated
Definition: CExperiment.h:663
CCopasiVector< CFittingPoint > mFittingPoints
Definition: CExperiment.h:682
iterator end()
CCopasiTask::Type * mpTaskType
Definition: CExperiment.h:575
CVector< C_FLOAT64 > mDataTime
Definition: CExperiment.h:620
#define C_FLOAT64
Definition: copasi.h:92
virtual size_t numCols() const
Definition: CMatrix.h:144
CMatrix< C_FLOAT64 > mScale
Definition: CExperiment.h:635
void CExperiment::updateFittedPointValuesFromExtendedTimeSeries ( const size_t &  index)

Fill the fitted points with values from the extended time series

Definition at line 399 of file CExperiment.cpp.

References CCopasiVector< T >::begin(), CCopasiVector< T >::end(), extendedTimeSeriesSize(), mDataDependent, mExtendedTimeSeries, mFittingPoints, and CMatrix< CType >::numCols().

400 {
403 
404  if (index >= extendedTimeSeriesSize())
405  {
406  for (; it != end; ++it)
407  (*it)->setValues(std::numeric_limits<C_FLOAT64>::quiet_NaN(),
408  std::numeric_limits<C_FLOAT64>::quiet_NaN(),
409  std::numeric_limits<C_FLOAT64>::quiet_NaN(),
410  std::numeric_limits<C_FLOAT64>::quiet_NaN());
411 
412  return;
413  }
414 
415  size_t i;
416 
417  for (i = 1; it != end; ++it, ++i)
418  {
419  (*it)->setValues(mExtendedTimeSeries[index * (mDataDependent.numCols() + 1)],
420  std::numeric_limits<C_FLOAT64>::quiet_NaN(),
421  mExtendedTimeSeries[index * (mDataDependent.numCols() + 1) + i] ,
422  std::numeric_limits<C_FLOAT64>::quiet_NaN());
423  }
424 }
CMatrix< C_FLOAT64 > mDataDependent
Definition: CExperiment.h:630
iterator begin()
CCopasiVector< CFittingPoint > mFittingPoints
Definition: CExperiment.h:682
iterator end()
size_t extendedTimeSeriesSize() const
CVector< C_FLOAT64 > mExtendedTimeSeries
Definition: CExperiment.h:685
virtual size_t numCols() const
Definition: CMatrix.h:144
bool CExperiment::updateModelWithIndependentData ( const size_t &  index)

Update the model with the independent data of the experiment

Parameters
constsize_t & index
Returns
bool success

Definition at line 1217 of file CExperiment.cpp.

References mDataIndependent, mIndependentUpdateMethods, and CVectorCore< CType >::size().

Referenced by CFitProblem::calculate(), and CFitProblem::calculateCrossValidation().

1218 {
1219  size_t i, imax = mIndependentUpdateMethods.size();
1220 
1221  for (i = 0; i < imax; i++)
1223 
1224  return true;
1225 }
CMatrix< C_FLOAT64 > mDataIndependent
Definition: CExperiment.h:625
size_t size() const
Definition: CVector.h:100
CVector< UpdateMethod * > mIndependentUpdateMethods
Definition: CExperiment.h:650

Friends And Related Function Documentation

bool operator== ( const CExperiment lhs,
const CExperiment rhs 
)
friend

Comparison operator

Parameters
constCExperiment & lhs
constCExperiment & rhs
Returns
bool equal

Definition at line 1394 of file CExperiment.cpp.

1396 {
1397  std::string Key = *lhs.getValue("Key").pKEY;
1398  const_cast<CExperiment *>(&lhs)->setValue("Key", *rhs.getValue("Key").pKEY);
1399 
1400  bool Result =
1401  (*static_cast<const CCopasiParameterGroup *>(&lhs) ==
1402  *static_cast<const CCopasiParameterGroup *>(&rhs));
1403 
1404  const_cast<CExperiment *>(&lhs)->setValue("Key", Key);
1405 
1406  return Result;
1407 }
bool setValue(const std::string &name, const CType &value)
const CCopasiParameter::Value & getValue(const std::string &name) const

Member Data Documentation

std::vector< std::string > CExperiment::mColumnName
private

The column names if available after reading a file

Definition at line 610 of file CExperiment.h.

Referenced by getColumnNames(), read(), and readColumnNames().

CVector< C_FLOAT64 > CExperiment::mColumnObjectiveValue
private

Definition at line 673 of file CExperiment.h.

Referenced by calculateStatistics(), compile(), getObjectiveValue(), and printResult().

CVector< C_FLOAT64 > CExperiment::mColumnRMS
private

Definition at line 674 of file CExperiment.h.

Referenced by calculateStatistics(), compile(), getRMS(), and printResult().

CVector< C_FLOAT64 > CExperiment::mColumnScale
private

Definition at line 644 of file CExperiment.h.

Referenced by compile(), getErrorSum(), initializeScalingMatrix(), printResult(), and read().

CVector< size_t > CExperiment::mColumnValidValueCount
private
CMatrix< C_FLOAT64 > CExperiment::mDataDependent
private
CMatrix< C_FLOAT64 > CExperiment::mDataIndependent
private

The relevant independent experimental data after reading a file

Definition at line 625 of file CExperiment.h.

Referenced by compile(), getIndependentData(), read(), and updateModelWithIndependentData().

CVector< C_FLOAT64 > CExperiment::mDataTime
private

The vector of time points

Definition at line 620 of file CExperiment.h.

Referenced by getTimeData(), printResult(), read(), and updateFittedPointValues().

CVector< C_FLOAT64 > CExperiment::mDefaultColumnScale
private

Definition at line 646 of file CExperiment.h.

Referenced by calculateWeights(), getDefaultScale(), and read().

std::map< CCopasiObject *, size_t > CExperiment::mDependentObjects
private

A map of all dependent data objects to dependent data columns;

Definition at line 680 of file CExperiment.h.

Referenced by compile(), getColumnValidValueCount(), getDefaultScale(), getDependentObjects(), getErrorMeanSD(), getErrorSum(), getObjectiveValue(), and getRMS().

CVector< C_FLOAT64 * > CExperiment::mDependentValues
private
CVector< C_FLOAT64 > CExperiment::mExtendedTimeSeries
private
size_t CExperiment::mExtendedTimeSeriesSize
private

Definition at line 691 of file CExperiment.h.

Referenced by extendedTimeSeriesSize(), and initExtendedTimeSeries().

CCopasiVector< CFittingPoint > CExperiment::mFittingPoints
private
std::set< const CCopasiObject * > CExperiment::mIndependentObjects
private

Definition at line 654 of file CExperiment.h.

Referenced by compile(), and getIndependentObjects().

CVector< UpdateMethod * > CExperiment::mIndependentUpdateMethods
private
CVector< C_FLOAT64 > CExperiment::mIndependentValues
private

Definition at line 656 of file CExperiment.h.

Referenced by compile(), and restoreModelIndependentData().

C_FLOAT64 CExperiment::mMean
private

Definition at line 665 of file CExperiment.h.

Referenced by calculateStatistics(), compile(), getErrorMean(), and printResult().

CVector< C_FLOAT64 > CExperiment::mMeans
private

Definition at line 642 of file CExperiment.h.

Referenced by calculateWeights(), and read().

C_FLOAT64 CExperiment::mMeanSD
private

Definition at line 666 of file CExperiment.h.

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

bool CExperiment::mMissingData
private

Indicates whether we have missing data

Definition at line 640 of file CExperiment.h.

Referenced by calculateWeights(), sumOfSquares(), and sumOfSquaresStore().

size_t CExperiment::mNumDataRows
private
C_FLOAT64 CExperiment::mObjectiveValue
private

Definition at line 667 of file CExperiment.h.

Referenced by calculateStatistics(), compile(), getObjectiveValue(), and printResult().

C_FLOAT64* CExperiment::mpDataDependentCalculated
private

The relevant dependent experimental data after reading a file

Definition at line 663 of file CExperiment.h.

Referenced by calculateStatistics(), getErrorMeanSD(), getErrorSum(), printResult(), read(), sumOfSquaresStore(), and updateFittedPointValues().

std::string* CExperiment::mpFileName
private

This is realized as a CCopasiParameter type STRING

Definition at line 560 of file CExperiment.h.

Referenced by compare(), getFileName(), initializeParameter(), operator=(), read(), and setFileName().

unsigned C_INT32* CExperiment::mpFirstRow
private

This is realized as a CCopasiParameter type UINT

Definition at line 565 of file CExperiment.h.

Referenced by compare(), getFirstRow(), guessColumnNumber(), initializeParameter(), operator=(), read(), setFirstRow(), setHeaderRow(), and setLastRow().

unsigned C_INT32* CExperiment::mpHeaderRow
private

This is realized as a CCopasiParameter type UINT

Definition at line 600 of file CExperiment.h.

Referenced by getHeaderRow(), initializeParameter(), operator=(), read(), readColumnNames(), setFirstRow(), setHeaderRow(), and setLastRow().

unsigned C_INT32* CExperiment::mpLastRow
private

This is realized as a CCopasiParameter type UINT

Definition at line 570 of file CExperiment.h.

Referenced by getLastRow(), guessColumnNumber(), initializeParameter(), operator=(), read(), setFirstRow(), setHeaderRow(), and setLastRow().

bool* CExperiment::mpNormalizeWeightsPerExperiment
private

Indicates whether the weights of this experiment should be normalized to 1

Definition at line 580 of file CExperiment.h.

Referenced by calculateWeights(), getNormalizeWeightsPerExperiment(), initializeParameter(), operator=(), and setNormalizeWeightsPerExperiment().

unsigned C_INT32* CExperiment::mpNumColumns
private

This is realized as a CCopasiParameter type UINT

Definition at line 605 of file CExperiment.h.

Referenced by compile(), getNumColumns(), initializeParameter(), operator=(), read(), readColumnNames(), and setNumColumns().

CExperimentObjectMap* CExperiment::mpObjectMap
private

This is realized as a CCopasiParameter type GROUP

Definition at line 615 of file CExperiment.h.

Referenced by compile(), elevateChildren(), fixBuild55(), getObjectMap(), printResult(), read(), setWeightMethod(), and updateFittedPoints().

bool* CExperiment::mpRowOriented
private

This is realized as a CCopasiParameter type BOOL

Definition at line 595 of file CExperiment.h.

Referenced by initializeParameter(), isRowOriented(), operator=(), and setIsRowOriented().

std::string* CExperiment::mpSeparator
private

This is realized as a CCopasiParameter type STRING

Definition at line 585 of file CExperiment.h.

Referenced by getSeparator(), guessColumnNumber(), initializeParameter(), operator=(), read(), readColumnNames(), and setSeparator().

CCopasiTask::Type* CExperiment::mpTaskType
private
WeightMethod* CExperiment::mpWeightMethod
private
std::vector< Refresh * > CExperiment::mRefreshMethods
private
C_FLOAT64 CExperiment::mRMS
private

Definition at line 668 of file CExperiment.h.

Referenced by calculateStatistics(), compile(), getRMS(), and printResult().

CVector< C_FLOAT64 > CExperiment::mRowObjectiveValue
private

Definition at line 670 of file CExperiment.h.

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

CVector< C_FLOAT64 > CExperiment::mRowRMS
private

Definition at line 671 of file CExperiment.h.

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

CMatrix< C_FLOAT64 > CExperiment::mScale
private

The individual scale for each residual

Definition at line 635 of file CExperiment.h.

Referenced by calculateStatistics(), getErrorMeanSD(), initializeScalingMatrix(), printResult(), sumOfSquares(), sumOfSquaresStore(), and updateFittedPointValues().

C_FLOAT64* CExperiment::mStorageIt
private

Definition at line 688 of file CExperiment.h.

Referenced by CExperiment(), initExtendedTimeSeries(), and storeExtendedTimeSeriesData().

const std::string CExperiment::TypeName
static
Initial value:
=
{
"ignored",
"independent",
"dependent",
"Time",
""
}

String literals for the GUI to display type names of columns known to COPASI.

Definition at line 79 of file CExperiment.h.

Referenced by CQExperimentData::init(), CQExperimentData::loadTable(), CQExperimentData::saveTable(), and CQExperimentData::slotTypeChanged().

const std::string CExperiment::WeightMethodName
static
Initial value:
=
{
"Mean",
"Mean Square",
"Standard Deviation",
"Value Scaling",
""
}

String literals for the GUI to display weight method known to COPASI.

Definition at line 101 of file CExperiment.h.

Referenced by CQExperimentData::init().

const char * CExperiment::WeightMethodType
static
Initial value:
=
{
"Mean",
"MeanSquare",
"StandardDeviation",
"ValueScaling",
NULL
}

XML type names of weight methods known to COPASI.

Definition at line 106 of file CExperiment.h.

const char * CExperiment::XMLType
static
Initial value:
=
{
"ignored",
"independent",
"dependent",
"time",
NULL
}

XML type names of tasks known to COPASI.

Definition at line 84 of file CExperiment.h.


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