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

#include <CTrajectoryTask.h>

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

Public Member Functions

virtual CCopasiMethodcreateMethod (const int &type) const
 
 CTrajectoryTask (const CCopasiContainer *pParent=NULL)
 
 CTrajectoryTask (const CTrajectoryTask &src, const CCopasiContainer *pParent=NULL)
 
CStategetState ()
 
const CTimeSeriesgetTimeSeries () const
 
virtual bool initialize (const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
 
void load (CReadConfig &configBuffer)
 
virtual bool process (const bool &useInitialValues)
 
void processStart (const bool &useInitialValues)
 
bool processStep (const C_FLOAT64 &nextTime)
 
virtual bool restore ()
 
virtual bool setMethodType (const int &type)
 
 ~CTrajectoryTask ()
 
- Public Member Functions inherited from CCopasiTask
 CCopasiTask (const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const std::string &type="Task")
 
 CCopasiTask (const Type &taskType, const CCopasiContainer *pParent=NULL, const std::string &type="Task")
 
 CCopasiTask (const CCopasiTask &src, const CCopasiContainer *pParent=NULL)
 
void cleanup ()
 
CProcessReportgetCallBack () const
 
const CDescriptiongetDescription () const
 
virtual const std::string & getKey () const
 
CCopasiMethodgetMethod ()
 
const CCopasiMethodgetMethod () const
 
COutputHandlergetOutputHandler () const
 
const OutputFlaggetOutputMode () const
 
CCopasiProblemgetProblem ()
 
const CCopasiProblemgetProblem () const
 
CReportgetReport ()
 
const CResultgetResult () const
 
CCopasiParameterGroupgetSliders ()
 
Type getType () const
 
const bool & isScheduled () const
 
const bool & isUpdateModel () const
 
virtual void output (const COutputInterface::Activity &activity)
 
virtual void separate (const COutputInterface::Activity &activity)
 
virtual bool setCallBack (CProcessReport *pCallBack)
 
void setScheduled (const bool &scheduled)
 
void setType (const Type &type)
 
void setUpdateModel (const bool &updateModel)
 
virtual bool updateMatrices ()
 
virtual ~CCopasiTask ()
 
- 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
 
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 ()
 

Static Public Attributes

static const unsigned int ValidMethods []
 
- Static Public Attributes inherited from CCopasiTask
static const std::string TypeName []
 
static const unsigned int ValidMethods []
 
static const char * XMLType []
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 

Private Member Functions

void cleanup ()
 

Private Attributes

C_FLOAT64 mOutputStartTime
 
CStatempCurrentState
 
const C_FLOAT64mpCurrentTime
 
bool(* mpLess )(const C_FLOAT64 &, const C_FLOAT64 &)
 
bool(* mpLessOrEqual )(const C_FLOAT64 &, const C_FLOAT64 &)
 
CTrajectoryMethodmpTrajectoryMethod
 
CTrajectoryProblemmpTrajectoryProblem
 
CTimeSeries mTimeSeries
 
bool mTimeSeriesRequested
 
bool mUpdateMoieties
 

Additional Inherited Members

- Public Types inherited from CCopasiTask
enum  eOutputFlagBase {
  INITIALIZE = 0x01, STREAM = 0x02, FINISH = 0x04, REPORT = 0x10,
  PLOT = 0x20, TIME_SERIES = 0x40
}
 
enum  OutputFlag {
  NO_OUTPUT = 0, OUTPUT_BEFORE = INITIALIZE, OUTPUT_AFTER = FINISH, OUTPUT = REPORT | PLOT | STREAM,
  OUTPUT_SE = REPORT | PLOT | INITIALIZE | STREAM | FINISH, OUTPUT_UI = REPORT | PLOT | TIME_SERIES | INITIALIZE | STREAM | FINISH, ONLY_TIME_SERIES = TIME_SERIES | INITIALIZE | STREAM | FINISH
}
 
enum  Type {
  steadyState = 0, timeCourse, scan, fluxMode,
  optimization, parameterFitting, mca, lyap,
  tssAnalysis, sens, moieties, crosssection,
  lna, unset
}
 
- 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 CCopasiTask
static bool isValidMethod (const unsigned int &method, const unsigned int *validMethods)
 
- 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)
 
- Public Attributes inherited from CCopasiTask
std::string Error
 
std::string Warning
 
- 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 CCopasiTask
CDescription mDescription
 
OutputFlag mDoOutput
 
std::string mKey
 
unsigned C_INT32 mOutputCounter
 
