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

#include <CModelParameter.h>

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

Public Types

enum  CompareResult {
  Obsolete, Missing, Modified, Conflict,
  Identical
}
 
enum  Framework { Concentration = 0, ParticleNumbers }
 
enum  Type {
  Model, Compartment, Species, ModelValue,
  ReactionParameter, Reaction, Group, Set,
  unknown
}
 

Public Member Functions

 CModelParameter (CModelParameterGroup *pParent, const CModelParameter::Type &type)
 
 CModelParameter (const CModelParameter &src, CModelParameterGroup *pParent)
 
virtual void compile ()
 
virtual const CompareResultdiff (const CModelParameter &other, const CModelParameter::Framework &framework=ParticleNumbers, const bool &createMissing=false)
 
virtual const CModelParametergetChild (const size_t &index) const
 
const CCopasiObjectNamegetCN () const
 
const CompareResultgetCompareResult () const
 
size_t getIndex () const
 
std::string getInitialExpression () const
 
const CExpressiongetInitialExpressionPtr () const
 
CModelgetModel () const
 
virtual std::string getName () const
 
virtual size_t getNumChildren () const
 
CCopasiObjectgetObject () const
 
CModelParameterGroupgetParent () const
 
CModelParameterSetgetSet () const
 
const CModelEntity::StatusgetSimulationType () const
 
const TypegetType () const
 
const std::string getUnit (const Framework &framework) const
 
virtual const double & getValue (const Framework &framework) const
 
bool isInitialExpressionValid () const
 
bool isReadOnly () const
 
virtual bool refreshFromModel (const bool &modifyExistence)
 
virtual void setCN (const CCopasiObjectName &cn)
 
void setCompareResult (const CompareResult &compareResult)
 
void setInitialExpression (const std::string &initialExpression)
 
void setParent (CModelParameterGroup *pParent)
 
bool setSimulationType (const CModelEntity::Status &simulationType)
 
virtual void setValue (const double &value, const Framework &framework)
 
virtual bool updateModel ()
 
virtual ~CModelParameter ()
 

Static Public Attributes

static const char * TypeNames []
 

Static Protected Member Functions

static std::string nameFromCN (const CCopasiObjectName &cn)
 

Protected Attributes

CRegisteredObjectName mCN
 
CompareResult mCompareResult
 
bool mIsInitialExpressionValid
 
CExpressionmpInitialExpression
 
CCopasiObjectmpObject
 
CModelParameterGroupmpParent
 
CModelEntity::Status mSimulationType
 
Type mType
 
double mValue
 

Private Member Functions

 CModelParameter ()
 

Friends

std::ostream & operator<< (std::ostream &os, const CModelParameter &o)
 

Detailed Description

Definition at line 21 of file CModelParameter.h.

Member Enumeration Documentation

Enumerator
Obsolete 
Missing 
Modified 
Conflict 
Identical 

Definition at line 41 of file CModelParameter.h.

Enumerator
Concentration 
ParticleNumbers 

Definition at line 50 of file CModelParameter.h.

Enumerator
Model 
Compartment 
Species 
ModelValue 
ReactionParameter 
Reaction 
Group 
Set 
unknown 

Definition at line 26 of file CModelParameter.h.

Constructor & Destructor Documentation

CModelParameter::CModelParameter ( )
private

The default constructor is hidden.

Referenced by CModelParameterGroup::add(), and CModelParameterGroup::copy().

CModelParameter::CModelParameter ( CModelParameterGroup pParent,
const CModelParameter::Type type 
)

Constructor

Definition at line 60 of file CModelParameter.cpp.

References mpParent, mType, and Set.

60  :
61  mpParent(static_cast< CModelParameterGroup * >(pParent)),
62  mType(type),
63  mCN(),
65  mValue(std::numeric_limits< C_FLOAT64 >::quiet_NaN()),
66  mpInitialExpression(NULL),
68  mpObject(NULL),
70 {
71  assert(mType == Set || mpParent != NULL);
72 }
CModelParameterGroup * mpParent
CCopasiObject * mpObject
bool mIsInitialExpressionValid
CExpression * mpInitialExpression
CModelEntity::Status mSimulationType
CompareResult mCompareResult
CRegisteredObjectName mCN
CModelParameter::CModelParameter ( const CModelParameter src,
CModelParameterGroup pParent 
)

Copy constructor

Definition at line 74 of file CModelParameter.cpp.

References getInitialExpression(), mpParent, mType, Set, and setInitialExpression().

74  :
75  mpParent(pParent),
76  mType(src.mType),
77  mCN(src.mCN),
79  mValue(src.mValue),
80  mpInitialExpression(NULL),
82  mpObject(src.mpObject),
84 {
85  assert(mType == Set || mpParent != NULL);
86 
88 }
std::string getInitialExpression() const
CModelParameterGroup * mpParent
CCopasiObject * mpObject
bool mIsInitialExpressionValid
CExpression * mpInitialExpression
void setInitialExpression(const std::string &initialExpression)
CModelEntity::Status mSimulationType
CompareResult mCompareResult
CRegisteredObjectName mCN
CModelParameter::~CModelParameter ( )
virtual

