COPASI API  4.16.103
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
CEFMAlgorithm Class Reference

#include <CEFMAlgorithm.h>

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

Classes

class  CSpeciesOrderNode
 

Public Member Functions

virtual bool calculate ()
 
void calculateFluxModes ()
 
 CEFMAlgorithm (const CEFMAlgorithm &src, const CCopasiContainer *pParent=NULL)
 
virtual bool initialize ()
 
 ~CEFMAlgorithm ()
 
- Public Member Functions inherited from CEFMMethod
 CEFMMethod (const CEFMMethod &src, const CCopasiContainer *pParent=NULL)
 
virtual bool isValidProblem (const CCopasiProblem *pProblem)
 
virtual ~CEFMMethod ()
 
- 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 ()
 

Protected Member Functions

 CEFMAlgorithm (const CCopasiContainer *pParent=NULL)
 
 CEFMAlgorithm (const CCopasiMethod::SubType subType, const CCopasiContainer *pParent=NULL)
 
- Protected Member Functions inherited from CEFMMethod
 CEFMMethod (const CCopasiTask::Type &taskType, const SubType &subType, const CCopasiContainer *pParent=NULL)
 
- 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

size_t mhSteps
 
std::vector< size_t > mIndexSet
 
unsigned C_INT32 mMaxStep
 
CTableauMatrixmpCurrentTableau
 
CModelmpModel
 
CTableauMatrixmpNextTableau
 
size_t mReversible
 
unsigned C_INT32 mStep
 
unsigned C_INT32 mStepProcess
 
std::vector< std::vector
< C_FLOAT64 > > 
mStoi
 
- Protected Attributes inherited from CEFMMethod
std::vector< CFluxMode > * mpFluxModes
 
std::vector< const CReaction * > * mpReorderedReactions
 
- 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

void buildFluxModes ()
 
double calculateCombinations (size_t index)
 
void calculateNextTableau ()
 
bool findMinimalCombinationIndex ()
 
void initObjects ()
 

Friends

CEFMMethodCEFMMethod::createMethod (CCopasiMethod::SubType subType)
 

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 Member Functions inherited from CEFMMethod
static CEFMMethodcreateMethod (CCopasiMethod::SubType subType=CCopasiMethod::EFMAlgorithm)
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from 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 39 of file CEFMAlgorithm.h.

Constructor & Destructor Documentation

CEFMAlgorithm::CEFMAlgorithm ( const CCopasiContainer pParent = NULL)
protected

Default constructor

Parameters
constCCopasiContainer * pParent (Default: NULL)

Definition at line 73 of file CEFMAlgorithm.cpp.

References initObjects().

73  :
75  mpModel(NULL),
76  mStoi(),
77  mReversible(0),
78  mpCurrentTableau(NULL),
79  mpNextTableau(NULL),
80  mIndexSet()
81 {initObjects();}
std::vector< std::vector< C_FLOAT64 > > mStoi
CTableauMatrix * mpNextTableau
std::vector< size_t > mIndexSet
CTableauMatrix * mpCurrentTableau
CModel * mpModel
size_t mReversible
CEFMAlgorithm::CEFMAlgorithm ( const CCopasiMethod::SubType  subType,
const CCopasiContainer pParent = NULL 
)
protected

Constructor to be called by derived methods

Parameters
constCCopasiMethod::SubType subType
constCCopasiContainer * pParent (Default: NULL)

Definition at line 83 of file CEFMAlgorithm.cpp.

References initObjects().

83  :
84  CEFMMethod(CCopasiTask::fluxMode, subType, pParent),
85  mpModel(NULL),
86  mStoi(),
87  mReversible(0),
88  mpCurrentTableau(NULL),
89  mpNextTableau(NULL),
90  mIndexSet()
91 {initObjects();}
std::vector< std::vector< C_FLOAT64 > > mStoi
CTableauMatrix * mpNextTableau
std::vector< size_t > mIndexSet
CTableauMatrix * mpCurrentTableau
CModel * mpModel
size_t mReversible
CEFMAlgorithm::CEFMAlgorithm ( const CEFMAlgorithm src,
const CCopasiContainer pParent = NULL 
)