CProcessReportmpCallBack
 
CStatempInitialState
 
CCopasiMethodmpMethod
 
COutputHandlermpOutputHandler
 
CCopasiProblemmpProblem
 
CCopasiParameterGroupmpSliders
 
CReport mReport
 
CResult mResult
 
bool mScheduled
 
Type mType
 
bool mUpdateModel
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 37 of file CTrajectoryTask.h.

Constructor & Destructor Documentation

CTrajectoryTask::CTrajectoryTask ( const CCopasiContainer pParent = NULL)

Default constructor

Parameters
constCCopasiContainer * pParent (default: NULL)

Definition at line 73 of file CTrajectoryTask.cpp.

References CCopasiContainer::add(), createMethod(), CCopasiMethod::deterministic, CCopasiParameterGroup::getParameter(), CCopasiParameter::getValue(), CCopasiTask::mpMethod, CCopasiTask::mpProblem, mUpdateMoieties, and CCopasiParameter::Value::pBOOL.

73  :
76  mTimeSeries(),
77  mpTrajectoryProblem(NULL),
78  mpTrajectoryMethod(NULL),
79  mUpdateMoieties(false),
80  mpCurrentState(NULL),
81  mpCurrentTime(NULL),
82  mOutputStartTime(0.0),
84  mpLess(&fl)
85 {
86  mpProblem = new CTrajectoryProblem(this);
88  this->add(mpMethod, true);
89 
90  CCopasiParameter * pParameter = mpMethod->getParameter("Integrate Reduced Model");
91 
92  if (pParameter != NULL)
93  mUpdateMoieties = *pParameter->getValue().pBOOL;
94  else
95  mUpdateMoieties = false;
96 }
CCopasiMethod * mpMethod
Definition: CCopasiTask.h:239
CTimeSeries mTimeSeries
CCopasiTask(const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const std::string &type="Task")
CTrajectoryProblem * mpTrajectoryProblem
CState * mpCurrentState
const C_FLOAT64 * mpCurrentTime
CCopasiProblem * mpProblem
Definition: CCopasiTask.h:234
bool fle(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
C_FLOAT64 mOutputStartTime
bool(* mpLessOrEqual)(const C_FLOAT64 &, const C_FLOAT64 &)
const Value & getValue() const
CCopasiParameter * getParameter(const std::string &name)
bool(* mpLess)(const C_FLOAT64 &, const C_FLOAT64 &)
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
virtual CCopasiMethod * createMethod(const int &type) const
CTrajectoryMethod * mpTrajectoryMethod
CTrajectoryTask::CTrajectoryTask ( const CTrajectoryTask src,
const CCopasiContainer pParent = NULL 
)

Copy constructor

Parameters
constCTrajectoryTask & src
constCCopasiContainer * pParent (default: NULL)

Definition at line 98 of file CTrajectoryTask.cpp.

References CCopasiContainer::add(), createMethod(), CCopasiParameterGroup::elevateChildren(), CCopasiMethod::getSubType(), CCopasiParameter::getValue(), CCopasiTask::mpMethod, CCopasiTask::mpProblem, mUpdateMoieties, and CCopasiParameter::Value::pBOOL.

99  :
100  CCopasiTask(src, pParent),
102  mTimeSeries(),
103  mpTrajectoryProblem(NULL),
104  mpTrajectoryMethod(NULL),
105  mUpdateMoieties(false),
106  mpCurrentState(NULL),
107  mpCurrentTime(NULL),
108  mOutputStartTime(0.0),
110  mpLess(src.mpLess)
111 {
112  mpProblem =
113  new CTrajectoryProblem(*static_cast< CTrajectoryProblem * >(src.mpProblem), this);
114 
116  * mpMethod = * src.mpMethod;
117 
118  mpMethod->elevateChildren();
119 
120  this->add(mpMethod, true);
121 
122  CCopasiParameter * pParameter = mpMethod->getParameter("Integrate Reduced Model");
123 
124  if (pParameter != NULL)
125  mUpdateMoieties = *pParameter->getValue().pBOOL;
126  else
127  mUpdateMoieties = false;
128 }
CCopasiMethod * mpMethod
Definition: CCopasiTask.h:239
CTimeSeries mTimeSeries
CCopasiTask(const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const std::string &type="Task")
CTrajectoryProblem * mpTrajectoryProblem
CState * mpCurrentState
const CCopasiMethod::SubType & getSubType() const
const C_FLOAT64 * mpCurrentTime
CCopasiProblem * mpProblem
Definition: CCopasiTask.h:234
C_FLOAT64 mOutputStartTime
bool(* mpLessOrEqual)(const C_FLOAT64 &, const C_FLOAT64 &)
const Value & getValue() const
bool(* mpLess)(const C_FLOAT64 &, const C_FLOAT64 &)
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
virtual CCopasiMethod * createMethod(const int &type) const
CTrajectoryMethod * mpTrajectoryMethod
CTrajectoryTask::~CTrajectoryTask ( )

Destructor

Definition at line 130 of file CTrajectoryTask.cpp.

References cleanup().

131 {
132  cleanup();
133 }

Member Function Documentation

void CTrajectoryTask::cleanup ( )
private

cleanup()

Definition at line 135 of file CTrajectoryTask.cpp.

References mpCurrentState, and pdelete.

Referenced by ~CTrajectoryTask().

136 {
138 }
#define pdelete(p)
Definition: copasi.h:215
CState * mpCurrentState
CCopasiMethod * CTrajectoryTask::createMethod ( const int &  type) const
virtual

Create a method of the specified type to solve the task. It is the duty of the caller to release the CCopasiMethod.

Parameters
constCCopasiMethod::SubType & type
Returns
CCopasiMethod *

Reimplemented from CCopasiTask.

Definition at line 537 of file CTrajectoryTask.cpp.

References CTrajectoryMethod::createMethod().

Referenced by CTrajectoryTask(), and setMethodType().

538 {
540 
541  return CTrajectoryMethod::createMethod(Type);
542 }
static CTrajectoryMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::deterministic)
CState * CTrajectoryTask::getState ( )

