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

#include <CSensMethod.h>

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

Public Member Functions

 CSensMethod (const CSensMethod &src, const CCopasiContainer *pParent=NULL)
 
size_t getNumberOfSubtaskCalculations ()
 
bool initialize (CSensProblem *problem)
 
virtual bool isValidProblem (const CCopasiProblem *pProblem)
 
bool process (CProcessReport *handler)
 
bool restore (const bool &updateModel)
 
 ~CSensMethod ()
 
- Public Member Functions inherited from CCopasiMethod
 CCopasiMethod (const CCopasiMethod &src, const CCopasiContainer *pParent=NULL)
 
const CCopasiMethod::SubTypegetSubType () const
 
const CCopasiTask::TypegetType () const
 
virtual void load (CReadConfig &configBuffer, CReadConfig::Mode mode=CReadConfig::SEARCH)
 
virtual void print (std::ostream *ostream) const
 
virtual void printResult (std::ostream *ostream) const
 
virtual bool setCallBack (CProcessReport *pCallBack)
 
virtual ~CCopasiMethod ()
 
- Public Member Functions inherited from CCopasiParameterGroup
bool addGroup (const std::string &name)
 
bool addParameter (const CCopasiParameter &parameter)
 
bool addParameter (const std::string &name, const CCopasiParameter::Type type)
 
template<class CType >
bool addParameter (const std::string &name, const CCopasiParameter::Type type, const CType &value)
 
void addParameter (CCopasiParameter *pParameter)
 
CCopasiParameterGroupassertGroup (const std::string &name)
 