Destructor

Definition at line 91 of file CModelParameter.cpp.

References mpParent, and CModelParameterGroup::remove().

92 {
93  if (mpParent != NULL)
94  {
95  mpParent->remove(this);
96  }
97 }
CModelParameterGroup * mpParent
void remove(CModelParameter *pModelParameter)

Member Function Documentation

void CModelParameter::compile ( )
virtual

Compile the parameter

Reimplemented in CModelParameterReactionParameter, CModelParameterSpecies, and CModelParameterGroup.

Definition at line 391 of file CModelParameter.cpp.

References Compartment, CExpression::compile(), getModel(), CCopasiObject::getObjectDataModel(), mCN, mIsInitialExpressionValid, Model, ModelValue, mpInitialExpression, mpObject, mType, CCopasiDataModel::ObjectFromName(), ReactionParameter, Species, and unknown.

Referenced by CModelParameterGroup::compile(), CModelParameterSpecies::compile(), and CModelParameterReactionParameter::compile().

392 {
393  mpObject = NULL;
395 
396  CModel * pModel = getModel();
397 
398  assert(pModel != NULL);
399 
400  std::vector< CCopasiContainer * > ListOfContainer;
401  ListOfContainer.push_back(pModel);
402 
403  mpObject = pModel->getObjectDataModel()->ObjectFromName(ListOfContainer, mCN);
404 
405  if (mpObject != NULL)
406  {
407  if (mType == unknown)
408  {
409  if (dynamic_cast< CModel * >(mpObject) != NULL)
410  mType = Model;
411  else if (dynamic_cast< CCompartment * >(mpObject) != NULL)
412  mType = Compartment;
413  else if (dynamic_cast< CMetab * >(mpObject) != NULL)
414  mType = Species;
415  else if (dynamic_cast< CModelValue * >(mpObject) != NULL)
416  mType = ModelValue;
417  else if (dynamic_cast< CCopasiParameter * >(mpObject) != NULL)
419  }
420  }
421 
422  if (mpInitialExpression != NULL)
423  {
425  }
426 }
CCopasiDataModel * getObjectDataModel()
CCopasiObject * mpObject
bool mIsInitialExpressionValid
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
Definition: CExpression.cpp:97
CExpression * mpInitialExpression
Definition: CModel.h:50
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CRegisteredObjectName mCN
CModel * getModel() const
const CModelParameter::CompareResult & CModelParameter::diff ( const CModelParameter other,
const CModelParameter::Framework framework = ParticleNumbers,
const bool &  createMissing = false 
)
virtual

Compare the parameter to an other

Parameters
constCModelParameter & other
constCModelParameter::Framework & framework (default: ParticleNumbers)
constbool & createMissing = false

Reimplemented in CModelParameterGroup.

Definition at line 428 of file CModelParameter.cpp.

References CModelEntity::ASSIGNMENT, Compartment, Conflict, getInitialExpression(), getObject(), getValue(), Identical, mCompareResult, Missing, ModelValue, Modified, mpObject, mType, Obsolete, ParticleNumbers, and Species.