Copy Constructor

Parameters
constCEFMAlgorithm & src

Definition at line 93 of file CEFMAlgorithm.cpp.

References initObjects().

94  :
95  CEFMMethod(src, pParent),
96  mpModel(NULL),
97  mStoi(),
98  mReversible(0),
99  mpCurrentTableau(NULL),
100  mpNextTableau(NULL),
101  mIndexSet()
102 {initObjects();}
std::vector< std::vector< C_FLOAT64 > > mStoi
CTableauMatrix * mpNextTableau
std::vector< size_t > mIndexSet
CTableauMatrix * mpCurrentTableau
CModel * mpModel
size_t mReversible
CEFMAlgorithm::~CEFMAlgorithm ( )

Destructor

Definition at line 104 of file CEFMAlgorithm.cpp.

References DESTRUCTOR_TRACE, mpCurrentTableau, mpNextTableau, and pdelete.

105 {
109 }
#define pdelete(p)
Definition: copasi.h:215
CTableauMatrix * mpNextTableau
#define DESTRUCTOR_TRACE
Definition: copasi.h:206
CTableauMatrix * mpCurrentTableau

Member Function Documentation

void CEFMAlgorithm::buildFluxModes ( )
private

Construct the flux modes

Definition at line 376 of file CEFMAlgorithm.cpp.

References CTableauMatrix::begin(), CTableauMatrix::end(), mpCurrentTableau, and CEFMMethod::mpFluxModes.

Referenced by calculateFluxModes().

377 {
378  mpFluxModes->clear();
379 
380  std::list< const CTableauLine * >::iterator a = mpCurrentTableau->begin();
381  std::list< const CTableauLine * >::iterator end = mpCurrentTableau->end();
382 
383  while (a != end)
384  {
385  mpFluxModes->push_back(CFluxMode(*a));
386  a++;
387  }
388 }
std::list< const CTableauLine * >::iterator begin()
std::vector< CFluxMode > * mpFluxModes
Definition: CEFMMethod.h:91
std::list< const CTableauLine * >::iterator end()
CTableauMatrix * mpCurrentTableau
bool CEFMAlgorithm::calculate ( void  )
virtual

Execute the optimization algorithm calling simulation routine when needed. It is noted that this procedure can give feedback of its progress by the callback function set with SetCallback. @ return success;

Reimplemented from CEFMMethod.

Reimplemented in CSSAMethod.

Definition at line 195 of file CEFMAlgorithm.cpp.

References calculateFluxModes(), CProcessReport::finishItem(), initialize(), mhSteps, and CCopasiMethod::mpCallBack.

196 {
197  if (!initialize())
198  {
199  if (mpCallBack)
201 
202  return false;
203  }
204 
206 
207  return true;
208 }
void calculateFluxModes()
virtual bool initialize()
virtual bool finishItem(const size_t &handle)
CProcessReport * mpCallBack
double CEFMAlgorithm::calculateCombinations ( size_t  index)
private

Calculate number of combinations for an index

Definition at line 426 of file CEFMAlgorithm.cpp.

References CTableauMatrix::begin(), CTableauMatrix::end(), and mpCurrentTableau.

Referenced by findMinimalCombinationIndex().

427 {
428  double posIrr = 0;
429  double negIrr = 0;
430  double rev = 0;
431 
432  //Reversible reactions
433  std::list< const CTableauLine * >::const_iterator it = mpCurrentTableau->begin();
434  std::list< const CTableauLine * >::const_iterator end = mpCurrentTableau->end();
435 
436  for (; it != end; ++it)
437  {
438  if ((*it)->isReversible() && (*it)->getMultiplier(index) != 0.0)
439  {
440  rev++;
441  }
442  else if ((*it)->getMultiplier(index) < 0.0)
443  {
444  negIrr++;
445  }
446  else if ((*it)->getMultiplier(index) > 0.0)
447  {
448  posIrr++;
449  }
450  }
451 
452  return (posIrr + rev) * (negIrr + rev);
453 }
std::list< const CTableauLine * >::iterator begin()
std::list< const CTableauLine * >::iterator end()
CTableauMatrix * mpCurrentTableau
void CEFMAlgorithm::calculateFluxModes ( )