Retrieves a pointer to current state of the integration.

Returns
CState * pState

Definition at line 544 of file CTrajectoryTask.cpp.

References mpCurrentState.

Referenced by CNewtonMethod::doIntegration().

545 {return mpCurrentState;}
CState * mpCurrentState
const CTimeSeries & CTrajectoryTask::getTimeSeries ( ) const

gets a reference to the time series

Returns
time series

Definition at line 547 of file CTrajectoryTask.cpp.

References mTimeSeries.

Referenced by CQGLNetworkPainter::createDataSets(), QTimeCourseAnimation::getScales(), getTimeSeriesFromTask(), and QTimeCourseAnimation::initialize().

548 {return mTimeSeries;}
CTimeSeries mTimeSeries
bool CTrajectoryTask::initialize ( const OutputFlag of,
COutputHandler pOutputHandler,
std::ostream *  pOstream 
)
virtual

Initialize the task. If an ostream is given this ostream is used instead of the target specified in the report. This allows nested tasks to share the same output device.

Parameters
constOutputFlag & of
COutputHandler* pOutputHandler
std::ostream* pOstream (default: NULL)
Returns
bool success

Reimplemented from CCopasiTask.

Definition at line 161 of file CTrajectoryTask.cpp.

References COutputHandler::addInterface(), CTimeSeries::allocate(), CTimeSeries::clear(), CTrajectoryProblem::getContinueSimultaneousEvents(), CModel::getMathModel(), CCopasiProblem::getModel(), CCopasiParameterGroup::getParameter(), CMathModel::getProcessQueue(), CModel::getState(), CTrajectoryProblem::getStepNumber(), CState::getTime(), CCopasiParameter::getValue(), CCopasiTask::initialize(), CCopasiMethod::isValidProblem(), mpCurrentState, mpCurrentTime, CCopasiTask::mpMethod, CCopasiTask::mpProblem, mpTrajectoryMethod, mpTrajectoryProblem, mTimeSeries, mTimeSeriesRequested, mUpdateMoieties, CCopasiParameter::Value::pBOOL, pdelete, CProcessQueue::setContinueSimultaneousEvents(), CTrajectoryMethod::setProblem(), CCopasiTask::TIME_SERIES, and CTrajectoryProblem::timeSeriesRequested().

Referenced by CFitProblem::initialize(), CNewtonMethod::initialize(), and test000087::test_simulate_reaction_flux_reference_1().