431 {
432  if (mCompareResult == Missing ||
434  {
435  return mCompareResult;
436  }
437 
438  switch (mType)
439  {
440  case Compartment:
441  case Species:
442  case ModelValue:
443 
444  if (other.getObject() != NULL &&
445  mpObject != NULL &&
446  static_cast< CModelEntity *>(mpObject)->getStatus() == CModelEntity::ASSIGNMENT &&
447  (fabs(getValue(ParticleNumbers) - other.getValue(ParticleNumbers)) > 50 * (fabs(getValue(ParticleNumbers)) + fabs(other.getValue(ParticleNumbers))) * std::numeric_limits< C_FLOAT64 >::epsilon() ||
448  getInitialExpression() != ""))
449  {
451  return mCompareResult;
452  }
453 
454  break;
455 
456  default:
457  break;
458  }
459 
460  if (getInitialExpression() != other.getInitialExpression() ||
461  fabs(getValue(framework) - other.getValue(framework)) > 50 * (fabs(getValue(framework)) + fabs(other.getValue(framework))) * std::numeric_limits< C_FLOAT64 >::epsilon())
462  {
464  }
465  else
466  {
468  }
469 
470  return mCompareResult;
471 }
std::string getInitialExpression() const
CCopasiObject * mpObject
CCopasiObject * getObject() const
virtual const double & getValue(const Framework &framework) const
CompareResult mCompareResult
const CModelParameter * CModelParameter::getChild ( const size_t &  index) const
virtual

Reimplemented in CModelParameterGroup.

Definition at line 673 of file CModelParameter.cpp.

Referenced by applyValueToModelParameter().

674 {
675  return NULL;
676 }
const CCopasiObjectName & CModelParameter::getCN ( ) const

Retrieve the CN of the object represented by the parameter

Returns
const CCopasiObjectName & cn

Definition at line 199 of file CModelParameter.cpp.

References mCN.

Referenced by applyValueToModelParameter(), CModelParameterReactionParameter::compile(), CModelParameterSet::createFromModel(), CCopasiXML::saveModelParameter(), and CQParameterOverviewDM::setData().

200 {
201  return mCN;
202 }
CRegisteredObjectName mCN
const CModelParameter::CompareResult & CModelParameter::getCompareResult ( ) const

Retrieve the compare result.

Returns
const CompareResult & compareResult

Definition at line 302 of file CModelParameter.cpp.

References mCompareResult.

Referenced by CQParameterOverviewDM::diffData(), CQParameterOverviewDM::flags(), and CCopasiXML::saveModelParameter().

303 {
304  return mCompareResult;
305 }
CompareResult mCompareResult
size_t CModelParameter::getIndex ( ) const

Retrieve the index of the parameter in the vector of children in the parent

Returns
size_t index

Definition at line 307 of file CModelParameter.cpp.

References CModelParameterGroup::begin(), C_INVALID_INDEX, CModelParameterGroup::end(), and mpParent.

308 {
311 
312  size_t Index = 0;
313 
314  for (; it != end; ++it, ++Index)
315  {
316  if (*it == this) return Index;
317  }
318 
319  return C_INVALID_INDEX;
320 }
CModelParameterGroup * mpParent
#define C_INVALID_INDEX
Definition: copasi.h:222
std::vector< CModelParameter * >::const_iterator const_iterator
std::string CModelParameter::getInitialExpression ( ) const

Retrieve the initial expression infix.

Returns
std::string initialExpression

Definition at line 287 of file CModelParameter.cpp.

References CEvaluationTree::getInfix(), and mpInitialExpression.

Referenced by CQParameterOverviewDM::assignmentData(), CModelParameter(), CModelParameterReactionParameter::compile(), diff(), isReadOnly(), operator<<(), CCopasiXML::saveModelParameter(), and updateModel().

288 {
289  if (mpInitialExpression == NULL)
290  {
291  return "";
292  }
293 
294  return mpInitialExpression->getInfix();
295 }
CExpression * mpInitialExpression
const std::string & getInfix() const
const CExpression * CModelParameter::getInitialExpressionPtr ( ) const

Retrieve the actual initial expression.

Returns
const CExpression* initialExpression

Definition at line 282 of file CModelParameter.cpp.

References mpInitialExpression.

Referenced by CQParameterOverviewDM::assignmentData().

283 {
284  return mpInitialExpression;
285 }
CExpression * mpInitialExpression
CModel * CModelParameter::getModel ( ) const

Retrieve a pointer to the model the parameter is part of

Returns
CModel * pModel

Definition at line 363 of file CModelParameter.cpp.

References CModelParameterSet::getModel(), and getSet().

Referenced by compile(), CModelParameterReactionParameter::compile(), getUnit(), isReadOnly(), CModelParameterSpecies::setValue(), and updateModel().

364 {
365  CModelParameterSet * pSet = getSet();
366 
367  if (pSet != NULL)
368  {
369  return pSet->getModel();
370  }
371 
372  return NULL;
373 }
CModelParameterSet * getSet() const
CModel * getModel() const
std::string CModelParameter::getName ( ) const
virtual

Retrieve the name of the parameter.

Returns
std::string name

Reimplemented in CModelParameterSpecies, and CModelParameterSet.

Definition at line 381 of file CModelParameter.cpp.

References CCopasiObject::getObjectName(), mCN, mpObject, and nameFromCN().

Referenced by CQParameterOverviewDM::assignmentData(), getUnit(), CQParameterOverviewDM::nameData(), refreshFromModel(), and CModelParameterSet::saveToStream().

382 {
383  if (mpObject != NULL)
384  {
385  return mpObject->getObjectName();
386  }
387 
388  return nameFromCN(mCN);
389 }
static std::string nameFromCN(const CCopasiObjectName &cn)
CCopasiObject * mpObject
const std::string & getObjectName() const
CRegisteredObjectName mCN
size_t CModelParameter::getNumChildren ( ) const
virtual

Reimplemented in CModelParameterGroup.

Definition at line 667 of file CModelParameter.cpp.

Referenced by applyValueToModelParameter().

668 {
669  return 0;
670 }
CCopasiObject * CModelParameter::getObject ( ) const

Retrieve the pointer to the corresponding model object

Returns
CCopasiObject * pObject

Definition at line 336 of file CModelParameter.cpp.

References mpObject.

Referenced by diff().

337 {
338  return mpObject;
339 }
CCopasiObject * mpObject
CModelParameterGroup * CModelParameter::getParent ( ) const

Retrieve the parent, i.e., containing group, of the parameter.

Returns
CModelParameterGroup * pParent

Definition at line 104 of file CModelParameter.cpp.

References mpParent.

Referenced by CQParameterOverviewDM::getRow(), getSet(), CQParameterOverviewDM::index(), and CQParameterOverviewDM::parent().

105 {
106  return mpParent;
107 }
CModelParameterGroup * mpParent
CModelParameterSet * CModelParameter::getSet ( ) const

Retrieve a pointer to the parameter set the parameter belongs to

Returns
CModelParameterSet * set

Definition at line 341 of file CModelParameter.cpp.

References getParent(), getType(), mpParent, mType, and Set.

Referenced by CQParameterOverviewDM::assignmentData(), CModelParameterSpecies::compile(), CModelParameterReactionParameter::compile(), getModel(), CModelParameterSpecies::getName(), refreshFromModel(), CQParameterOverviewDM::setData(), setInitialExpression(), and setValue().

342 {
343  if (mType == Set)
344  {
345  return static_cast< CModelParameterSet * >(const_cast< CModelParameter * >(this));
346  }
347 
348  CModelParameterGroup * pParent = mpParent;
349 
350  while (pParent != NULL)
351  {
352  if (pParent->getType() == Set)
353  {
354  return static_cast< CModelParameterSet * >(pParent);
355  }
356 
357  pParent = pParent->getParent();
358  }
359 
360  return NULL;
361 }
CModelParameterGroup * mpParent
const Type & getType() const
CModelParameterGroup * getParent() const
const CModelEntity::Status & CModelParameter::getSimulationType ( ) const

Retrieve the role the parameters object plays in the simulation

Returns
const CModelEntity::Status & simulationType

Definition at line 242 of file CModelParameter.cpp.

References mSimulationType.

Referenced by CCopasiXML::saveModelParameter(), and CQParameterOverviewDM::typeData().

243 {
244  return mSimulationType;
245 }
CModelEntity::Status mSimulationType
const CModelParameter::Type & CModelParameter::getType ( ) const
const std::string CModelParameter::getUnit ( const Framework framework) const

Retrieve the unit of the parameter based on the current framework

Parameters
constFramework & framework (default: ParticleNumbers)
Returns
const std::string unit

Definition at line 114 of file CModelParameter.cpp.

References Compartment, Concentration, CModel::dimensionlessArea, CModel::dimensionlessLength, CModel::dimensionlessQuantity, CModel::dimensionlessTime, CModel::dimensionlessVolume, CModel::getAreaUnitEnum(), CReaction::getChemEq(), CCompartment::getChildObjectUnits(), CMetab::getChildObjectUnits(), CReaction::getCompartmentNumber(), CReaction::getFunction(), CMetab::getInitialConcentrationReference(), CModelEntity::getInitialValueReference(), CModel::getLengthUnitEnum(), getModel(), getName(), CReaction::getParameterIndex(), CModel::getQuantityUnitEnum(), CModel::getTimeUnitEnum(), CModel::getTimeUnitsDisplayString(), CModel::getVolumeUnitEnum(), Model, ModelValue, mpObject, mType, ReactionParameter, CFindDimensions::setUseHeuristics(), and Species.

Referenced by CModelParameterSet::saveToStream(), and CQParameterOverviewDM::unitData().

115 {
116  std::string Unit;
117 
118  switch (mType)
119  {
120  case Model:
122  break;
123 
124  case Compartment:
125  {
126  const CCompartment * pCompartment = static_cast< const CCompartment * >(mpObject);
127 
128  if (pCompartment == NULL)
129  {
130  return "";
131  }
132 
133  return pCompartment->getChildObjectUnits(pCompartment->getInitialValueReference());
134  }
135  break;
136 
137  case Species:
138  {
139  const CMetab * pSpecies = static_cast< const CMetab * >(mpObject);
140 
141  if (pSpecies == NULL)
142  {
143  return "";
144  }
145 
146  if (framework == Concentration)
147  {
148  return pSpecies->getChildObjectUnits(pSpecies->getInitialConcentrationReference());
149  }
150 
151  return pSpecies->getChildObjectUnits(pSpecies->getInitialValueReference());
152  }
153  break;
154 
155  case ModelValue:
156  break;
157 
158  case ReactionParameter:
159  {
160  const CReaction * pReaction = static_cast< const CModelParameterReactionParameter * >(this)->getReaction();
161 
162  if (pReaction == NULL)
163  {
164  return "";
165  }
166 
167  const CModel * pModel = getModel();
168 
169  CFindDimensions Units(pReaction->getFunction(),
175 
176  Units.setUseHeuristics(true);
177 
178  Units.setChemicalEquation(&pReaction->getChemEq());
179 
180  Units.findDimensions(pReaction->getCompartmentNumber() > 1);
181 
182  return Units.getDimensions()[pReaction->getParameterIndex(getName())].getDisplayString(pModel);
183  }
184  break;
185 
186  default:
187  break;
188  }
189 
190  return "";
191 }
CModel::AreaUnit getAreaUnitEnum() const
Definition: CModel.cpp:2198
CCopasiObject * mpObject
std::string getTimeUnitsDisplayString() const
Definition: CModel.cpp:4531
virtual std::string getName() const
CModel::QuantityUnit getQuantityUnitEnum() const
Definition: CModel.cpp:2331
CCopasiObject * getInitialValueReference() const
Definition: CMetab.h:178
void setUseHeuristics(bool flag)
Definition: CDimension.cpp:330
virtual std::string getChildObjectUnits(const CCopasiObject *pObject) const
const CFunction * getFunction() const
Definition: CReaction.cpp:252
size_t getParameterIndex(const std::string &parameterName, CFunctionParameter::DataType *pType=NULL) const
Definition: CReaction.cpp:292
CModel::LengthUnit getLengthUnitEnum() const
Definition: CModel.cpp:2220
virtual std::string getChildObjectUnits(const CCopasiObject *pObject) const
Definition: CMetab.cpp:118
CModel::TimeUnit getTimeUnitEnum() const
Definition: CModel.cpp:2243
size_t getCompartmentNumber() const
Definition: CReaction.cpp:873
Definition: CModel.h:50
CModel::VolumeUnit getVolumeUnitEnum() const
Definition: CModel.cpp:2175
CConcentrationReference * getInitialConcentrationReference() const
Definition: CMetab.cpp:861
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223
CModel * getModel() const
const C_FLOAT64 & CModelParameter::getValue ( const Framework framework) const
virtual

Retrieve the value of the parameter based on the current framework

Parameters
constFramework & framework
Returns
const double & value

Reimplemented in CModelParameterSpecies.

Definition at line 261 of file CModelParameter.cpp.

References mValue.

Referenced by CModelParameterReactionParameter::compile(), diff(), refreshFromModel(), CCopasiXML::saveModelParameter(), CModelParameterSet::saveToStream(), CModelParameterSpecies::setValue(), and CQParameterOverviewDM::valueData().

262 {
263  return mValue;
264 }
bool CModelParameter::isInitialExpressionValid ( ) const

Check whether the initial expression is valid, i.e., it compiled

Returns
bool isInitialExpressionValid

Definition at line 375 of file CModelParameter.cpp.

References mIsInitialExpressionValid.

376 {
378 }
bool mIsInitialExpressionValid
bool CModelParameter::isReadOnly ( ) const

Check whether the value is read only.

Returns
bool isReadOnly

Definition at line 322 of file CModelParameter.cpp.

References getInitialExpression(), getModel(), Group, mIsInitialExpressionValid, Model, mType, Reaction, and Set.

Referenced by CQParameterOverviewDM::flags().

323 {
324  if (mType == Reaction ||
325  mType == Group ||
326  mType == Set ||
327  (mType == Model && getModel()->isAutonomous()) ||
329  {
330  return true;
331  }
332 
333  return false;
334 }
std::string getInitialExpression() const
bool mIsInitialExpressionValid
CModel * getModel() const
std::string CModelParameter::nameFromCN ( const CCopasiObjectName cn)
staticprotected

Determine the parameter name based on the CN of the corresponding object

Parameters
constCCopasiObjectName & cn
Returns
std::string name

Definition at line 39 of file CModelParameter.cpp.

References CCopasiObjectName::getElementName(), CCopasiObjectName::getObjectName(), CCopasiObjectName::getPrimary(), and CCopasiObjectName::getRemainder().

Referenced by getName(), and CModelParameterSpecies::getName().

40 {
41  CCopasiObjectName Primary = cn.getPrimary();
42  CCopasiObjectName Remainder = cn.getRemainder();
43 
44  while (Remainder != "")
45  {
46  Primary = Remainder.getPrimary();
47  Remainder = Remainder.getRemainder();
48  }
49 
50  std::string Name = Primary.getElementName(0);
51 
52  if (Name != "")
53  {
54  return Name;
55  }
56 
57  return Primary.getObjectName();
58 }
CCopasiObjectName getRemainder() const
CCopasiObjectName getPrimary() const
std::string getElementName(const size_t &pos, const bool &unescape=true) const
std::string getObjectName() const
bool CModelParameter::refreshFromModel ( const bool &  modifyExistence)
virtual

Refresh the parameter from the corresponding model object

Parameters
constbool & modifyExistence

Reimplemented in CModelParameterGroup.

Definition at line 561 of file CModelParameter.cpp.

References CModelEntity::ASSIGNMENT, Compartment, CModelEntity::FIXED, CKeyFactory::get(), CModelEntity::getInitialValue(), CCopasiRootContainer::getKeyFactory(), CModelParameterGroup::getModelParameter(), getName(), CReaction::getParameterMapping(), getSet(), getValue(), CCopasiParameter::getValue(), Identical, CModel::isAutonomous(), CReaction::isLocalParameter(), mCompareResult, Missing, Model, ModelValue, mpObject, mSimulationType, mType, mValue, Obsolete, ParticleNumbers, CCopasiParameter::Value::pDOUBLE, ReactionParameter, and Species.

Referenced by CQParameterOverviewWidget::slotResolve().

562 {
563  bool success = true;
564 
565  if (modifyExistence)
566  {
568  {
569  delete this;
570 
571  return true;
572  }
573 
575  {
577  }
578 
579  if (mType != ReactionParameter &&
580  mpObject != NULL)
581  {
582  mSimulationType = static_cast< CModelEntity * >(mpObject)->getStatus();
583  }
584  }
585 
586  if (mpObject != NULL)
587  {
588  switch (mType)
589  {
590  case Model:
591  {
592  CModel * pModel = static_cast< CModel * >(mpObject);
593 
594  if (!pModel->isAutonomous())
595  {
596  mValue = pModel->getInitialValue();
597  }
598  else
599  {
600  mValue = 0.0;
601  }
602  }
603  break;
604 
605  case Compartment:
606  case Species:
607  case ModelValue:
608  {
609  CModelEntity * pEntity = static_cast< CModelEntity * >(mpObject);
610 
611  mValue = pEntity->getInitialValue();
612  }
613  break;
614 
615  case ReactionParameter:
616  {
617  CCopasiParameter * pParameter = static_cast< CCopasiParameter * >(mpObject);
618  mValue = * pParameter->getValue().pDOUBLE;
619 
620  // We need to update the mapping
621  // Check whether this refers to a global quantity.
622  const CReaction * pReaction = static_cast< CModelParameterReactionParameter * >(this)->getReaction();
623 
624  if (pReaction != NULL)
625  {
626  if (pReaction->isLocalParameter(getName()))
627  {
629  static_cast< CModelParameterReactionParameter * >(this)->setGlobalQuantityCN("");
630  }
631  else
632  {
634  const std::vector<std::string> ModelValue = pReaction->getParameterMapping(getName());
635 
636  assert(ModelValue.size() == 1);
637 
638  CModelValue * pModelValue = static_cast< CModelValue * >(CCopasiRootContainer::getKeyFactory()->get(ModelValue[0]));
639  static_cast< CModelParameterReactionParameter * >(this)->setGlobalQuantityCN(pModelValue->getInitialValueReference()->getCN());
640  }
641  }
642 
643  CCopasiObjectName GlobalQuantityCN = static_cast< CModelParameterReactionParameter * >(this)->getGlobalQuantityCN();
644 
645  if (GlobalQuantityCN != "")
646  {
647  CModelParameter * pGlobalQuantity = getSet()->getModelParameter(GlobalQuantityCN);
648 
649  if (pGlobalQuantity != NULL)
650  {
651  mValue = pGlobalQuantity->getValue(ParticleNumbers);
652  }
653  }
654  }
655  break;
656 
657  default:
658  success = false;
659  break;
660  }
661  }
662 
663  return success;
664 }
CCopasiObject * mpObject
virtual std::string getName() const
CCopasiObject * get(const std::string &key)
CModelParameter * getModelParameter(const std::string &cn) const
bool isLocalParameter(const size_t &index) const
Definition: CReaction.cpp:449
const C_FLOAT64 & getInitialValue() const
const bool & isAutonomous() const
Definition: CModel.cpp:3956
CModelParameterSet * getSet() const
const Value & getValue() const
CModelEntity::Status mSimulationType
virtual const double & getValue(const Framework &framework) const
CompareResult mCompareResult
static CKeyFactory * getKeyFactory()
Definition: CModel.h:50
const std::vector< std::string > & getParameterMapping(const size_t &index) const
Definition: CReaction.cpp:432
void CModelParameter::setCN ( const CCopasiObjectName cn)
virtual

Set the CN of the object represented by the parameter

Parameters
constCCopasiObjectName & cn

Reimplemented in CModelParameterSpecies.

Definition at line 194 of file CModelParameter.cpp.

References mCN.

Referenced by CModelParameterSet::createFromModel(), CModelParameterSpecies::setCN(), CCopasiXMLParser::ModelParameterElement::start(), and CCopasiXMLParser::ModelParameterGroupElement::start().

195 {
196  mCN = cn;
197 }
CRegisteredObjectName mCN
void CModelParameter::setCompareResult ( const CompareResult compareResult)

The the compare result.

Parameters
constCompareResult & compareResult

Definition at line 297 of file CModelParameter.cpp.

References mCompareResult.

Referenced by CModelParameterGroup::diff().

298 {
299  mCompareResult = compareResult;
300 }
CompareResult mCompareResult
void CModelParameter::setInitialExpression ( const std::string &  initialExpression)

Set the initial expression infix.

Parameters
conststd::string & initialExpression

Definition at line 266 of file CModelParameter.cpp.

References getSet(), mpInitialExpression, pdelete, and CExpression::setInfix().

Referenced by CModelParameter(), CModelParameterSet::createFromModel(), CCopasiXMLParser::ModelParameterElement::end(), and CModelParameterReactionParameter::setGlobalQuantityCN().

267 {
268  if (initialExpression == "")
269  {
271  return;
272  }
273 
274  if (mpInitialExpression == NULL)
275  {
276  mpInitialExpression = new CExpression("InitialExpression", getSet());
277  }
278 
279  mpInitialExpression->setInfix(initialExpression);
280 }
virtual bool setInfix(const std::string &infix)
Definition: CExpression.cpp:63
#define pdelete(p)
Definition: copasi.h:215
CExpression * mpInitialExpression
CModelParameterSet * getSet() const
void CModelParameter::setParent ( CModelParameterGroup pParent)

Set the parent, i.e., containing group, of the parameter. Note, it is the responsibility of the user to remove the parameter from the old part.

Parameters
CModelParameterGroup* pParent

Definition at line 99 of file CModelParameter.cpp.

References mpParent.

100 {
101  mpParent = pParent;
102 }
CModelParameterGroup * mpParent
bool CModelParameter::setSimulationType ( const CModelEntity::Status simulationType)

Set the role the parameters object plays in the simulation. Note, REACTION is only valid for species.

Parameters
constCModelEntity::Status & simulationType
Returns
bool success

Definition at line 204 of file CModelParameter.cpp.

References CModelEntity::ASSIGNMENT, Compartment, CModelEntity::FIXED, Model, ModelValue, mSimulationType, mType, ReactionParameter, CModelEntity::REACTIONS, Species, and CModelEntity::TIME.

Referenced by CModelParameterReactionParameter::compile(), CModelParameterSet::createFromModel(), and CCopasiXMLParser::ModelParameterElement::start().

205 {
206  bool success = true;
207 
208  switch (mType)
209  {
210  case Model:
211  success = (simulationType == CModelEntity::TIME);
212  break;
213 
214  case Species:
215  success = (simulationType != CModelEntity::TIME);
216  break;
217 
218  case ReactionParameter:
219  success = (simulationType == CModelEntity::FIXED ||
220  simulationType == CModelEntity::ASSIGNMENT);
221  break;
222 
223  case ModelValue:
224  case Compartment:
225  success = (simulationType != CModelEntity::TIME &&
226  simulationType != CModelEntity::REACTIONS);
227  break;
228 
229  default:
230  success = (simulationType == CModelEntity::FIXED);
231  break;
232  }
233 
234  if (success)
235  {
236  mSimulationType = simulationType;
237  }
238 
239  return success;
240 }
CModelEntity::Status mSimulationType
void CModelParameter::setValue ( const double &  value,
const Framework framework 
)
virtual

Set the value of the parameter based on the current framework

Parameters
constdouble & value
constFramework & framework

Definition at line 248 of file CModelParameter.cpp.

References getSet(), CModelParameterSet::isActive(), mValue, and updateModel().

Referenced by applyValueToModelParameter(), CModelParameterSet::createFromModel(), CQParameterOverviewDM::setData(), and CCopasiXMLParser::ModelParameterElement::start().

249 {
250  mValue = value;
251 
252  CModelParameterSet * pSet = getSet();
253 
254  if (pSet->isActive())
255  {
256  updateModel();
257  }
258 }
virtual bool updateModel()
CModelParameterSet * getSet() const
bool CModelParameter::updateModel ( )
virtual

Update the corresponding model object with the current parameter settings

Reimplemented in CModelParameterGroup, and CModelParameterSet.

Definition at line 474 of file CModelParameter.cpp.

References CModelEntity::ASSIGNMENT, C_FLOAT64, Compartment, getInitialExpression(), CCopasiParameter::getKey(), CCopasiObject::getKey(), getModel(), CCopasiObject::getObjectAncestor(), CCopasiObject::getObjectDataModel(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CModelEntity::getStatus(), CCopasiObject::getValuePointer(), CModel::isAutonomous(), mIsInitialExpressionValid, Model, ModelValue, mpInitialExpression, mpObject, mpParent, mType, mValue, CCopasiDataModel::ObjectFromName(), ReactionParameter, CModelEntity::setInitialExpression(), CModelEntity::setInitialValue(), CReaction::setParameterMapping(), CCopasiParameter::setValue(), and Species.

Referenced by setValue().

475 {
476  bool success = true;
477 
478  if (mpObject != NULL)
479  {
480  switch (mType)
481  {
482  case Model:
483  {
484  CModel * pModel = static_cast< CModel * >(mpObject);
485 
486  if (!pModel->isAutonomous())
487  {
488  pModel->setInitialValue(mValue);
489  }
490  else
491  {
492  pModel->setInitialValue(0.0);
493  }
494  }
495  break;
496 
497  case Compartment:
498  case Species:
499  case ModelValue:
500  {
501  CModelEntity * pEntity = static_cast< CModelEntity * >(mpObject);
502 
503  if (pEntity->getStatus() != CModelEntity::ASSIGNMENT)
504  {
505  pEntity->setInitialValue(mValue);
506 
508  {
510  }
511  }
512  }
513  break;
514 
515  case ReactionParameter:
516  {
517  CCopasiParameter * pParameter = static_cast< CCopasiParameter * >(mpObject);
518  CReaction * pReaction = static_cast< CReaction * >(mpObject->getObjectAncestor("Reaction"));
519 
521  getInitialExpression() != "")
522  {
523  CModel * pModel = mpParent->getModel();
524 
525  assert(pModel != NULL);
526 
527  std::vector< CCopasiContainer * > ListOfContainer;
528  ListOfContainer.push_back(pModel);
529 
530  CCopasiObjectName CN = static_cast< CEvaluationNodeObject * >(mpInitialExpression->getRoot())->getObjectCN();
531  CCopasiObject * pObject = pModel->getObjectDataModel()->ObjectFromName(ListOfContainer, CN);
532 
533  assert(pObject != NULL);
534 
535  // We assign the object value
536  pParameter->setValue(* (C_FLOAT64 *) pObject->getValuePointer());
537 
538  // We map the parameter to the global quantity
539  pReaction->setParameterMapping(pParameter->getObjectName(), pObject->getObjectParent()->getKey());
540  }
541  else
542  {
543  pParameter->setValue(mValue);
544 
545  // We need to remove the existing mapping to a global quantity1.
546  pReaction->setParameterMapping(pParameter->getObjectName(), pParameter->getKey());
547  }
548  }
549  break;
550 
551  default:
552  success = false;
553  break;
554  }
555  }
556 
557  return success;
558 }
CCopasiDataModel * getObjectDataModel()
CCopasiContainer * getObjectAncestor(const std::string &type) const
std::string getInitialExpression() const
CModelParameterGroup * mpParent
bool setValue(const CType &value)
CCopasiObject * mpObject
const std::string & getObjectName() const
bool mIsInitialExpressionValid
bool setInitialExpression(const std::string &expression)
CExpression * mpInitialExpression
virtual const std::string & getKey() const
virtual const std::string & getKey() const
const bool & isAutonomous() const
Definition: CModel.cpp:3956
#define C_FLOAT64
Definition: copasi.h:92
void setParameterMapping(const size_t &index, const std::string &key)
Definition: CReaction.cpp:339
virtual void setInitialValue(const C_FLOAT64 &initialValue)
virtual void * getValuePointer() const
Definition: CModel.h:50
const CModelEntity::Status & getStatus() const
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
CModel * getModel() const

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CModelParameter o 
)
friend

Definition at line 862 of file CModelParameter.cpp.

863 {
864  os << "Model Parameter:" << std::endl;
865  os << " Type: " << CModelParameter::TypeNames[o.mType] << std::endl;
866  os << " CN: " << o.mCN << std::endl;
867  os << " Value: " << o.mValue << std::endl;
868  os << " Expression: " << o.getInitialExpression() << std::endl;
869  os << " Diff: " << o.mCompareResult << std::endl;
870 
871  return os;
872 }
std::string getInitialExpression() const
static const char * TypeNames[]
CompareResult mCompareResult
CRegisteredObjectName mCN

Member Data Documentation

CRegisteredObjectName CModelParameter::mCN
protected

The CN of the corresponding model object

Definition at line 274 of file CModelParameter.h.

Referenced by compile(), getCN(), getName(), CModelParameterSpecies::getName(), operator<<(), setCN(), and CModelParameterSpecies::setCN().

CompareResult CModelParameter::mCompareResult
protected
bool CModelParameter::mIsInitialExpressionValid
protected

The result of the last compile of the initial expression. Note an empty or missing expression is valid.

Definition at line 305 of file CModelParameter.h.

Referenced by compile(), isInitialExpressionValid(), isReadOnly(), and updateModel().

CExpression* CModelParameter::mpInitialExpression
protected

A pointer to the initial expression

Definition at line 289 of file CModelParameter.h.

Referenced by compile(), getInitialExpression(), getInitialExpressionPtr(), setInitialExpression(), and updateModel().

CCopasiObject* CModelParameter::mpObject
protected

A pointer to the corresponding model object. NULL if no object exists.

Definition at line 299 of file CModelParameter.h.

Referenced by compile(), diff(), getName(), CModelParameterSpecies::getName(), getObject(), getUnit(), refreshFromModel(), and updateModel().

CModelParameterGroup* CModelParameter::mpParent
protected
CModelEntity::Status CModelParameter::mSimulationType
protected

The role the parameter object is used in the simulation.

Definition at line 279 of file CModelParameter.h.

Referenced by getSimulationType(), refreshFromModel(), and setSimulationType().

Type CModelParameter::mType
protected
double CModelParameter::mValue
protected
const char * CModelParameter::TypeNames
static
Initial value:
=
{
"Model",
"Compartment",
"Species",
"ModelValue",
"ReactionParameter",
"Reaction",
"Group",
"Set",
"unknown",
NULL
}

Definition at line 39 of file CModelParameter.h.

Referenced by operator<<(), CCopasiXML::saveModelParameter(), CCopasiXMLParser::ModelParameterElement::start(), and CCopasiXMLParser::ModelParameterGroupElement::start().


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