Do the actual calculation

Definition at line 210 of file CEFMAlgorithm.cpp.

References buildFluxModes(), calculateNextTableau(), COutputInterface::DURING, findMinimalCombinationIndex(), CProcessReport::finishItem(), CCopasiObject::getObjectParent(), mhSteps, mIndexSet, mMaxStep, CCopasiMethod::mpCallBack, mpCurrentTableau, mReversible, mStep, mStepProcess, mStoi, pdelete, and CProcessReport::progressItem().

Referenced by CSSAMethod::buildExtremeCurrents(), and calculate().

211 {
212  bool Continue = true;
213 
214  if (mStoi.size())
215  {
216  /* initialize the current tableau matrix */
219 
220  /* Do the iteration */
221  mIndexSet.resize(mMaxStep);
222 
223  for (mStep = 0; mStep < mMaxStep; mStep++)
224  mIndexSet[mStep] = mStep;
225 
226  while (findMinimalCombinationIndex() && Continue)
227  {
229  mStepProcess++;
230 
231  if (mpCallBack)
232  Continue &= mpCallBack->progressItem(mhSteps);
233 
234  static_cast<CCopasiTask *>(getObjectParent())->output(COutputInterface::DURING);
235  }
236 
237  /* Build the elementary flux modes to be returned */
238  if (Continue)
239  buildFluxModes();
240 
241  /* Delete the current / final tableau matrix */
243  }
244 
245  if (mpCallBack)
246  Continue &= mpCallBack->finishItem(mhSteps);
247 }
#define pdelete(p)
Definition: copasi.h:215
unsigned C_INT32 mMaxStep
std::vector< std::vector< C_FLOAT64 > > mStoi
virtual bool progressItem(const size_t &handle)
bool findMinimalCombinationIndex()
std::vector< size_t > mIndexSet
virtual bool finishItem(const size_t &handle)
CTableauMatrix * mpCurrentTableau
void calculateNextTableau()
unsigned C_INT32 mStep
unsigned C_INT32 mStepProcess
size_t mReversible
CProcessReport * mpCallBack
CCopasiContainer * getObjectParent() const
void CEFMAlgorithm::calculateNextTableau ( )
private

Initialize arrays and pointer called by calculate.

Definition at line 249 of file CEFMAlgorithm.cpp.

References CProcessReport::addItem(), CTableauMatrix::addLine(), CTableauMatrix::begin(), C_FLOAT64, C_INT32, CTableauMatrix::end(), CProcessReport::finishItem(), CCopasiMethod::mpCallBack, mpCurrentTableau, mpNextTableau, mStep, pdelete, CProcessReport::proceed(), CProcessReport::progressItem(), CTableauMatrix::removeLine(), and CTableauMatrix::size().

Referenced by calculateFluxModes().

