COPASI API  4.16.103
Public Member Functions | Private Attributes | Friends | List of all members
CMathTrigger::CRootFinder Class Reference

#include <CMathTrigger.h>

Inheritance diagram for CMathTrigger::CRootFinder:
Inheritance graph
[legend]
Collaboration diagram for CMathTrigger::CRootFinder:
Collaboration graph
[legend]

Public Member Functions

void applyInitialValues ()
 
void calculateTrueValue ()
 
bool compile (std::vector< CCopasiContainer * > listOfContainer)
 
 CRootFinder (const CCopasiContainer *pParent=NULL)
 
 CRootFinder (const CRootFinder &src, const CCopasiContainer *pParent=NULL)
 
void determineDiscrete (const std::set< const CCopasiObject * > &stateVariables)
 
C_FLOAT64getRootValuePtr ()
 
CEvaluationNodegetTrueExpression () const
 
void initObjects ()
 
const bool & isDiscrete () const
 
const bool & isEquality () const
 
bool isTrue () const
 
void toggle (const C_FLOAT64 &time, const bool &equality, const bool &continous)
 
void toggle (const C_FLOAT64 &time)
 
virtual ~CRootFinder ()
 
- 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 CObjectInterfacegetObject (const CCopasiObjectName &cn) 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 CCopasiObjectName getCN () const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
virtual const std::string & getKey () const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
virtual voidgetValuePointer () 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
 
virtual void print (std::ostream *ostream) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Private Attributes

bool mDiscrete
 
bool mEquality
 
C_FLOAT64 mLastToggleTime
 
C_FLOAT64mpRootValue
 
CExpression mRoot
 
C_FLOAT64 mTrue
 

Friends

class CMathTrigger
 

Additional Inherited Members

- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Protected Member Functions inherited from 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 CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 16 of file CMathTrigger.h.

Constructor & Destructor Documentation

CMathTrigger::CRootFinder::CRootFinder ( const CCopasiContainer pParent = NULL)

Default constructor

Parameters
constCCopasiContainer * pParent (default: NULL)

Definition at line 14 of file CMathTrigger.cpp.

References initObjects().

14  :
15  CCopasiContainer("Root", pParent),
16  mRoot("Expression", this),
17  mpRootValue(NULL),
18  mEquality(false),
19  mDiscrete(false),
20  mTrue(0.0),
21  mLastToggleTime(std::numeric_limits< C_FLOAT64 >::quiet_NaN())
22 {
23  initObjects();
24 }
CMathTrigger::CRootFinder::CRootFinder ( const CRootFinder src,
const CCopasiContainer pParent = NULL 
)

Copy constructor

Parameters
const CRoot &src
"constCCopasiContainer * pParent (default: NULL)

Definition at line 26 of file CMathTrigger.cpp.

References initObjects().

27  :
28  CCopasiContainer(src, pParent),
29  mRoot(src.mRoot, this),
30  mpRootValue(NULL),
31  mEquality(src.mEquality),
32  mDiscrete(src.mDiscrete),
33  mTrue(src.mTrue),
34  mLastToggleTime(src.mLastToggleTime)
35 {
36  initObjects();
37 }
CMathTrigger::CRootFinder::~CRootFinder ( )
virtual

Destructor

Definition at line 39 of file CMathTrigger.cpp.

40 {}

Member Function Documentation

void CMathTrigger::CRootFinder::applyInitialValues ( )

Initialize all values of the math model with their initial values.

Definition at line 141 of file CMathTrigger.cpp.

References CMathTrigger::calculateTrueValue().

142 {
144  mLastToggleTime = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
145 }
void CMathTrigger::CRootFinder::calculateTrueValue ( )

Determine the truth value for the initial conditions.

Definition at line 147 of file CMathTrigger.cpp.

Referenced by CMathModel::processRoots().

148 {
149  if ((*mpRootValue < 0.0) ||
150  ((*mpRootValue <= 0.0) && !mEquality))
151  {
152  mTrue = 0.0;
153  }
154  else
155  {
156  mTrue = 1.0;
157  }
158 }
bool CMathTrigger::CRootFinder::compile ( std::vector< CCopasiContainer * >  listOfContainer)

Compile the root finder

Parameters
std::vector<CCopasiContainer * > listOfContainer

Definition at line 51 of file CMathTrigger.cpp.

52 {
53  bool success = true;
54 
55  success &= mRoot.compile(listOfContainer);
56 
57  return true;
58 }
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
Definition: CExpression.cpp:97
void CMathTrigger::CRootFinder::determineDiscrete ( const std::set< const CCopasiObject * > &  stateVariables)

Determine whether the root only changes during discrete events. The root must be compiled before calling this method.

Parameters
conststd::set< const CCopasiObject *> & stateVariables

Definition at line 60 of file CMathTrigger.cpp.