164 {
165  assert(mpProblem && mpMethod);
166 
168  assert(mpTrajectoryProblem);
169 
170  mpTrajectoryMethod = dynamic_cast<CTrajectoryMethod *>(mpMethod);
171  assert(mpTrajectoryMethod);
172 
174 
175  bool success = mpMethod->isValidProblem(mpProblem);
176 
177  CCopasiParameter * pParameter = mpMethod->getParameter("Integrate Reduced Model");
178 
179  if (pParameter != NULL)
180  mUpdateMoieties = *pParameter->getValue().pBOOL;
181  else
182  mUpdateMoieties = false;
183 
187 
188  //mpOutputStartTime = & mpTrajectoryProblem->getOutputStartTime();
189 
190  // Handle the time series as a regular output.
192 
193  if ((pOutputHandler != NULL) &&
196  {
198  pOutputHandler->addInterface(&mTimeSeries);
199  }
200  else
201  {
202  mTimeSeries.clear();
203  }
204 
206 
207  if (!CCopasiTask::initialize(of, pOutputHandler, pOstream)) success = false;
208 
209  return success;
210 }
CCopasiMethod * mpMethod
Definition: CCopasiTask.h:239
#define pdelete(p)
Definition: copasi.h:215
CTimeSeries mTimeSeries
void clear()
Definition: CTimeSeries.cpp:96
void setProblem(CTrajectoryProblem *problem)
virtual bool initialize(const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
const unsigned C_INT32 & getStepNumber() const
CTrajectoryProblem * mpTrajectoryProblem
void allocate(const size_t &steps)
Definition: CTimeSeries.cpp:73
Definition: CState.h:305
const CMathModel * getMathModel() const
Definition: CModel.cpp:4722
CState * mpCurrentState
virtual bool isValidProblem(const CCopasiProblem *pProblem)
const C_FLOAT64 * mpCurrentTime
CCopasiProblem * mpProblem
Definition: CCopasiTask.h:234
virtual void addInterface(COutputInterface *pInterface)
void setContinueSimultaneousEvents(const bool &continueSimultaneousEvents)
const Value & getValue() const
CCopasiParameter * getParameter(const std::string &name)
const C_FLOAT64 & getTime() const
Definition: CState.cpp:325
bool timeSeriesRequested() const
const CState & getState() const
Definition: CModel.cpp:1771
const CProcessQueue & getProcessQueue() const
Definition: CMathModel.cpp:362
const bool & getContinueSimultaneousEvents() const
CTrajectoryMethod * mpTrajectoryMethod
CModel * getModel() const
void CTrajectoryTask::load ( CReadConfig configBuffer)

Loads parameters for this solver with data coming from a CReadConfig object. (CReadConfig object reads an input stream)

Parameters
configbufferreference to a CReadConfig object.

Definition at line 140 of file CTrajectoryTask.cpp.

References CCopasiContainer::add(), CTrajectoryMethod::createMethod(), CCopasiParameterGroup::getParameter(), CCopasiParameter::getValue(), CReadConfig::getVariable(), CReadConfig::LOOP, CCopasiTask::mpMethod, CCopasiTask::mpProblem, CCopasiTask::mScheduled, mUpdateMoieties, CCopasiParameter::Value::pBOOL, and pdelete.

Referenced by CCopasiDataModel::loadModel().

141 {
142  configBuffer.getVariable("Dynamics", "bool", &mScheduled,
144 
146  mpProblem = new CTrajectoryProblem(this);
147  ((CTrajectoryProblem *) mpProblem)->load(configBuffer);
148 
149  pdelete(mpMethod);
151  this->add(mpMethod, true);
152 
153  CCopasiParameter * pParameter = mpMethod->getParameter("Integrate Reduced Model");
154 
155  if (pParameter != NULL)
156  mUpdateMoieties = *pParameter->getValue().pBOOL;
157 
159 }
CCopasiMethod * mpMethod
Definition: CCopasiTask.h:239
#define pdelete(p)
Definition: copasi.h:215
bool mScheduled
Definition: CCopasiTask.h:217
CCopasiProblem * mpProblem
Definition: CCopasiTask.h:234
const Value & getValue() const
CCopasiParameter * getParameter(const std::string &name)
static CTrajectoryMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::deterministic)
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
C_INT32 getVariable(const std::string &name, const std::string &type, void *pout, CReadConfig::Mode mode=CReadConfig::NEXT)
Definition: CReadConfig.cpp:81
bool CTrajectoryTask::process ( const bool &  useInitialValues)
virtual

Process the task with or without initializing to the initial state.

Parameters
constbool & useInitialValues
Returns
bool success

Reimplemented from CCopasiTask.

Definition at line 212 of file CTrajectoryTask.cpp.

References CProcessReport::addItem(), COutputInterface::AFTER, COutputInterface::BEFORE, bl(), ble(), C_FLOAT64, C_INT32, COutputInterface::DURING, CCopasiMessage::ERROR, CCopasiMessage::EXCEPTION, CProcessReport::finishItem(), fl(), fle(), CTrajectoryProblem::getDuration(), CCopasiException::getMessage(), CCopasiProblem::getModel(), CTrajectoryProblem::getOutputStartTime(), CTrajectoryProblem::getStepSize(), MCTrajectoryMethod, MCTrajectoryProblem, min, mOutputStartTime, CCopasiTask::mpCallBack, mpCurrentState, mpCurrentTime, mpLess, mpLessOrEqual, mpTrajectoryProblem, mUpdateMoieties, CCopasiTask::output(), processStart(), processStep(), CProcessReport::progressItem(), CProcessReport::setName(), CModel::setState(), and CModel::updateSimulatedValues().

Referenced by CNewtonMethod::doIntegration(), and test000087::test_simulate_reaction_flux_reference_1().

213 {
214  //*****
215 
216  processStart(useInitialValues);
217 
218  //*****
219 
220  //size_t FailCounter = 0;
221 
224  C_FLOAT64 StepNumber = fabs(Duration) / StepSize;
225 
226  if (isnan(StepNumber) || StepNumber < 1.0)
227  StepNumber = 1.0;
228 
229  //the output starts only after "outputStartTime" has passed
230  if (useInitialValues)
232  else
234 
235  C_FLOAT64 NextTimeToReport;
236 
237  const C_FLOAT64 EndTime = *mpCurrentTime + Duration;
238  const C_FLOAT64 StartTime = *mpCurrentTime;
239  C_FLOAT64 CompareEndTime;
240 
241  if (StepSize < 0.0)
242  {
243  mpLessOrEqual = &ble;
244  mpLess = &bl;
245 
246  // It suffices to reach the end time within machine precision
247  CompareEndTime = EndTime + 100.0 * (fabs(EndTime) * std::numeric_limits< C_FLOAT64 >::epsilon() + std::numeric_limits< C_FLOAT64 >::min());
248  }
249  else
250  {
251  mpLessOrEqual = &fle;
252  mpLess = &fl;
253 
254  // It suffices to reach the end time within machine precision
255  CompareEndTime = EndTime - 100.0 * (fabs(EndTime) * std::numeric_limits< C_FLOAT64 >::epsilon() + std::numeric_limits< C_FLOAT64 >::min());
256  }
257 
258  unsigned C_INT32 StepCounter = 1;
259 
260  if (StepSize == 0.0 && Duration != 0.0)
261  {
263  return false;
264  }
265 
267 
268  bool flagProceed = true;
269  C_FLOAT64 handlerFactor = 100.0 / Duration;
270 
271  C_FLOAT64 Percentage = 0;
272  size_t hProcess;
273 
274  if (mpCallBack != NULL && StepNumber > 1.0)
275  {
276  mpCallBack->setName("performing simulation...");
277  C_FLOAT64 hundred = 100;
278  hProcess = mpCallBack->addItem("Completion",
279  Percentage,
280  &hundred);
281  }
282 
284 
285  try
286  {
287  do
288  {
289  // This is numerically more stable then adding
290  // mpTrajectoryProblem->getStepSize().
291  NextTimeToReport =
292  StartTime + (EndTime - StartTime) * StepCounter++ / StepNumber;
293 
294  flagProceed &= processStep(NextTimeToReport);
295 
296  if (mpCallBack != NULL && StepNumber > 1.0)
297  {
298  Percentage = (*mpCurrentTime - StartTime) * handlerFactor;
299  flagProceed &= mpCallBack->progressItem(hProcess);
300  }
301 
303  {
305  }
306  }
307  while ((*mpLess)(*mpCurrentTime, CompareEndTime) && flagProceed);
308  }
309 
310  catch (int)
311  {
314 
316  {
318  }
319 
320  if (mpCallBack != NULL && StepNumber > 1.0) mpCallBack->finishItem(hProcess);
321 
323 
325  }
326 
327  catch (CCopasiException & Exception)
328  {
331 
333  {
335  }
336 
337  if (mpCallBack != NULL && StepNumber > 1.0) mpCallBack->finishItem(hProcess);
338 
340 
341  throw CCopasiException(Exception.getMessage());
342  }
343 
344  if (mpCallBack != NULL && StepNumber > 1.0) mpCallBack->finishItem(hProcess);
345 
347 
348  return true;
349 }
const CCopasiMessage & getMessage() const
virtual bool setName(const std::string &name)
bool processStep(const C_FLOAT64 &nextTime)
void updateSimulatedValues(const bool &updateMoieties)
Definition: CModel.cpp:1851
CProcessReport * mpCallBack
Definition: CCopasiTask.h:249
CTrajectoryProblem * mpTrajectoryProblem
virtual void output(const COutputInterface::Activity &activity)
CState * mpCurrentState
#define C_INT32
Definition: copasi.h:90
void processStart(const bool &useInitialValues)
virtual bool progressItem(const size_t &handle)
const C_FLOAT64 * mpCurrentTime
#define MCTrajectoryMethod
const C_FLOAT64 & getStepSize() const
bool fle(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
#define MCTrajectoryProblem
bool ble(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
void setState(const CState &state)
Definition: CModel.cpp:1785
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
const C_FLOAT64 & getDuration() const
C_FLOAT64 mOutputStartTime
bool(* mpLessOrEqual)(const C_FLOAT64 &, const C_FLOAT64 &)
virtual bool finishItem(const size_t &handle)
bool(* mpLess)(const C_FLOAT64 &, const C_FLOAT64 &)
const C_FLOAT64 & getOutputStartTime() const
#define C_FLOAT64
Definition: copasi.h:92
bool bl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CModel * getModel() const
#define min(a, b)
Definition: f2c.h:175
void CTrajectoryTask::processStart ( const bool &  useInitialValues)

Starts the process of integration by calling CTrajectoryMethod::start

Parameters
constbool & useInitialValues

Definition at line 351 of file CTrajectoryTask.cpp.

References CModel::applyInitialValues(), CCopasiProblem::getModel(), CModel::getState(), mpCurrentState, mpTrajectoryMethod, mpTrajectoryProblem, CTrajectoryMethod::setCurrentState(), and CTrajectoryMethod::start().

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

352 {
353  if (useInitialValues)
355 
357 
360 
361  return;
362 }
CTrajectoryProblem * mpTrajectoryProblem
void setCurrentState(CState *currentState)
CState * mpCurrentState
void applyInitialValues()
Definition: CModel.cpp:1236
virtual void start(const CState *initialState)
const CState & getState() const
Definition: CModel.cpp:1771
CTrajectoryMethod * mpTrajectoryMethod
CModel * getModel() const
bool CTrajectoryTask::processStep ( const C_FLOAT64 nextTime)

Integrates one step

Parameters
constC_FLOAT64 & nextTime
Returns
bool success;

Definition at line 364 of file CTrajectoryTask.cpp.

References C_FLOAT64, COutputInterface::DURING, CCopasiMessage::EXCEPTION, CTrajectoryMethod::FAILURE, CCopasiProblem::getModel(), CTrajectoryProblem::getOutputEvent(), CModel::getProcessQueueExecutionTime(), CTrajectoryMethod::getRoots(), CModel::getState(), MCTrajectoryMethod, min, mOutputStartTime, CCopasiTask::mpCallBack, mpCurrentState, mpCurrentTime, mpLessOrEqual, mpTrajectoryMethod, mpTrajectoryProblem, mUpdateMoieties, CTrajectoryMethod::NORMAL, CCopasiTask::output(), CProcessReport::proceed(), CModel::processQueue(), CModel::processRoots(), CTrajectoryMethod::ROOT, CModel::setState(), CTrajectoryMethod::stateChanged(), CTrajectoryMethod::step(), and CModel::updateSimulatedValues().

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

365 {
366  CModel * pModel = mpTrajectoryProblem->getModel();
367  bool StateChanged = false;
368  bool proceed = true;
369 
370  C_FLOAT64 Tolerance = 100.0 * (fabs(endTime) * std::numeric_limits< C_FLOAT64 >::epsilon() + std::numeric_limits< C_FLOAT64 >::min());
371  C_FLOAT64 NextTime = endTime;
372 
373  while (proceed)
374  {
375  // TODO Provide a call back method for resolving simultaneous assignments.
376  StateChanged = pModel->processQueue(*mpCurrentTime, false, NULL);
377 
378  if (StateChanged)
379  {
382  {
384  }
385 
386  *mpCurrentState = pModel->getState();
388  StateChanged = false;
389  }
390 
391  // std::min suffices since events are only supported in forward integration.
392  NextTime = std::min(endTime, pModel->getProcessQueueExecutionTime());
393 
394  switch (mpTrajectoryMethod->step(NextTime - *mpCurrentTime))
395  {
397  pModel->setState(*mpCurrentState);
399 
403  {
405  }
406 
407  // TODO Provide a call back method for resolving simultaneous assignments.
408  StateChanged = pModel->processQueue(*mpCurrentTime, true, NULL);
409 
410  if (fabs(*mpCurrentTime - endTime) < Tolerance)
411  {
412  if (StateChanged)
413  {
414  *mpCurrentState = pModel->getState();
416  StateChanged = false;
417  }
418 
419  return true;
420  }
421 
422  if (StateChanged)
423  {
426  {
428  }
429 
430  *mpCurrentState = pModel->getState();
432  StateChanged = false;
433  }
434 
435  break;
436 
438  pModel->setState(*mpCurrentState);
440 
441  pModel->processRoots(*mpCurrentTime, true, true, mpTrajectoryMethod->getRoots());
442 
446  {
448  }
449 
450  // TODO Provide a call back method for resolving simultaneous assignments.
451  StateChanged = pModel->processQueue(*mpCurrentTime, true, NULL);
452 
453  pModel->processRoots(*mpCurrentTime, false, true, mpTrajectoryMethod->getRoots());
454 
455  // If the root happens to coincide with end of the step we have to return
456  if (fabs(*mpCurrentTime - endTime) < Tolerance)
457  {
458  if (StateChanged)
459  {
460  *mpCurrentState = pModel->getState();
462  StateChanged = false;
463  }
464 
465  return true;
466  }
467 
469  (StateChanged || *mpCurrentTime == pModel->getProcessQueueExecutionTime()) &&
471  {
473  }
474 
475  if (StateChanged)
476  {
477  *mpCurrentState = pModel->getState();
479  StateChanged = false;
480  }
481 
482  break;
483 
486 
487  return false;
488  break;
489  }
490 
491  proceed = mpCallBack == NULL || mpCallBack->proceed();
492  }
493 
494  return proceed;
495 }
virtual void stateChanged()
void updateSimulatedValues(const bool &updateMoieties)
Definition: CModel.cpp:1851
CProcessReport * mpCallBack
Definition: CCopasiTask.h:249
CTrajectoryProblem * mpTrajectoryProblem
virtual void output(const COutputInterface::Activity &activity)
CState * mpCurrentState
const C_FLOAT64 * mpCurrentTime
const CVector< C_INT > & getRoots() const
virtual bool proceed()
#define MCTrajectoryMethod
void setState(const CState &state)
Definition: CModel.cpp:1785
C_FLOAT64 mOutputStartTime
void processRoots(const C_FLOAT64 &time, const bool &equality, const bool &correct, const CVector< C_INT > &roots)
Definition: CModel.cpp:4692
bool(* mpLessOrEqual)(const C_FLOAT64 &, const C_FLOAT64 &)
bool processQueue(const C_FLOAT64 &time, const bool &equality, CProcessQueue::resolveSimultaneousAssignments pResolveSimultaneousAssignments)
Definition: CModel.cpp:4685
#define C_FLOAT64
Definition: copasi.h:92
const C_FLOAT64 & getProcessQueueExecutionTime() const
Definition: CModel.cpp:4702
Definition: CModel.h:50
const CState & getState() const
Definition: CModel.cpp:1771
virtual Status step(const double &deltaT)
CTrajectoryMethod * mpTrajectoryMethod
CModel * getModel() const
#define min(a, b)
Definition: f2c.h:175
const bool & getOutputEvent() const
bool CTrajectoryTask::restore ( )
virtual

Perform necessary cleanup procedures

Reimplemented from CCopasiTask.

Definition at line 497 of file CTrajectoryTask.cpp.

References CCopasiProblem::getModel(), CModel::getState(), mpCurrentState, CCopasiTask::mpProblem, CCopasiTask::mUpdateModel, mUpdateMoieties, CCopasiTask::restore(), CModel::setInitialState(), CModel::setState(), CModel::updateInitialValues(), and CModel::updateSimulatedValues().

Referenced by CFitProblem::restore(), and test000087::test_simulate_reaction_flux_reference_1().

498 {
499  bool success = CCopasiTask::restore();
500 
501  if (mUpdateModel)
502  {
503  CModel * pModel = mpProblem->getModel();
504 
505  pModel->setState(*mpCurrentState);
507  pModel->setInitialState(pModel->getState());
508  pModel->updateInitialValues();
509  }
510 
511  return success;
512 }
void setInitialState(const CState &state)
Definition: CModel.cpp:1774
void updateSimulatedValues(const bool &updateMoieties)
Definition: CModel.cpp:1851
CState * mpCurrentState
CCopasiProblem * mpProblem
Definition: CCopasiTask.h:234
void setState(const CState &state)
Definition: CModel.cpp:1785
bool mUpdateModel
Definition: CCopasiTask.h:223
bool updateInitialValues()
Definition: CModel.cpp:1461
Definition: CModel.h:50
const CState & getState() const
Definition: CModel.cpp:1771
virtual bool restore()
CModel * getModel() const
bool CTrajectoryTask::setMethodType ( const int &  type)
virtual

Set the method type applied to solve the task

Parameters
constCCopasiMethod::SubType & type
Returns
bool success

Reimplemented from CCopasiTask.

Definition at line 514 of file CTrajectoryTask.cpp.

References CCopasiContainer::add(), createMethod(), CCopasiParameterGroup::getParameter(), CCopasiMethod::getSubType(), CCopasiParameter::getValue(), CCopasiTask::isValidMethod(), CCopasiTask::mpMethod, mUpdateMoieties, CCopasiParameter::Value::pBOOL, pdelete, and ValidMethods.

Referenced by CNewtonMethod::initialize(), test000087::test_simulate_reaction_flux_reference_1(), and SEDMLImporter::updateCopasiTaskForSimulation().

515 {
517 
518  if (!isValidMethod(Type, ValidMethods)) return false;
519 
520  if (mpMethod->getSubType() == Type) return true;
521 
522  pdelete(mpMethod);
523  mpMethod = createMethod(Type);
524  this->add(mpMethod, true);
525 
526  CCopasiParameter * pParameter = mpMethod->getParameter("Integrate Reduced Model");
527 
528  if (pParameter != NULL)
529  mUpdateMoieties = *pParameter->getValue().pBOOL;
530  else
531  mUpdateMoieties = false;
532 
533  return true;
534 }
CCopasiMethod * mpMethod
Definition: CCopasiTask.h:239
#define pdelete(p)
Definition: copasi.h:215
static const unsigned int ValidMethods[]
const CCopasiMethod::SubType & getSubType() const
const Value & getValue() const
CCopasiParameter * getParameter(const std::string &name)
static bool isValidMethod(const unsigned int &method, const unsigned int *validMethods)
Definition: CCopasiTask.cpp:89
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
virtual CCopasiMethod * createMethod(const int &type) const

Member Data Documentation

C_FLOAT64 CTrajectoryTask::mOutputStartTime
private

A pointer to the time at which the output starts.

Definition at line 86 of file CTrajectoryTask.h.

Referenced by process(), and processStep().

CState* CTrajectoryTask::mpCurrentState
private

A pointer to the current state of the integration.

Definition at line 76 of file CTrajectoryTask.h.

Referenced by cleanup(), getState(), initialize(), process(), processStart(), processStep(), and restore().

const C_FLOAT64* CTrajectoryTask::mpCurrentTime
private

A pointer to the current time of the integration.

Definition at line 81 of file CTrajectoryTask.h.

Referenced by initialize(), process(), and processStep().

bool(* CTrajectoryTask::mpLess)(const C_FLOAT64 &, const C_FLOAT64 &)
private

A pointer to less comparison

Definition at line 96 of file CTrajectoryTask.h.

Referenced by process().

bool(* CTrajectoryTask::mpLessOrEqual)(const C_FLOAT64 &, const C_FLOAT64 &)
private

A pointer to lessOrEqual comparison

Definition at line 91 of file CTrajectoryTask.h.

Referenced by process(), and processStep().

CTrajectoryMethod* CTrajectoryTask::mpTrajectoryMethod
private

A pointer to the trajectory method

Definition at line 66 of file CTrajectoryTask.h.

Referenced by initialize(), processStart(), and processStep().

CTrajectoryProblem* CTrajectoryTask::mpTrajectoryProblem
private

A pointer to the trajectory Problem

Definition at line 61 of file CTrajectoryTask.h.

Referenced by initialize(), process(), processStart(), and processStep().

CTimeSeries CTrajectoryTask::mTimeSeries
private

the time series (if requested)

Definition at line 56 of file CTrajectoryTask.h.

Referenced by getTimeSeries(), and initialize().

bool CTrajectoryTask::mTimeSeriesRequested
private

whether the time series should be stored in mTimeSeries

Definition at line 51 of file CTrajectoryTask.h.

Referenced by initialize().

bool CTrajectoryTask::mUpdateMoieties
private

Indicates whether we need to update moieties.

Definition at line 71 of file CTrajectoryTask.h.

Referenced by CTrajectoryTask(), initialize(), load(), process(), processStep(), restore(), and setMethodType().

const unsigned int CTrajectoryTask::ValidMethods
static

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