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

#include <CScanMethod.h>

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

Public Member Functions

 CScanItemRandom (CCopasiParameterGroup *si, CRandom *rg, const bool &continueFromCurrentState)
 
virtual bool isNesting () const
 
virtual void step ()
 
virtual ~CScanItemRandom ()
 
- Public Member Functions inherited from CScanItem
size_t getNumSteps () const
 
const CCopasiObjectgetObject () const
 
bool isFinished () const
 
virtual bool isValidScanItem (const bool &continueFromCurrentState)
 
void reset ()
 
void restoreValue () const
 
void storeValue ()
 
virtual ~CScanItem ()
 

Private Attributes

C_FLOAT64 mFaktor
 
bool mLog
 
C_FLOAT64 mMax
 
C_FLOAT64 mMin
 
unsigned C_INT32 mRandomType
 
CRandommRg
 

Additional Inherited Members

- Static Public Member Functions inherited from CScanItem
static CScanItemcreateScanItemFromParameterGroup (CCopasiParameterGroup *si, CRandom *rg, const bool &continueFromCurrentState)
 
- Protected Member Functions inherited from CScanItem
 CScanItem (CCopasiParameterGroup *si, const bool &continueFromCurrentState)
 
- Protected Attributes inherited from CScanItem
bool mFlagFinished
 
size_t mIndex
 
bool mIsStateVariable
 
size_t mNumSteps
 
CCopasiObjectmpInitialObject
 
CCopasiObjectmpObject
 
C_FLOAT64 mStoreValue
 

Detailed Description

Definition at line 128 of file CScanMethod.h.

Constructor & Destructor Documentation

CScanItemRandom::CScanItemRandom ( CCopasiParameterGroup si,
CRandom rg,
const bool &  continueFromCurrentState 
)

Definition at line 267 of file CScanMethod.cpp.

References CCopasiParameterGroup::getValue(), mFaktor, mLog, mMax, mMin, CScanItem::mNumSteps, mRandomType, CCopasiParameter::Value::pBOOL, CCopasiParameter::Value::pDOUBLE, and CCopasiParameter::Value::pUINT.

268  :
269  CScanItem(si, continueFromCurrentState),
270  mRg(rg),
271  mRandomType(0),
272  mLog(false)
273 {
274  mRandomType = * si->getValue("Distribution type").pUINT;
275 
276  mLog = * si->getValue("log").pBOOL;
277  mMin = * si->getValue("Minimum").pDOUBLE;
278  mMax = * si->getValue("Maximum").pDOUBLE;
279 
280  if (mLog && mRandomType == 0)
281  {
282  mMin = log(mMin);
283  mMax = log(mMax);
284  }
285 
286  mNumSteps = 0;
287  mFaktor = (mMax - mMin);
288 }
C_FLOAT64 mMax
Definition: CScanMethod.h:131
unsigned C_INT32 mRandomType
Definition: CScanMethod.h:133
size_t mNumSteps
Definition: CScanMethod.h:39
C_FLOAT64 mMin
Definition: CScanMethod.h:131
unsigned C_INT32 * pUINT
CRandom * mRg
Definition: CScanMethod.h:132
const CCopasiParameter::Value & getValue(const std::string &name) const
C_FLOAT64 mFaktor
Definition: CScanMethod.h:131
virtual CScanItemRandom::~CScanItemRandom ( )
inlinevirtual

Definition at line 137 of file CScanMethod.h.

137 {};

Member Function Documentation

virtual bool CScanItemRandom::isNesting ( ) const
inlinevirtual

Reimplemented from CScanItem.

Definition at line 140 of file CScanMethod.h.

140 {return false;};
void CScanItemRandom::step ( )
virtual

Implements CScanItem.

Definition at line 290 of file CScanMethod.cpp.

References C_FLOAT64, CRandom::getRandomCC(), CRandom::getRandomGamma(), CRandom::getRandomNormal01(), CRandom::getRandomPoisson(), mFaktor, CScanItem::mFlagFinished, CScanItem::mIndex, mLog, mMax, mMin, CScanItem::mNumSteps, CScanItem::mpInitialObject, CScanItem::mpObject, mRandomType, mRg, CCopasiObject::setObjectValue(), and CCopasiMessage::WARNING.

291 {
292  C_FLOAT64 Value;
293 
294  //the index
295  if (mIndex > mNumSteps)
296  mFlagFinished = true;
297  else
298  {
299  C_FLOAT64 tmpF;
300 
301  switch (mRandomType)
302  {
303  case 0: // uniform
304  Value = mMin + mRg->getRandomCC() * mFaktor;
305 
306  if (mLog)
307  Value = exp(Value);
308 
309  break;
310 
311  case 1: // normal
312  tmpF = mRg->getRandomNormal01();
313  Value = mMin + tmpF * mMax;
314 
315  if (mLog)
316  Value = exp(Value);
317 
318  break;
319 
320  case 2: // poisson
321 
322  if (mMin < 0)
323  CCopasiMessage(CCopasiMessage::WARNING, "Invalid ScanItem: Requested Poisson random variable for negative argument: %lf", mMin);
324 
325  Value = mRg->getRandomPoisson(mMin);
326 
327  break;
328 
329  case 3: // gamma
330  Value = mRg->getRandomGamma(mMin, mMax);
331 
332  if (mLog)
333  Value = exp(Value);
334 
335  break;
336  }
337  }
338 
339  if (mpObject) mpObject->setObjectValue(Value);
340 
342 
343  ++mIndex;
344 }
C_FLOAT64 mMax
Definition: CScanMethod.h:131
void setObjectValue(const C_FLOAT64 &value)
CCopasiObject * mpInitialObject
Definition: CScanMethod.h:42
unsigned C_INT32 mRandomType
Definition: CScanMethod.h:133
virtual C_FLOAT64 getRandomNormal01()
Definition: CRandom.cpp:261
size_t mNumSteps
Definition: CScanMethod.h:39
virtual C_FLOAT64 getRandomPoisson(const C_FLOAT64 &mean)
Definition: CRandom.cpp:314
virtual C_FLOAT64 getRandomCC()
Definition: CRandom.cpp:235
bool mFlagFinished
Definition: CScanMethod.h:48
C_FLOAT64 mMin
Definition: CScanMethod.h:131
size_t mIndex
Definition: CScanMethod.h:46
CRandom * mRg
Definition: CScanMethod.h:132
#define C_FLOAT64
Definition: copasi.h:92
virtual C_FLOAT64 getRandomGamma(C_FLOAT64 shape, C_FLOAT64 scale)
Definition: CRandom.cpp:572
CCopasiObject * mpObject
Definition: CScanMethod.h:41
C_FLOAT64 mFaktor
Definition: CScanMethod.h:131

Member Data Documentation

C_FLOAT64 CScanItemRandom::mFaktor
private

Definition at line 131 of file CScanMethod.h.

Referenced by CScanItemRandom(), and step().

bool CScanItemRandom::mLog
private

Definition at line 134 of file CScanMethod.h.

Referenced by CScanItemRandom(), and step().

C_FLOAT64 CScanItemRandom::mMax
private

Definition at line 131 of file CScanMethod.h.

Referenced by CScanItemRandom(), and step().

C_FLOAT64 CScanItemRandom::mMin
private

Definition at line 131 of file CScanMethod.h.

Referenced by CScanItemRandom(), and step().

unsigned C_INT32 CScanItemRandom::mRandomType
private

Definition at line 133 of file CScanMethod.h.

Referenced by CScanItemRandom(), and step().

CRandom* CScanItemRandom::mRg
private

Definition at line 132 of file CScanMethod.h.

Referenced by step().


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