250 {
251  std::list< const CTableauLine * >::iterator a;
252  std::list< const CTableauLine * >::iterator b;
253  C_FLOAT64 ma, mb;
254 #ifdef COPASI_DEBUG_TRACE
255  DebugFile << *mpCurrentTableau << std::endl;
256 #endif //COPASI_DEBUG_TRACE
257 
259 
260  /* Move all lines with zeros in the step column to the new tableau matrix */
261  /* and remove them from the current tableau matrix */
262  a = mpCurrentTableau->begin();
263 
264  bool Continue = true;
265 
266  unsigned C_INT32 Counter, MaxCounter;
267  size_t hCounter;
268 
269  Counter = 0;
270  MaxCounter = (unsigned C_INT32) mpCurrentTableau->size();
271 
272  if (mpCallBack)
273  hCounter =
274  mpCallBack->addItem("Current Line",
275  Counter,
276  & MaxCounter);
277 
278  while (a != mpCurrentTableau->end() && Continue)
279  if ((*a)->getMultiplier(mStep) == 0.0)
280  {
281  /* We have to make sure that "a" points to the next element in the */
282  /* list after the removal of itself */
283 
284  if (a == mpCurrentTableau->begin())
285  {
286  mpNextTableau->addLine(*a, false);
288  a = mpCurrentTableau->begin();
289  }
290  else
291  {
292  /* We have to remember the previous element so that a++ points to */
293  /* past the removed one */
294  b = a--;
295  mpNextTableau->addLine(*b, false);
297  a++;
298  }
299 
300  Counter++;
301 
302  if (mpCallBack)
303  Continue &= mpCallBack->progressItem(hCounter);
304  }
305  else
306  a++;
307 
308  C_FLOAT64 Sign;
309 
310  /* Now we create all linear combinations of the remaining lines in the */
311  /* current tableau */
312  a = mpCurrentTableau->begin();
313 
314  //std::cout << "Tableau Marker A" << std::endl << std::endl;
315 
316  while (a != mpCurrentTableau->end() && Continue)
317  {
318  b = a;
319  b++;
320 
321  /* We make sure that "mb" is positive */
322  mb = (*a)->getMultiplier(mStep);
323 
324  if (mb < 0.0)
325  {
326  mb *= -1.0;
327  Sign = 1.0;
328  }
329  else
330  Sign = -1.0;
331 
332  //std::cout << "Tableau Marker B" << std::endl << std::endl;
333 
334  while (b != mpCurrentTableau->end() && Continue)
335  {
336  ma = Sign * (*b)->getMultiplier(mStep);
337 
338  /* The multiplier "ma" for irreversible reactions must be positive */
339  if (ma > 0.0 || (*a)->isReversible())
340  mpNextTableau->addLine(new CTableauLine(ma, **a, mb, **b));
341 
342  /*CTableauLine * debugLine = new CTableauLine(ma, **a, mb, **b);
343  if(debugLine->isReversible())
344  std::cout << "Reversible Rxn" << std::endl;
345  else std::cout << "Irreversible Rxn" << std::endl;
346  std::cout << "Flux Score: " << debugLine->getScore() << "Flux Mode Vector: "
347  << debugLine->getFluxMode() << std::endl;*/
348 
349  b++;
350 
351  if (mpCallBack)
352  Continue &= mpCallBack->proceed();
353  }
354 
355  // We no longer need a since all linear combinations have been build;
357  a = mpCurrentTableau->begin();
358 
359  Counter++;
360 
361  if (mpCallBack)
362  Continue &= mpCallBack->progressItem(hCounter);
363  }
364 
365  if (mpCallBack)
366  Continue &= mpCallBack->finishItem(hCounter);
367 
368  /* Assign the next tableau to the current tableau and cleanup */
370 
372 
373  mpNextTableau = NULL;
374 }
#define pdelete(p)
Definition: copasi.h:215
std::list< const CTableauLine * >::iterator begin()
size_t size() const
std::list< const CTableauLine * >::iterator end()
CTableauMatrix * mpNextTableau
#define C_INT32
Definition: copasi.h:90
virtual bool progressItem(const size_t &handle)
virtual bool proceed()
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
void removeLine(const std::list< const CTableauLine * >::iterator line)
virtual bool finishItem(const size_t &handle)
void addLine(const CTableauLine *src, const bool &check=true)
CTableauMatrix * mpCurrentTableau
#define C_FLOAT64
Definition: copasi.h:92
unsigned C_INT32 mStep
CProcessReport * mpCallBack
bool CEFMAlgorithm::findMinimalCombinationIndex ( )
private

Find index containing smallest number of combinations

Definition at line 390 of file CEFMAlgorithm.cpp.

References C_INT32, calculateCombinations(), mIndexSet, and mStep.

Referenced by calculateFluxModes().