template<class CType >
CCopasiParameterassertParameter (const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
 
index_iterator beginIndex () const
 
name_iterator beginName () const
 
 CCopasiParameterGroup (const CCopasiParameterGroup &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameterGroup (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &objectType="ParameterGroup")
 
void clear ()
 
virtual bool elevateChildren ()
 
index_iterator endIndex () const
 
name_iterator endName () const
 
CCopasiParameterGroupgetGroup (const std::string &name)
 
const CCopasiParameterGroupgetGroup (const std::string &name) const
 
CCopasiParameterGroupgetGroup (const size_t &index)
 
const CCopasiParameterGroupgetGroup (const size_t &index) const
 
size_t getIndex (const std::string &name) const
 
std::string getKey (const std::string &name) const
 
std::string getKey (const size_t &index) const
 
virtual const std::string & getName (const size_t &index) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
CCopasiParametergetParameter (const std::string &name)
 
const CCopasiParametergetParameter (const std::string &name) const
 
CCopasiParametergetParameter (const size_t &index)
 
const CCopasiParametergetParameter (const size_t &index) const
 
CCopasiParameter::Type getType (const std::string &name) const
 
CCopasiParameter::Type getType (const size_t &index) const
 
std::string getUniqueParameterName (const CCopasiParameter *pParameter) const
 
const CCopasiParameter::ValuegetValue (const std::string &name) const
 
const CCopasiParameter::ValuegetValue (const size_t &index) const
 
CCopasiParameter::ValuegetValue (const std::string &name)
 
CCopasiParameter::ValuegetValue (const size_t &index)
 
CCopasiParameterGroupoperator= (const CCopasiParameterGroup &rhs)
 
bool removeParameter (const std::string &name)
 
bool removeParameter (const size_t &index)
 
template<class CType >
bool setValue (const std::string &name, const CType &value)
 
template<class CType >
bool setValue (const size_t &index, const CType &value)
 
size_t size () const
 
bool swap (const size_t &iFrom, const size_t &iTo)
 
bool swap (index_iterator &from, index_iterator &to)
 
virtual ~CCopasiParameterGroup ()
 
- Public Member Functions inherited from CCopasiParameter
 CCopasiParameter (const CCopasiParameter &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameter (const std::string &name, const Type &type, const void *pValue=NULL, const CCopasiContainer *pParent=NULL, const std::string &objectType="Parameter")
 
virtual CCopasiObjectName getCN () const
 
virtual const std::string & getKey () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const CCopasiParameter::TypegetType () const
 
const ValuegetValue () const
 
ValuegetValue ()
 
virtual voidgetValuePointer () const
 
CCopasiObjectgetValueReference () const
 
bool isValidValue (const C_FLOAT64 &value) const
 
bool isValidValue (const C_INT32 &value) const
 
bool isValidValue (const unsigned C_INT32 &value) const
 
bool isValidValue (const bool &value) const
 
bool isValidValue (const std::string &value) const
 
bool isValidValue (const CCopasiObjectName &value) const
 
bool isValidValue (const std::vector< CCopasiParameter * > &value) const
 
CCopasiParameteroperator= (const CCopasiParameter &rhs)
 
template<class CType >
bool setValue (const CType &value)
 
bool setValue (const std::vector< CCopasiParameter * > &value)
 
virtual ~CCopasiParameter ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Static Public Member Functions

static CSensMethodcreateMethod (CCopasiMethod::SubType subType=CCopasiMethod::sensMethod)
 
- 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)
 

Protected Member Functions

void calculate_difference (size_t level, const C_FLOAT64 &delta, CCopasiArray &result, CCopasiArray::index_type &resultindex)
 
bool calculate_one_level (size_t level, CCopasiArray &result)
 
 CSensMethod (CCopasiMethod::SubType subType, const CCopasiContainer *pParent=NULL)
 
void do_collapsing ()
 
C_FLOAT64 do_collapsing_innerloop (CCopasiArray::index_type &fullindex)
 
void do_scaling ()
 
bool do_target_calculation (CCopasiArray &result, bool first)
 
C_FLOAT64 do_variation (CCopasiObject *variable)
 
void scaling_targetfunction (const C_FLOAT64 &factor, CCopasiArray::index_type &resultindex)
 
void scaling_variables (size_t level, const C_FLOAT64 &factor, CCopasiArray::index_type &resultindex)
 
void setValue (CCopasiObject *variable, C_FLOAT64 value)
 
- Protected Member Functions inherited from CCopasiMethod
 CCopasiMethod (const CCopasiTask::Type &taskType, const SubType &subType, const CCopasiContainer *pParent=NULL)
 
- Protected Member Functions inherited from CCopasiParameterGroup
 CCopasiParameterGroup ()
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 

Protected Attributes

std::vector< Refresh * > mInitialRefreshes
 
std::vector< CSensMethodLocalDatamLocalData
 
C_FLOAT64mpDeltaFactor
 
C_FLOAT64mpMinDelta
 
CSensProblemmpProblem
 
CCopasiTaskmpSubTask
 
bool mStoreSubtasktUpdateFlag
 stores the update model flag of the subtask More...
 
std::vector< CCopasiObject * > mTargetfunctionPointers
 
- Protected Attributes inherited from CCopasiMethod
CProcessReportmpCallBack
 
- Protected Attributes inherited from CCopasiParameter
std::string mKey
 
CCopasiObjectmpValueReference
 
size_t mSize
 
Value mValue
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 

Private Member Functions

 CSensMethod ()
 

Private Attributes

size_t mCounter
 
size_t mFailedCounter
 
unsigned C_INT32 mProgress
 
size_t mProgressHandler
 

Additional Inherited Members

- Public Types inherited from CCopasiMethod
enum  SubType {
  unset = 0, RandomSearch, RandomSearchMaster, SimulatedAnnealing,
  CoranaWalk, DifferentialEvolution, ScatterSearch, GeneticAlgorithm,
  EvolutionaryProgram, SteepestDescent, HybridGASA, GeneticAlgorithmSR,
  HookeJeeves, LevenbergMarquardt, NelderMead, SRES,
  Statistics, ParticleSwarm, Praxis, TruncatedNewton,
  Newton, deterministic, LSODAR, directMethod,
  stochastic, tauLeap, adaptiveSA, hybrid,
  hybridLSODA, hybridODE45, DsaLsodar, tssILDM,
  tssILDMModified, tssCSP, mcaMethodReder, scanMethod,
  lyapWolf, sensMethod, EFMAlgorithm, EFMBitPatternTreeAlgorithm,
  EFMBitPatternAlgorithm, Householder, crossSectionMethod, linearNoiseApproximation
}
 
- Public Types inherited from CCopasiParameterGroup
typedef parameterGroup::iterator index_iterator
 
typedef
CCopasiContainer::objectMap::iterator 
name_iterator
 
typedef std::vector
< CCopasiParameter * > 
parameterGroup
 
- Public Types inherited from CCopasiParameter
enum  Type {
  DOUBLE = 0, UDOUBLE, INT, UINT,
  BOOL, GROUP, STRING, CN,
  KEY, FILE, EXPRESSION, INVALID
}
 
- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Static Public Attributes inherited from CCopasiMethod
static const std::string SubTypeName []
 
static const char * XMLSubType []
 
- Static Public Attributes inherited from CCopasiParameter
static const std::string TypeName []
 
static const char * XMLType []
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- 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
}
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 49 of file CSensMethod.h.

Constructor & Destructor Documentation

CSensMethod::CSensMethod ( )
private

Default constructor.

Referenced by createMethod().

CSensMethod::CSensMethod ( CCopasiMethod::SubType  subType,
const CCopasiContainer pParent = NULL 
)
explicitprotected

Specific constructor.

Parameters
CCopasiMethod::SubTypesubType
constCCopasiContainer * pParent (default: NULL)

Default constructor.

Definition at line 55 of file CSensMethod.cpp.

References CCopasiParameterGroup::addParameter(), C_FLOAT64, CONSTRUCTOR_TRACE, CCopasiParameter::getValue(), mpDeltaFactor, mpMinDelta, CCopasiParameter::Value::pUDOUBLE, and CCopasiParameter::UDOUBLE.

56  :
57  CCopasiMethod(CCopasiTask::sens, subType, pParent),
58  mpProblem(NULL),
59  mLocalData(),
61  mpSubTask(NULL),
63  mpDeltaFactor(NULL),
64  mpMinDelta(NULL),
67  mProgress(0),
68  mCounter(0),
70 {
71  addParameter("Delta factor",
73  mpDeltaFactor = (C_FLOAT64*)getValue("Delta factor").pUDOUBLE;
74 
75  addParameter("Delta minimum",
77  mpMinDelta = (C_FLOAT64*)getValue("Delta minimum").pUDOUBLE;
78 
80 }
C_FLOAT64 * mpDeltaFactor
Definition: CSensMethod.h:178
std::vector< CCopasiObject * > mTargetfunctionPointers
Definition: CSensMethod.h:172
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
#define C_INVALID_INDEX
Definition: copasi.h:222
size_t mFailedCounter
Definition: CSensMethod.h:189
size_t mProgressHandler
Definition: CSensMethod.h:185
CSensProblem * mpProblem
Definition: CSensMethod.h:168
const Value & getValue() const
std::vector< Refresh * > mInitialRefreshes
Definition: CSensMethod.h:176
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 * mpMinDelta
Definition: CSensMethod.h:179
bool mStoreSubtasktUpdateFlag
stores the update model flag of the subtask
Definition: CSensMethod.h:182
bool addParameter(const CCopasiParameter &parameter)
size_t mCounter
Definition: CSensMethod.h:188
CCopasiTask * mpSubTask
Definition: CSensMethod.h:174
unsigned C_INT32 mProgress
Definition: CSensMethod.h:186
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CSensMethod::CSensMethod ( const CSensMethod src,
const CCopasiContainer pParent = NULL 
)

Copy constructor.

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

Copy constructor.

Parameters
const CSensMethod &src

Definition at line 86 of file CSensMethod.cpp.

References CONSTRUCTOR_TRACE.

87  :
88  CCopasiMethod(src, pParent),
89  mpProblem(src.mpProblem),
90  mLocalData(),
92  mpSubTask(NULL),
94  mpDeltaFactor(NULL),
95  mpMinDelta(NULL),
98  mProgress(0),
99  mCounter(0),
100  mFailedCounter(0)
C_FLOAT64 * mpDeltaFactor
Definition: CSensMethod.h:178
std::vector< CCopasiObject * > mTargetfunctionPointers
Definition: CSensMethod.h:172
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
#define C_INVALID_INDEX
Definition: copasi.h:222
size_t mFailedCounter
Definition: CSensMethod.h:189
size_t mProgressHandler
Definition: CSensMethod.h:185
CSensProblem * mpProblem
Definition: CSensMethod.h:168
std::vector< Refresh * > mInitialRefreshes
Definition: CSensMethod.h:176
C_FLOAT64 * mpMinDelta
Definition: CSensMethod.h:179
bool mStoreSubtasktUpdateFlag
stores the update model flag of the subtask
Definition: CSensMethod.h:182
size_t mCounter
Definition: CSensMethod.h:188
CCopasiTask * mpSubTask
Definition: CSensMethod.h:174
unsigned C_INT32 mProgress
Definition: CSensMethod.h:186
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CSensMethod::~CSensMethod ( )

Destructor.

Definition at line 106 of file CSensMethod.cpp.

References DESTRUCTOR_TRACE.

#define DESTRUCTOR_TRACE
Definition: copasi.h:206

Member Function Documentation

void CSensMethod::calculate_difference ( size_t  level,
const C_FLOAT64 delta,
CCopasiArray result,
CCopasiArray::index_type resultindex 
)
protected

Definition at line 213 of file CSensMethod.cpp.

References C_INVALID_INDEX, and mLocalData.

Referenced by calculate_one_level().

215 {
216  assert(delta != 0.0);
217  assert(mLocalData[level].tmp1.size() == mLocalData[level].tmp2.size());
218  size_t dim = mLocalData[level].tmp1.dimensionality();
219  assert(resultindex.size() >= dim);
220 
221  CCopasiArray::index_type indexmax = mLocalData[level].tmp1.size();
222 
223  //init index with zero
224  CCopasiArray::index_type indexit; indexit.resize(dim);
225  size_t i;
226 
227  for (i = 0; i < dim; ++i)
228  indexit[i] = 0;
229 
230  //handle scalars separately
231  if (dim == 0)
232  {
233  result[resultindex] = (mLocalData[level].tmp2[indexit] - mLocalData[level].tmp1[indexit]) / delta;
234  return;
235  }
236 
237  //now for all higher dimensionalities
238  for (;;)
239  {
240  //do difference calculation
241  for (i = 0; i < dim; ++i)
242  resultindex[i] = indexit[i]; //TODO: use stl algorithm
243 
244  result[resultindex] = (mLocalData[level].tmp2[indexit] - mLocalData[level].tmp1[indexit]) / delta;
245 
246  //increase index
247  ++indexit[dim - 1];
248 
249  //check overflow
250  size_t j;
251 
252  for (j = dim - 1; j != C_INVALID_INDEX; --j)
253  {
254  if (indexit[j] >= indexmax[j])
255  {
256  indexit[j] = 0;
257 
258  if (j > 0)
259  ++indexit[j - 1];
260  else
261  return;
262  }
263  else
264  break;
265  }
266  }
267 }
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
#define C_INVALID_INDEX
Definition: copasi.h:222
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
bool CSensMethod::calculate_one_level ( size_t  level,
CCopasiArray result 
)
protected

Definition at line 269 of file CSensMethod.cpp.

References C_FLOAT64, calculate_difference(), do_target_calculation(), do_variation(), CCopasiParameter::getValuePointer(), mLocalData, CCopasiArray::resize(), and setValue().

Referenced by process().

270 {
271  //do first calculation
272  if (level == 0)
273  {
274  if (!do_target_calculation(mLocalData[level].tmp1, true)) return false;
275  }
276  else
277  {
278  if (!calculate_one_level(level - 1, mLocalData[level].tmp1)) return false;
279  }
280 
281  //resize results array
282  CCopasiArray::index_type resultindex; resultindex = mLocalData[level].tmp1.size();
283 
284  if (mLocalData[level].variables.size() > 1)
285  resultindex.push_back(mLocalData[level].variables.size());
286 
287  result.resize(resultindex);
288 
289  //loop over all variables
290  size_t i, imax = mLocalData[level].variables.size();
291 
292  for (i = 0; i < imax; ++i)
293  {
294  //store variable value
295  C_FLOAT64 store = *(C_FLOAT64 *)mLocalData[level].variables[i]->getValuePointer();
296 
297  //change variable
298  C_FLOAT64 delta = do_variation(mLocalData[level].variables[i]);
299 
300  //do second calculation
301  if (level == 0)
302  {
303  if (!do_target_calculation(mLocalData[level].tmp2, false)) return false;
304  }
305  else
306  {
307  if (!calculate_one_level(level - 1, mLocalData[level].tmp2)) return false;
308  }
309 
310  //restore variable
311  //mLocalData[level].variables[i]->setObjectValue(store);
312  setValue(mLocalData[level].variables[i], store);
313 
314  //calculate derivative
315  if (imax > 1)
316  resultindex[resultindex.size() - 1] = i;
317 
318  calculate_difference(level, delta, result, resultindex);
319  }
320 
321  return true;
322 }
void calculate_difference(size_t level, const C_FLOAT64 &delta, CCopasiArray &result, CCopasiArray::index_type &resultindex)
void resize(const index_type &sizes)
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
virtual void * getValuePointer() const
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
C_FLOAT64 do_variation(CCopasiObject *variable)
bool do_target_calculation(CCopasiArray &result, bool first)
void setValue(CCopasiObject *variable, C_FLOAT64 value)
#define C_FLOAT64
Definition: copasi.h:92
bool calculate_one_level(size_t level, CCopasiArray &result)
CSensMethod * CSensMethod::createMethod ( CCopasiMethod::SubType  subType = CCopasiMethod::sensMethod)
static

Create a trajectory method. Note: the returned object has to be released after use with delete

CSensMethod class.

Definition at line 34 of file CSensMethod.cpp.

References CSensMethod(), fatalError, CCopasiMethod::sensMethod, and CCopasiMethod::unset.

Referenced by SensitivitiesWidget::createMethod(), and CSensTask::createMethod().

35 {
36  CSensMethod * pMethod = NULL;
37 
38  switch (subType)
39  {
40  case unset:
41  case sensMethod:
42  pMethod = new CSensMethod(subType);
43  break;
44 
45  default:
46  fatalError();
47  }
48 
49  return pMethod;
50 }
#define fatalError()
void CSensMethod::do_collapsing ( )
protected

collapse the first dimension of the scaled result (by calculating the 2-norm over the target functions)

Definition at line 437 of file CSensMethod.cpp.

References C_INVALID_INDEX, CSensProblem::collapsRequested(), do_collapsing_innerloop(), CSensProblem::getCollapsedResult(), CSensProblem::getScaledResult(), mpProblem, and CCopasiArray::size().

Referenced by process().

438 {
440  {
442  CCopasiArray::index_type collapsedresultindex = mpProblem->getCollapsedResult().size();
443 
444  size_t shift = fullresultindex.size() - collapsedresultindex.size();
445 
446  if (shift != 1) return; //only supported if target functions list is 1D
447 
448  //***** skalar ********
449  if (collapsedresultindex.size() == 0)
450  {
451  mpProblem->getCollapsedResult()[collapsedresultindex] =
452  do_collapsing_innerloop(fullresultindex);
453  return;
454  }
455 
456  //***** higher dimensions *********
457  size_t i, dim = collapsedresultindex.size();
459 
460  //set index to zero
461  for (i = 0; i < dim; ++i) collapsedresultindex[i] = 0;
462 
463  for (;;)
464  {
465  fullresultindex[0] = 0;
466 
467  for (i = 0; i < dim; ++i)
468  fullresultindex[i + shift] = collapsedresultindex[i];
469 
470  mpProblem->getCollapsedResult()[collapsedresultindex] =
471  do_collapsing_innerloop(fullresultindex);
472 
473  //increase index
474  ++collapsedresultindex[dim - 1];
475 
476  //check overflow
477  size_t j;
478 
479  for (j = dim - 1; j != C_INVALID_INDEX; --j)
480  {
481  if (collapsedresultindex[j] >= indexmax[j])
482  {
483  collapsedresultindex[j] = 0;
484 
485  if (j > 0)
486  ++collapsedresultindex[j - 1];
487  else
488  return;
489  }
490  else
491  break;
492  }
493  }
494  }
495  else
496  {}
497 }
bool collapsRequested() const
#define C_INVALID_INDEX
Definition: copasi.h:222
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
CSensProblem * mpProblem
Definition: CSensMethod.h:168
CCopasiArray & getCollapsedResult()
CCopasiArray & getScaledResult()
C_FLOAT64 do_collapsing_innerloop(CCopasiArray::index_type &fullindex)
const index_type & size() const
Definition: CCopasiArray.h:76
C_FLOAT64 CSensMethod::do_collapsing_innerloop ( CCopasiArray::index_type fullindex)
protected

Definition at line 413 of file CSensMethod.cpp.

References C_FLOAT64, CSensProblem::getScaledResult(), max, mpProblem, and CCopasiArray::size().

Referenced by do_collapsing().

414 {
415  //fullindex[0]=0;
416  //return mpProblem->getScaledResult()[fullindex];
417 
418  //assumes the sum is to be taken over the first dim of the scaled result array
419  C_FLOAT64 tmpFloat, tmpSum = 0;
420  size_t i, imax = mpProblem->getScaledResult().size()[0];
421 
422  for (i = 0; i < imax; ++i)
423  {
424  fullindex[0] = i;
425  tmpFloat = mpProblem->getScaledResult()[fullindex];
426 
427  if (tmpFloat != tmpFloat) continue;
428 
429  if (fabs(tmpFloat) >= std::numeric_limits< C_FLOAT64 >::max()) continue;
430 
431  tmpSum += tmpFloat * tmpFloat;
432  }
433 
434  return sqrt(tmpSum);
435 }
CSensProblem * mpProblem
Definition: CSensMethod.h:168
CCopasiArray & getScaledResult()
#define C_FLOAT64
Definition: copasi.h:92
const index_type & size() const
Definition: CCopasiArray.h:76
#define max(a, b)
Definition: f2c.h:176
void CSensMethod::do_scaling ( )
protected

calculate the scaled sensitivities. Calls scaling_variables(). It is assumed that the scaled result array is already of the correct size (this is done in initialize()).

Definition at line 404 of file CSensMethod.cpp.

References CCopasiArray::dimensionality(), CSensProblem::getResult(), mLocalData, mpProblem, and scaling_variables().

Referenced by process().

405 {
407  index.resize(mpProblem->getResult().dimensionality());
408  scaling_variables(mLocalData.size() - 1, 1.0, index);
409 }
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
void scaling_variables(size_t level, const C_FLOAT64 &factor, CCopasiArray::index_type &resultindex)
CCopasiArray & getResult()
CSensProblem * mpProblem
Definition: CSensMethod.h:168
size_t dimensionality() const
Definition: CCopasiArray.h:79
bool CSensMethod::do_target_calculation ( CCopasiArray result,
bool  first 
)
protected

Definition at line 111 of file CSensMethod.cpp.

References C_FLOAT64, CCopasiProblem::getModel(), CCopasiParameter::getValuePointer(), mCounter, mFailedCounter, mInitialRefreshes, CCopasiMethod::mpCallBack, mpProblem, mProgress, mProgressHandler, mpSubTask, mTargetfunctionPointers, CCopasiTask::process(), CProcessReport::progressItem(), CCopasiArray::resize(), CModel::updateNonSimulatedValues(), and CModel::updateSimulatedValues().

Referenced by calculate_one_level().

112 {
113  bool success = false;
114 
115  //perform the necessary updates
116  std::vector< Refresh * >::iterator it = mInitialRefreshes.begin();
117  std::vector< Refresh * >::iterator end = mInitialRefreshes.end();
118 
119  while (it != end)
120  (**it++)();
121 
122  //****** do subtask ******************
123  if (mpSubTask != NULL)
124  {
125  success = mpSubTask->process(/*first*/true);
126  mCounter++;
127  }
128  else
129  {
130  success = true; // doing nothing should never fail.
131  }
132 
135 
136  //****** retrieve results ************
137 
138  //resize results array
139  CCopasiArray::index_type resultindex;
140  size_t i, imax = mTargetfunctionPointers.size();
141 
142  if (imax > 1)
143  resultindex.push_back(imax);
144 
145  result.resize(resultindex);
146 
147  //copy result
148  if (success)
149  {
150  for (i = 0; i < imax; ++i)
151  {
152  if (imax > 1)
153  resultindex[0] = i;
154 
155  result[resultindex] = *(C_FLOAT64 *)mTargetfunctionPointers[i]->getValuePointer();
156  }
157  }
158  else
159  {
160  mFailedCounter++;
161 
162  for (i = 0; i < imax; ++i)
163  {
164  if (imax > 1)
165  resultindex[0] = i;
166 
167  result[resultindex] = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
168  }
169  }
170 
171  //progress bar
172  ++mProgress;
173 
174  if (mpCallBack)
175  {
177  return tmp;
178  }
179 
180  return success;
181 }
void resize(const index_type &sizes)
std::vector< CCopasiObject * > mTargetfunctionPointers
Definition: CSensMethod.h:172
void updateNonSimulatedValues(void)
Definition: CModel.cpp:1892
void updateSimulatedValues(const bool &updateMoieties)
Definition: CModel.cpp:1851
virtual void * getValuePointer() const
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
virtual bool progressItem(const size_t &handle)
size_t mFailedCounter
Definition: CSensMethod.h:189
size_t mProgressHandler
Definition: CSensMethod.h:185
CSensProblem * mpProblem
Definition: CSensMethod.h:168
virtual bool process(const bool &useInitialValues)
std::vector< Refresh * > mInitialRefreshes
Definition: CSensMethod.h:176
#define C_FLOAT64
Definition: copasi.h:92
size_t mCounter
Definition: CSensMethod.h:188
CProcessReport * mpCallBack
CModel * getModel() const
CCopasiTask * mpSubTask
Definition: CSensMethod.h:174
unsigned C_INT32 mProgress
Definition: CSensMethod.h:186
C_FLOAT64 CSensMethod::do_variation ( CCopasiObject variable)
protected

Definition at line 183 of file CSensMethod.cpp.

References C_FLOAT64, CCopasiObject::getValuePointer(), mpDeltaFactor, mpMinDelta, and setValue().

Referenced by calculate_one_level().

184 {
185  C_FLOAT64 value;
186  value = *(C_FLOAT64*)variable->getValuePointer();
187  C_FLOAT64 delta;
188  delta = fabs(value) * *mpDeltaFactor;
189 
190  if (delta < *mpMinDelta) delta = *mpMinDelta;
191 
192  setValue(variable, delta + value);
193 
194  return delta;
195 }
C_FLOAT64 * mpDeltaFactor
Definition: CSensMethod.h:178
void setValue(CCopasiObject *variable, C_FLOAT64 value)
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 * mpMinDelta
Definition: CSensMethod.h:179
virtual void * getValuePointer() const
size_t CSensMethod::getNumberOfSubtaskCalculations ( )

estimate how many calls to the subtask are necessary. Works only after initialize() was called.

Definition at line 686 of file CSensMethod.cpp.

References mLocalData.

Referenced by process().

687 {
688  size_t ret = 1;
689  size_t i;
690 
691  for (i = 0; i < mLocalData.size(); ++i)
692  {
693  ret *= mLocalData[i].variables.size() + 1;
694  }
695 
696  return ret;
697 }
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
bool CSensMethod::initialize ( CSensProblem problem)

initializes the subtask, creates the internal data structures of the method, resizes the result arrays and creates the array annotations

Definition at line 501 of file CSensMethod.cpp.

References CModel::buildInitialRefreshSequence(), C_INVALID_INDEX, CSensProblem::collapsRequested(), CSensProblem::CrossSection, CSensProblem::Evaluation, CCopasiParameter::getCN(), CSensProblem::getCollapsedResult(), CSensProblem::getCollapsedResultAnnotated(), CSensItem::getListTypeDisplayName(), CCopasiProblem::getModel(), CSensProblem::getNumberOfVariables(), CCopasiObject::getObjectDataModel(), CCopasiTask::getProblem(), CSensProblem::getResult(), CSensProblem::getResultAnnotated(), CSensProblem::getScaledResult(), CSensProblem::getScaledResultAnnotated(), CSensProblem::getSubTaskType(), CSensProblem::getTargetFunctions(), CCopasiDataModel::getTaskList(), CSensProblem::getVariables(), CSensItem::getVariablesPointerList(), CCopasiTask::initialize(), CCopasiTask::isUpdateModel(), mInitialRefreshes, mLocalData, mpProblem, mpSubTask, mStoreSubtasktUpdateFlag, mTargetfunctionPointers, CCopasiTask::NO_OUTPUT, CSensProblem::Optimization, CSensProblem::ParameterEstimation, CCopasiArray::resize(), CArrayAnnotation::resize(), CArrayAnnotation::setAnnotationCN(), CCopasiTask::setCallBack(), CArrayAnnotation::setDimensionDescription(), CCopasiProblem::setModel(), CCopasiTask::setUpdateModel(), CSensProblem::SteadyState, and CSensProblem::TimeSeries.

Referenced by CSensTask::updateMatrices().

502 {
503  bool success = true;
504 
505  mpProblem = problem;
506  assert(mpProblem);
507 
508  //initialize the target calculation
509  mpSubTask = NULL;
510  CCopasiDataModel* pDataModel = getObjectDataModel();
511  assert(pDataModel != NULL);
512 
513  switch (mpProblem->getSubTaskType())
514  {
516  mpSubTask = NULL;
517  break;
518 
520  mpSubTask = dynamic_cast<CCopasiTask*>
521  ((*pDataModel->getTaskList())["Steady-State"]);
522  break;
523 
525  mpSubTask = dynamic_cast<CCopasiTask*>
526  ((*pDataModel->getTaskList())["Time-Course"]);
527  break;
528 
529  /* case CSensProblem::LyapunovExp:
530  mpSubTask = dynamic_cast<CCopasiTask*>
531  ((*pDataModel->getTaskList())["Lyapunov Exponents"]);
532  break;*/
533 
535  mpSubTask = dynamic_cast<CCopasiTask*>
536  ((*pDataModel->getTaskList())["Parameter Estimation"]);
537  break;
538 
540  mpSubTask = dynamic_cast<CCopasiTask*>
541  ((*pDataModel->getTaskList())["Optimization"]);
542  break;
543 
545  mpSubTask = dynamic_cast<CCopasiTask*>
546  ((*pDataModel->getTaskList())["Cross Section"]);
547  break;
548  }
549 
550  if (mpSubTask)
551  {
552  //the subtask should not change the initial state of the model
554  mpSubTask->setUpdateModel(false);
555 
557  mpSubTask->setCallBack(NULL);
558  success &= mpSubTask->initialize(CCopasiTask::NO_OUTPUT, NULL, NULL);
559  }
560 
561  //initialize the variables pointers
562  std::set< const CCopasiObject * > ObjectSet;
563  size_t i, imax = mpProblem->getNumberOfVariables();
564  mLocalData.resize(imax);
565 
566  for (i = 0; i < imax; ++i)
567  {
568  mLocalData[i].variables = mpProblem->getVariables(i).getVariablesPointerList(pDataModel);
569 
570  ObjectSet.insert(mLocalData[i].variables.begin(), mLocalData[i].variables.end());
571  }
572 
573  //determine which refreshes need to be called when the variables are changed
574  ObjectSet.erase(NULL);
575  mInitialRefreshes.clear();
577 
578  //initialize the target function pointers
580 
581  //****** initialize result annotations ****************
582 
583  //determine dimensions of result
585  CCopasiArray::index_type sc; //size of collapsed result
586 
587  if (mTargetfunctionPointers.size() > 1)
588  {
589  s.push_back(mTargetfunctionPointers.size());
590  }
591 
592  for (i = 0; i < imax; ++i)
593  {
594  if (mLocalData[i].variables.size() > 1)
595  {
596  mLocalData[i].index = s.size();
597  s.push_back(mLocalData[i].variables.size());
598  sc.push_back(mLocalData[i].variables.size());
599  }
600  else
601  mLocalData[i].index = C_INVALID_INDEX;
602  }
603 
604  //resize result & annotations
605  mpProblem->getResult().resize(s);
607  //mpProblem->getResultAnnotated()->setMode(CArrayAnnotation::OBJECTS);
608 
611  //mpProblem->getScaledResultAnnotated()->setMode(CArrayAnnotation::OBJECTS);
612 
614  {
617  //mpProblem->getCollapsedResultAnnotated()->setMode(CArrayAnnotation::OBJECTS);
618  }
619 
620  size_t dim = 0;
621  size_t j;
622 
623  //target function annotations //TODO: only implemented for scalar and vector
624  if (mTargetfunctionPointers.size() > 1)
625  {
626  std::ostringstream tmp;
627  tmp << "Target functions, " << mpProblem->getTargetFunctions().getListTypeDisplayName();
630 
631  for (j = 0; j < mTargetfunctionPointers.size(); ++j)
632  {
635  }
636 
637  ++dim;
638  }
639 
640  //variables annotiation
641  size_t dim2 = 0; //for collapsed result
642 
643  for (i = 0; i < imax; ++i)
644  {
645  if (mLocalData[i].variables.size() > 1)
646  {
647  std::ostringstream tmp;
648  tmp << "Variables " << i + 1 << ", " << mpProblem->getVariables(i).getListTypeDisplayName();
651 
654 
655  for (j = 0; j < mLocalData[i].variables.size(); ++j)
656  {
657  mpProblem->getResultAnnotated()->setAnnotationCN(dim, j, mLocalData[i].variables[j]->getCN());
658  mpProblem->getScaledResultAnnotated()->setAnnotationCN(dim, j, mLocalData[i].variables[j]->getCN());
659 
661  mpProblem->getCollapsedResultAnnotated()->setAnnotationCN(dim2, j, mLocalData[i].variables[j]->getCN());
662  }
663 
664  ++dim;
665  ++dim2;
666  }
667  }
668 
669  return success;
670 }
CCopasiDataModel * getObjectDataModel()
virtual bool setCallBack(CProcessReport *pCallBack)
std::string getListTypeDisplayName() const
void resize(const index_type &sizes)
bool collapsRequested() const
size_t getNumberOfVariables() const
CCopasiProblem * getProblem()
CSensItem getVariables(size_t index) const
std::vector< CCopasiObject * > mTargetfunctionPointers
Definition: CSensMethod.h:172
virtual bool initialize(const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
const bool & isUpdateModel() const
void setAnnotationCN(size_t d, size_t i, const std::string cn)
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
CSensProblem::SubTaskType getSubTaskType() const
CArrayAnnotation * getCollapsedResultAnnotated()
#define C_INVALID_INDEX
Definition: copasi.h:222
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
std::vector< CCopasiObject * > getVariablesPointerList(CCopasiDataModel *pDataModel)
CArrayAnnotation * getScaledResultAnnotated()
CCopasiArray & getResult()
virtual bool setModel(CModel *pModel)
CSensItem getTargetFunctions() const
CSensProblem * mpProblem
Definition: CSensMethod.h:168
CArrayAnnotation * getResultAnnotated()
CCopasiArray & getCollapsedResult()
CCopasiVectorN< CCopasiTask > * getTaskList()
CCopasiArray & getScaledResult()
std::set< const CObjectInterface * > ObjectSet
void setDimensionDescription(size_t d, const std::string &s)
virtual CCopasiObjectName getCN() const
std::vector< Refresh * > mInitialRefreshes
Definition: CSensMethod.h:176
bool mStoreSubtasktUpdateFlag
stores the update model flag of the subtask
Definition: CSensMethod.h:182
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
void setUpdateModel(const bool &updateModel)
CModel * getModel() const
CCopasiTask * mpSubTask
Definition: CSensMethod.h:174
bool CSensMethod::isValidProblem ( const CCopasiProblem pProblem)
virtual

Check if the method is suitable for this problem

Returns
bool suitability of the method

Reimplemented from CCopasiMethod.

Definition at line 738 of file CSensMethod.cpp.

References CCopasiMessage::EXCEPTION, and CCopasiMethod::isValidProblem().

739 {
740  if (!CCopasiMethod::isValidProblem(pProblem)) return false;
741 
742  const CSensProblem * pP = dynamic_cast<const CSensProblem *>(pProblem);
743 
744  if (!pP)
745  {
746  CCopasiMessage(CCopasiMessage::EXCEPTION, "Problem is not a sensitivities problem.");
747  return false;
748  }
749 
750  return true;
751 
752  //all sizes at least one
753 
754  //dimension of variables 0 or 1
755 
756  //if target is scan make sure the scan subtask is not sens.
757 }
virtual bool isValidProblem(const CCopasiProblem *pProblem)
bool CSensMethod::process ( CProcessReport handler)

Definition at line 699 of file CSensMethod.cpp.

References CProcessReport::addItem(), C_INT32, calculate_one_level(), do_collapsing(), do_scaling(), CProcessReport::finishItem(), getNumberOfSubtaskCalculations(), CSensProblem::getResult(), max, MCCopasiTask, mCounter, mFailedCounter, mLocalData, CCopasiMethod::mpCallBack, mpProblem, mProgress, mProgressHandler, mpSubTask, CCopasiTask::setCallBack(), CProcessReport::setName(), and CCopasiMessage::WARNING.

Referenced by CSensTask::process().

700 {
701  // Reset the evaluation counter
702  mCounter = 0;
703  mFailedCounter = 0;
704 
705  if (!mLocalData.size()) return false;
706 
707  //initialize progress bar
708  mpCallBack = handler;
709 
710  if (mpCallBack)
711  {
712  mpCallBack->setName("performing sensitivities calculation...");
713  unsigned C_INT32 max = (unsigned C_INT32) getNumberOfSubtaskCalculations();
714  mProgress = 0;
715  mProgressHandler = mpCallBack->addItem("Completion",
716  mProgress,
717  &max);
718 
719  if (mpSubTask)
721  }
722 
723  if (!calculate_one_level(mLocalData.size() - 1, mpProblem->getResult())) return false;
724 
725  do_scaling();
726 
727  do_collapsing();
728 
730 
731  if (mFailedCounter * 20 > mCounter) // > 5% failure rate
733 
734  return true;
735 }
virtual bool setCallBack(CProcessReport *pCallBack)
void do_scaling()
virtual bool setName(const std::string &name)
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
#define C_INT32
Definition: copasi.h:90
CCopasiArray & getResult()
size_t mFailedCounter
Definition: CSensMethod.h:189
#define MCCopasiTask
size_t mProgressHandler
Definition: CSensMethod.h:185
void do_collapsing()
CSensProblem * mpProblem
Definition: CSensMethod.h:168
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
virtual bool finishItem(const size_t &handle)
size_t getNumberOfSubtaskCalculations()
size_t mCounter
Definition: CSensMethod.h:188
CProcessReport * mpCallBack
CCopasiTask * mpSubTask
Definition: CSensMethod.h:174
unsigned C_INT32 mProgress
Definition: CSensMethod.h:186
bool calculate_one_level(size_t level, CCopasiArray &result)
#define max(a, b)
Definition: f2c.h:176
bool CSensMethod::restore ( const bool &  updateModel)

Do all necessary restore procedures so that the model is in the same state as before

Parameters
constbool & updateModel
Returns
bool success

Definition at line 672 of file CSensMethod.cpp.

References mpSubTask, mStoreSubtasktUpdateFlag, CCopasiTask::restore(), and CCopasiTask::setUpdateModel().

Referenced by CSensTask::restore().

673 {
674  bool success = true;
675 
676  if (mpSubTask != NULL)
677  {
678  success &= mpSubTask->restore();
679 
680  //restore the update model flag
682  }
683  return success;
684 }
bool mStoreSubtasktUpdateFlag
stores the update model flag of the subtask
Definition: CSensMethod.h:182
virtual bool restore()
void setUpdateModel(const bool &updateModel)
CCopasiTask * mpSubTask
Definition: CSensMethod.h:174
void CSensMethod::scaling_targetfunction ( const C_FLOAT64 factor,
CCopasiArray::index_type resultindex 
)
protected

This contains the loop over the target functions for scaling the sensitivities

Definition at line 326 of file CSensMethod.cpp.

References C_INVALID_INDEX, CSensProblem::getResult(), CSensProblem::getScaledResult(), mLocalData, and mpProblem.

Referenced by scaling_variables().

328 {
329  size_t dim = mLocalData[0].tmp1.dimensionality();
330  assert(resultindex.size() >= dim);
331 
332  CCopasiArray::index_type indexmax = mLocalData[0].tmp1.size();
333  //init index with zero
334  CCopasiArray::index_type indexit; indexit.resize(dim);
335  size_t i;
336 
337  for (i = 0; i < dim; ++i)
338  indexit[i] = 0;
339 
340  //handle scalars separately
341  if (dim == 0)
342  {
343  mpProblem->getScaledResult()[resultindex] = mpProblem->getResult()[resultindex] * factor / mLocalData[0].tmp1[indexit];
344  return;
345  }
346 
347  //now for all higher dimensionalities
348  for (;;)
349  {
350  for (i = 0; i < dim; ++i)
351  resultindex[i] = indexit[i]; //TODO: use stl algorithm
352 
353  mpProblem->getScaledResult()[resultindex] = mpProblem->getResult()[resultindex] * factor / mLocalData[0].tmp1[indexit];
354 
355  //increase index
356  ++indexit[dim - 1];
357 
358  //check overflow
359  size_t j;
360 
361  for (j = dim - 1; j != C_INVALID_INDEX; --j)
362  {
363  if (indexit[j] >= indexmax[j])
364  {
365  indexit[j] = 0;
366 
367  if (j > 0)
368  ++indexit[j - 1];
369  else
370  return;
371  }
372  else
373  break;
374  }
375  }
376 }
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
#define C_INVALID_INDEX
Definition: copasi.h:222
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
CCopasiArray & getResult()
CSensProblem * mpProblem
Definition: CSensMethod.h:168
CCopasiArray & getScaledResult()
void CSensMethod::scaling_variables ( size_t  level,
const C_FLOAT64 factor,
CCopasiArray::index_type resultindex 
)
protected

This contains the loop over the variables for scaling the sensitivities. Works recursively and calls scaling_targetfunction() in the end.

Definition at line 378 of file CSensMethod.cpp.

References C_FLOAT64, CCopasiParameter::getValuePointer(), mLocalData, and scaling_targetfunction().

Referenced by do_scaling().

380 {
381  //loop over all variables
382  size_t i, imax = mLocalData[level].variables.size();
383 
384  for (i = 0; i < imax; ++i)
385  {
386  //get Value
387  C_FLOAT64 value = *(C_FLOAT64 *)mLocalData[level].variables[i]->getValuePointer() * factor;
388 
389  //do recursive calculation
390  if (imax > 1)
391  resultindex[mLocalData[level].index] = i;
392 
393  if (level == 0)
394  {
395  scaling_targetfunction(value, resultindex);
396  }
397  else
398  {
399  scaling_variables(level - 1, value, resultindex);
400  }
401  }
402 }
void scaling_targetfunction(const C_FLOAT64 &factor, CCopasiArray::index_type &resultindex)
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
virtual void * getValuePointer() const
void scaling_variables(size_t level, const C_FLOAT64 &factor, CCopasiArray::index_type &resultindex)
#define C_FLOAT64
Definition: copasi.h:92
void CSensMethod::setValue ( CCopasiObject variable,
C_FLOAT64  value 
)
protected

wraps the CCopasiObject::setObjectValue() method so we can add special treatment of concentrations

Definition at line 197 of file CSensMethod.cpp.

References CCopasiObject::getObjectAncestor(), CCopasiObject::getObjectName(), CMetab::refreshNumber(), CMetab::setConcentration(), and CCopasiObject::setObjectValue().

Referenced by calculate_one_level(), and do_variation().

198 {
199  variable->setObjectValue(value);
200 
201  if (variable->getObjectName() == "Concentration")
202  {
203  CMetab* pMetab = dynamic_cast<CMetab*>(variable->getObjectAncestor("Metabolite"));
204 
205  if (pMetab)
206  {
207  pMetab->setConcentration(value);
208  pMetab->refreshNumber();
209  }
210  }
211 }
CCopasiContainer * getObjectAncestor(const std::string &type) const
void setObjectValue(const C_FLOAT64 &value)
const std::string & getObjectName() const
Definition: CMetab.h:178
void refreshNumber()
Definition: CMetab.cpp:286
void setConcentration(const C_FLOAT64 concentration)
Definition: CMetab.cpp:250

Member Data Documentation

size_t CSensMethod::mCounter
private

Definition at line 188 of file CSensMethod.h.

Referenced by do_target_calculation(), and process().

size_t CSensMethod::mFailedCounter
private

Definition at line 189 of file CSensMethod.h.

Referenced by do_target_calculation(), and process().

std::vector< Refresh * > CSensMethod::mInitialRefreshes
protected

Definition at line 176 of file CSensMethod.h.

Referenced by do_target_calculation(), and initialize().

std::vector<CSensMethodLocalData> CSensMethod::mLocalData
protected
C_FLOAT64* CSensMethod::mpDeltaFactor
protected

Definition at line 178 of file CSensMethod.h.

Referenced by CSensMethod(), and do_variation().

C_FLOAT64* CSensMethod::mpMinDelta
protected

Definition at line 179 of file CSensMethod.h.

Referenced by CSensMethod(), and do_variation().

CSensProblem* CSensMethod::mpProblem
protected

A pointer to the sensitivities problem.

Definition at line 168 of file CSensMethod.h.

Referenced by do_collapsing(), do_collapsing_innerloop(), do_scaling(), do_target_calculation(), initialize(), process(), and scaling_targetfunction().

unsigned C_INT32 CSensMethod::mProgress
private

Definition at line 186 of file CSensMethod.h.

Referenced by do_target_calculation(), and process().

size_t CSensMethod::mProgressHandler
private

Definition at line 185 of file CSensMethod.h.

Referenced by do_target_calculation(), and process().

CCopasiTask* CSensMethod::mpSubTask
protected

Definition at line 174 of file CSensMethod.h.

Referenced by do_target_calculation(), initialize(), process(), and restore().

bool CSensMethod::mStoreSubtasktUpdateFlag
protected

stores the update model flag of the subtask

Definition at line 182 of file CSensMethod.h.

Referenced by initialize(), and restore().

std::vector<CCopasiObject*> CSensMethod::mTargetfunctionPointers
protected

Definition at line 172 of file CSensMethod.h.

Referenced by do_target_calculation(), and initialize().


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