61 {
62  mDiscrete = !mRoot.dependsOn(stateVariables);
63 }
bool dependsOn(DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
C_FLOAT64 * CMathTrigger::CRootFinder::getRootValuePtr ( )

Retrieve a pointer to the current value of the root.

Definition at line 160 of file CMathTrigger.cpp.

161 {
162  return mpRootValue;
163 }
CEvaluationNode * CMathTrigger::CRootFinder::getTrueExpression ( ) const

Retrieve the expression evaluating the truth value

Returns
CEvalutionNode * trueExpression

Definition at line 80 of file CMathTrigger.cpp.

References CCopasiNode< _Data >::addChild(), CEvaluationNodeNumber::DOUBLE, and CEvaluationNodeLogical::GT.

Referenced by CMathTrigger::compileGE(), CMathTrigger::compileGT(), CMathTrigger::compileLE(), and CMathTrigger::compileLT().

81 {
82  CEvaluationNode * pTrueExpression = NULL;
83 
84  pTrueExpression = new CEvaluationNodeLogical(CEvaluationNodeLogical::GT, "GT");
85  pTrueExpression->addChild(new CEvaluationNodeObject(&mTrue));
86  pTrueExpression->addChild(new CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, "0.5"));
87 
88  return pTrueExpression;
89 }
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
Definition: CCopasiNode.h:156
void CMathTrigger::CRootFinder::initObjects ( )

Initialize the contained object references.

Definition at line 42 of file CMathTrigger.cpp.

References CCopasiObject::addDirectDependency(), C_FLOAT64, CExpression::refresh(), and CCopasiObject::setRefresh().

Referenced by CRootFinder().

43 {
44  mpRootValue =
45  (C_FLOAT64 *)mRoot.getObject(std::string("Reference=Value"))->getValuePointer();
46 
49 }
void setRefresh(CType *pType, void(CType::*method)(void))
void addDirectDependency(const CCopasiObject *pObject)
#define C_FLOAT64
Definition: copasi.h:92
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
virtual void * getValuePointer() const =0
void refresh()
const bool & CMathTrigger::CRootFinder::isDiscrete ( ) const

Check whether the root change only during discrete events.

Returns
const bool & isDiscrete

Definition at line 65 of file CMathTrigger.cpp.

66 {
67  return mDiscrete;
68 }
const bool & CMathTrigger::CRootFinder::isEquality ( ) const

Check whether the root is checked for equality.

Returns
const bool & isEquality

Definition at line 70 of file CMathTrigger.cpp.

71 {
72  return mEquality;
73 }
bool CMathTrigger::CRootFinder::isTrue ( ) const

Check whether the root's current state is true .

Returns
bool isTrue

Definition at line 75 of file CMathTrigger.cpp.

76 {
77  return mTrue > 0.5;
78 }
void CMathTrigger::CRootFinder::toggle ( const C_FLOAT64 time,
const bool &  equality,
const bool &  continous 
)

Toggle the root status dependent on the processed equality status

Parameters
constC_FLOAT64 & time
constbool & equality
constbool & continuous

Definition at line 91 of file CMathTrigger.cpp.

94 {
95  // This function must only be called if we found a root, i.e., the
96  // value of the root expression changes sign. In that case it is save
97  // to toggle the activity.
98 
99  if (continous &&
100  !isnan(mLastToggleTime) &&
101  mLastToggleTime == time)
102  {
103  return;
104  }
105 
106  if (mDiscrete &&
107  equality == true)
108  {
109  mTrue = (mTrue > 0.5) ? 0.0 : 1.0;
110  mLastToggleTime = time;
111  }
112  else if (!mDiscrete)
113  {
114  if (equality == mEquality && mTrue < 0.5)
115  {
116  mTrue = 1.0;
117  mLastToggleTime = time;
118  }
119  else if (equality != mEquality && mTrue > 0.5)
120  {
121  mTrue = 0.0;
122  mLastToggleTime = time;
123  }
124  }
125 
126  return;
127 }
void CMathTrigger::CRootFinder::toggle ( const C_FLOAT64 time)

Toggle the root status dependent on the processed equality status

Parameters
constC_FLOAT64 & time

Definition at line 129 of file CMathTrigger.cpp.

130 {
131  // This function must only be called if we found a root, i.e., the
132  // value of the root expression changes sign. In that case it is save
133  // to toggle the activity.
134 
135  mTrue = (mTrue > 0.5) ? 0.0 : 1.0;
136  mLastToggleTime = time;
137 
138  return;
139 }

Friends And Related Function Documentation

friend class CMathTrigger
friend

Definition at line 18 of file CMathTrigger.h.

Member Data Documentation

bool CMathTrigger::CRootFinder::mDiscrete
private

This indicates whether the root changes only discretely

Definition at line 136 of file CMathTrigger.h.

bool CMathTrigger::CRootFinder::mEquality
private

This indicates whether the root is checked for equality

Definition at line 131 of file CMathTrigger.h.

Referenced by CMathTrigger::compileGE(), CMathTrigger::compileGT(), CMathTrigger::compileLE(), and CMathTrigger::compileLT().

C_FLOAT64 CMathTrigger::CRootFinder::mLastToggleTime
private

The time at which the last toggle of the truth value occurred

Definition at line 147 of file CMathTrigger.h.

C_FLOAT64* CMathTrigger::CRootFinder::mpRootValue
private

A pointer to the value of the root expression

Definition at line 126 of file CMathTrigger.h.

CExpression CMathTrigger::CRootFinder::mRoot
private

This expression calculates the root

Definition at line 121 of file CMathTrigger.h.

Referenced by CMathTrigger::compileGE(), CMathTrigger::compileGT(), CMathTrigger::compileLE(), and CMathTrigger::compileLT().

C_FLOAT64 CMathTrigger::CRootFinder::mTrue
private

Indicates the truth value of the root active This should be a bool but the CExpressionTree only handles double

Definition at line 142 of file CMathTrigger.h.


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