391 {
392  double minCombine = std::numeric_limits<double>::infinity();
393  double combine = 0;
394  size_t minIndex = 0;
395  size_t counter;
396 
397  if (mIndexSet.size() == 0)
398  return false;
399  else if (mIndexSet.size() == 1)
400  {
401  mStep = (unsigned C_INT32) mIndexSet[0];
402  mIndexSet.pop_back();
403  return true;
404  }
405 
406  for (counter = 0; counter < mIndexSet.size(); counter++)
407  {
408  combine = calculateCombinations(mIndexSet[counter]);
409 
410  if (combine < minCombine)
411  {
412  minCombine = combine;
413  minIndex = counter;
414  }
415 
416  if (combine == 0)
417  break;
418  }
419 
420  mStep = (unsigned C_INT32) mIndexSet[minIndex];
421  mIndexSet.erase(mIndexSet.begin() + minIndex);
422 
423  return true;
424 }
double calculateCombinations(size_t index)
#define C_INT32
Definition: copasi.h:90
std::vector< size_t > mIndexSet
unsigned C_INT32 mStep
bool CEFMAlgorithm::initialize ( )
virtual

Initialize arrays and pointer.

Returns
bool success

Reimplemented from CEFMMethod.

Reimplemented in CSSAMethod.

Definition at line 116 of file CEFMAlgorithm.cpp.

References CProcessReport::addItem(), C_INT32, CCopasiProblem::getModel(), CCopasiObject::getObjectParent(), CCopasiTask::getProblem(), CModel::getReactions(), CModel::getStoi(), CEFMMethod::initialize(), mhSteps, mMaxStep, CCopasiMethod::mpCallBack, CEFMMethod::mpFluxModes, mpModel, CEFMMethod::mpReorderedReactions, mReversible, mStep, mStepProcess, mStoi, CTransposeView< Matrix >::numRows(), and pTask.

Referenced by calculate().

117 {
118  if (!CEFMMethod::initialize())
119  {
120  return false;
121  }
122 
123  CEFMTask * pTask = dynamic_cast< CEFMTask *>(getObjectParent());
124 
125  if (pTask == NULL) return false;
126 
127  mpModel = pTask->getProblem()->getModel();
128 
129  if (mpModel == NULL) return false;
130 
131  mpFluxModes->clear();
132 
133  /* ModelStoi is the transpose of the models stoichiometry matrix */
135 
136  size_t row, numRows = ModelStoi.numRows();
137  size_t col, numCols = ModelStoi.numCols();
138 
139  /* Size the stoichiometry matrix passed to the algorithm */
140  mStoi.resize(numRows);
141  std::vector< std::vector< C_FLOAT64 > >::iterator it = mStoi.begin();
142  std::vector< std::vector< C_FLOAT64 > >::iterator end = mStoi.end();
143 
144  for (; it != end; ++it)
145  it->resize(numCols);
146 
147  /* Get the reactions from the model */
148  /* Note: We have as many reactions as we have rows in ModelStoi */
149  const CCopasiVectorNS < CReaction > & Reaction = mpModel->getReactions();
150 
151  /* Vector to keep track of the rearrangements necessary to put the */
152  /* reversible reactions to the top of stoichiometry matrix */
153  mpReorderedReactions->resize(numRows);
154 
155  /* Reversible reaction counter */
156  mReversible = 0;
157  size_t Insert;
158  size_t InsertReversible = 0;
159  size_t InsertIrreversible = numRows - 1;
160 
161  /* Build the transpose of the stoichiometry matrix, */
162 
163  /* sort reversible reactions to the top, count them */
164 
165  /* and keep track of the rearrangement */
166  for (row = 0; row < numRows; row++)
167  {
168  if (Reaction[row]->isReversible())
169  {
170  Insert = InsertReversible++;
171  mReversible++;
172  }
173  else
174  Insert = InsertIrreversible--;
175 
176  (*mpReorderedReactions)[Insert] = Reaction[row];
177 
178  for (col = 0; col < numCols; col++)
179  mStoi[Insert][col] = ModelStoi(row, col);
180  }
181 
182  mStep = 0;
183  mStepProcess = 0;
184  mMaxStep = (unsigned C_INT32) numCols;
185 
186  if (mpCallBack)
187  mhSteps =
188  mpCallBack->addItem("Current Step",
189  mStepProcess,
190  & mMaxStep);
191 
192  return true;
193 }
CCopasiProblem * getProblem()
unsigned C_INT32 mMaxStep
std::vector< std::vector< C_FLOAT64 > > mStoi
std::vector< CFluxMode > * mpFluxModes
Definition: CEFMMethod.h:91
#define C_INT32
Definition: copasi.h:90
virtual bool initialize()
Definition: CEFMMethod.cpp:109
CTSSATask * pTask
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
std::vector< const CReaction * > * mpReorderedReactions
Definition: CEFMMethod.h:96
size_t numRows() const
Definition: CMatrix.h:767
CModel * mpModel
unsigned C_INT32 mStep
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
unsigned C_INT32 mStepProcess
const CMatrix< C_FLOAT64 > & getStoi() const
Definition: CModel.cpp:1160
size_t mReversible
CProcessReport * mpCallBack
CModel * getModel() const
CCopasiContainer * getObjectParent() const
void CEFMAlgorithm::initObjects ( )
private

Definition at line 111 of file CEFMAlgorithm.cpp.

References CCopasiContainer::addObjectReference(), mStep, and CCopasiObject::ValueInt.

Referenced by CEFMAlgorithm().

112 {
114 }
unsigned C_INT32 mStep
CCopasiObject * addObjectReference(const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)

Friends And Related Function Documentation

Member Data Documentation

size_t CEFMAlgorithm::mhSteps
protected

Handle to the process report item "Current Step"

Definition at line 174 of file CEFMAlgorithm.h.

Referenced by CSSAMethod::calculate(), calculate(), calculateFluxModes(), CSSAMethod::initialize(), and initialize().

std::vector<size_t> CEFMAlgorithm::mIndexSet
protected

Vector set containing all step indexes for iteration when calculating flux modes.

Definition at line 179 of file CEFMAlgorithm.h.

Referenced by calculateFluxModes(), and findMinimalCombinationIndex().

unsigned C_INT32 CEFMAlgorithm::mMaxStep
protected

The max step used for process report.

Definition at line 169 of file CEFMAlgorithm.h.

Referenced by calculateFluxModes(), CSSAMethod::initialize(), and initialize().

CTableauMatrix* CEFMAlgorithm::mpCurrentTableau
protected

A pointer to the current tableau matrix

Definition at line 149 of file CEFMAlgorithm.h.

Referenced by buildFluxModes(), calculateCombinations(), calculateFluxModes(), calculateNextTableau(), and ~CEFMAlgorithm().

CModel* CEFMAlgorithm::mpModel
protected
CTableauMatrix* CEFMAlgorithm::mpNextTableau
protected

A pointer to the next tableaun matrix

Definition at line 154 of file CEFMAlgorithm.h.

Referenced by calculateNextTableau(), and ~CEFMAlgorithm().

size_t CEFMAlgorithm::mReversible
protected

The number of reversible reactions.

Definition at line 144 of file CEFMAlgorithm.h.

Referenced by calculateFluxModes(), CSSAMethod::initialize(), and initialize().

unsigned C_INT32 CEFMAlgorithm::mStep
protected

The current step used for process report.

Definition at line 159 of file CEFMAlgorithm.h.

Referenced by calculateFluxModes(), calculateNextTableau(), findMinimalCombinationIndex(), CSSAMethod::initialize(), initialize(), and initObjects().

unsigned C_INT32 CEFMAlgorithm::mStepProcess
protected

The current step used for process report.

Definition at line 164 of file CEFMAlgorithm.h.

Referenced by calculateFluxModes(), and initialize().

std::vector< std::vector< C_FLOAT64 > > CEFMAlgorithm::mStoi
protected

Matrix containing the reordered stoichiometry matrix.

Definition at line 139 of file CEFMAlgorithm.h.

Referenced by CSSAMethod::buildStoichiometry(), calculateFluxModes(), CSSAMethod::initialize(), initialize(), and CSSAMethod::testForMixingStability().


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