MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MarkovSolverBase Class Reference

#include <MarkovSolverBase.h>

+ Inheritance diagram for MarkovSolverBase:
+ Collaboration diagram for MarkovSolverBase:

Public Member Functions

VectorbilinearInterpolate () const
 
virtual MatrixcomputeMatrixExponential ()
 
void computeState ()
 
void fillupTable ()
 
Vector getInitialState () const
 
double getInvDx () const
 
double getInvDy () const
 
Matrix getQ () const
 
Vector getState () const
 
unsigned int getXdivs () const
 
double getXmax () const
 
double getXmin () const
 
unsigned int getYdivs () const
 
double getYmax () const
 
double getYmin () const
 
void handleLigandConc (double)
 
void handleVm (double)
 
void init (Id, double)
 
void innerFillupTable (vector< unsigned int >, string, unsigned int, unsigned int)
 
VectorlinearInterpolate () const
 
 MarkovSolverBase ()
 
void process (const Eref &, ProcPtr)
 
void reinit (const Eref &, ProcPtr)
 
void setInitialState (Vector)
 
void setXdivs (unsigned int)
 
void setXmax (double)
 
void setXmin (double)
 
void setYdivs (unsigned int)
 
void setYmax (double)
 
void setYmin (double)
 
virtual ~MarkovSolverBase ()
 

Static Public Member Functions

static const CinfoinitCinfo ()
 

Protected Attributes

MatrixQ_
 

Private Member Functions

void setLookupParams ()
 

Private Attributes

double dt_
 
MatrixexpMat_
 
vector< Matrix * > expMats1d_
 
vector< vector< Matrix * > > expMats2d_
 
Vector initialState_
 
double invDx_
 
double invDy_
 
double ligandConc_
 
MarkovRateTablerateTable_
 
unsigned int size_
 
Vector state_
 
double Vm_
 
unsigned int xDivs_
 
double xMax_
 
double xMin_
 
unsigned int yDivs_
 
double yMax_
 
double yMin_
 

Detailed Description

Definition at line 51 of file MarkovSolverBase.h.

Constructor & Destructor Documentation

MarkovSolverBase::MarkovSolverBase ( )

Definition at line 189 of file MarkovSolverBase.cpp.

189  : Q_(0), expMats1d_(0), expMat_(0),
190  expMats2d_(0), xMin_(DBL_MAX), xMax_(DBL_MIN), xDivs_(0u),
191  yMin_(DBL_MAX), yMax_(DBL_MIN), yDivs_(0u), size_(0u), Vm_(0),
192  ligandConc_(0), dt_(0)
193 {
194  ;
195 }
vector< Matrix * > expMats1d_
unsigned int yDivs_
unsigned int size_
vector< vector< Matrix * > > expMats2d_
unsigned int xDivs_
MarkovSolverBase::~MarkovSolverBase ( )
virtual

Definition at line 197 of file MarkovSolverBase.cpp.

References expMat_, expMats1d_, expMats2d_, and Q_.

198 {
199  if ( Q_ )
200  delete Q_;
201 
202  if ( !expMats1d_.empty() )
203  {
204  while ( !expMats1d_.empty() )
205  {
206  delete expMats1d_.back();
207  expMats1d_.pop_back();
208  }
209  }
210 
211  if ( !expMats2d_.empty() )
212  {
213  unsigned int n = expMats2d_.size();
214  for( unsigned int i = 0; i < n; ++i )
215  {
216  for ( unsigned int j = 0; j < expMats2d_[i].size(); ++j )
217  delete expMats2d_[i][j];
218  }
219  }
220 
221  if ( expMat_ != 0 )
222  delete expMat_;
223 }
vector< Matrix * > expMats1d_
vector< vector< Matrix * > > expMats2d_

Member Function Documentation

Vector * MarkovSolverBase::bilinearInterpolate ( ) const

Definition at line 317 of file MarkovSolverBase.cpp.

References expMats2d_, invDx_, invDy_, ligandConc_, state_, vecMatMul(), vecVecScalAdd(), Vm_, xDivs_, xMin_, yDivs_, and yMin_.

Referenced by computeState().

318 {
319  bool isEndOfX = false;
320  bool isEndOfY = false;
321 
322  unsigned int xIndex =
323  static_cast< unsigned int >( ( Vm_ - xMin_ ) * invDx_ );
324  unsigned int yIndex =
325  static_cast< unsigned int >( ( ligandConc_ - yMin_ ) * invDy_ );
326  double xv = (Vm_ - xMin_) * invDx_;
327  double yv = (ligandConc_ - yMin_) * invDy_;
328 
329  double xF = xv - xIndex;
330  double yF = yv - yIndex;
331  double xFyF = xF * yF;
332 
333  ( xIndex == xDivs_ ) ? isEndOfX = true : isEndOfX = false;
334  ( yIndex == yDivs_ ) ? isEndOfY = true : isEndOfY = false;
335 
336  vector< vector< Matrix* > >::const_iterator iExpQ0 =
337  expMats2d_.begin() + xIndex;
338  vector< Matrix* >::const_iterator iExpQ00 = iExpQ0->begin() + yIndex;
339  vector< Matrix* >::const_iterator iExpQ10;
340 
341  Matrix* expQ00 = *iExpQ00;
342  Matrix* expQ01;
343  Matrix* expQ10;
344  Matrix* expQ11;
345 
346 #if ENABLE_CPP1
347  // Intialization to supress compiler warning.
348  Vector *state00 = nullptr;
349  Vector *state01 = nullptr;
350  Vector *state10 = nullptr;
351  Vector *state11 = nullptr;
352  Vector *result = nullptr;
353 #else
354  Vector *state00 = NULL, *state01 = NULL
355  , *state10 = NULL, *state11 = NULL
356  , *result = NULL
357  ;
358 #endif
359 
360  state00 = vecMatMul( &state_, expQ00 );
361  if ( isEndOfX )
362  {
363  if ( isEndOfY )
364  return state00;
365  else
366  {
367  expQ01 = *(iExpQ00 + 1);
368  state01 = vecMatMul( &state_, expQ01 );
369  result = vecVecScalAdd( state00, state01,
370  (1 - yF), yF );
371  }
372  }
373  else
374  {
375  iExpQ10 = ( iExpQ0 + 1 )->begin() + yIndex;
376  expQ10 = *iExpQ10;
377  state10 = vecMatMul( &state_, expQ10 );
378 
379  if ( isEndOfY )
380  {
381  result = vecVecScalAdd( state00, state10, ( 1 - xF ), xF );
382  }
383  else
384  {
385  expQ01 = *( iExpQ00 + 1 );
386  expQ11 = *( iExpQ10 + 1 );
387 
388  state01 = vecMatMul( &state_, expQ01 );
389  state11 = vecMatMul( &state_, expQ11 );
390 
391  Vector *temp1, *temp2;
392 
393  temp1 = vecVecScalAdd( state00, state10,
394  ( 1 - xF - yF + xFyF ),
395  ( xF - xFyF )
396  );
397 
398  temp2 = vecVecScalAdd( state01, state11, ( yF - xFyF ), xFyF );
399 
400  result = vecVecScalAdd( temp1, temp2, 1.0, 1.0 );
401 
402  delete temp1;
403  delete temp2;
404  }
405  }
406 
407  if ( state00 )
408  delete state00;
409  if ( state01 )
410  delete state01;
411  if ( state10 )
412  delete state10;
413  if ( state11 )
414  delete state11;
415 
416  return result;
417 }
vector< double > Vector
Definition: MatrixOps.h:23
Vector * vecVecScalAdd(const Vector *v1, const Vector *v2, double alpha, double beta)
Definition: MatrixOps.cpp:249
Vector * vecMatMul(const Vector *v, Matrix *A)
Definition: MatrixOps.cpp:201
unsigned int yDivs_
vector< vector< Matrix * > > expMats2d_
vector< vector< double > > Matrix
Definition: MatrixOps.h:22
unsigned int xDivs_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Matrix * MarkovSolverBase::computeMatrixExponential ( )
virtual

Reimplemented in MarkovSolver.

Definition at line 600 of file MarkovSolverBase.cpp.

Referenced by fillupTable().

601 {
602  return 0;
603 }

+ Here is the caller graph for this function:

void MarkovSolverBase::computeState ( )

Definition at line 463 of file MarkovSolverBase.cpp.

References MarkovRateTable::areAllRates1d(), MarkovRateTable::areAnyRates2d(), MarkovRateTable::areAnyRatesLigandDep(), MarkovRateTable::areAnyRatesVoltageDep(), bilinearInterpolate(), linearInterpolate(), rateTable_, and state_.

Referenced by process().

464 {
465  Vector* newState;
466  bool useBilinear = false;
467  // useLinear = false;
468 
469  if ( rateTable_->areAnyRates2d() ||
470  ( rateTable_->areAllRates1d() &&
473  ) )
474  {
475  useBilinear = true;
476  }
477  /*
478  else if ( rateTable_->areAllRatesVoltageDep() ||
479  rateTable_->areAllRatesLigandDep() )
480  {
481  useLinear = true;
482  }
483  */
484 
485  //Heavily borrows from the Interpol2D::interpolate function.
486  if ( useBilinear )
487  newState = bilinearInterpolate();
488  else
489  newState = linearInterpolate();
490 
491  state_ = *newState;
492 
493  delete newState;
494 }
vector< double > Vector
Definition: MatrixOps.h:23
MarkovRateTable * rateTable_
Vector * linearInterpolate() const
Vector * bilinearInterpolate() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MarkovSolverBase::fillupTable ( )

Definition at line 524 of file MarkovSolverBase.cpp.

References MarkovRateTable::areAllRates1d(), MarkovRateTable::areAllRatesConstant(), MarkovRateTable::areAllRatesLigandDep(), MarkovRateTable::areAllRatesVoltageDep(), MarkovRateTable::areAnyRates2d(), MarkovRateTable::areAnyRatesLigandDep(), MarkovRateTable::areAnyRatesVoltageDep(), computeMatrixExponential(), expMat_, expMats1d_, expMats2d_, MarkovRateTable::getListOf1dRates(), MarkovRateTable::getListOf2dRates(), MarkovRateTable::getListOfConstantRates(), MarkovRateTable::getListOfLigandRates(), MarkovRateTable::getListOfVoltageRates(), innerFillupTable(), rateTable_, xDivs_, xMax_, xMin_, yDivs_, yMax_, and yMin_.

Referenced by init().

525 {
526  double dx = (xMax_ - xMin_) / xDivs_;
527  double dy = (yMax_ - yMin_) / yDivs_;
528 
529  vector< unsigned int > listOf1dRates = rateTable_->getListOf1dRates();
530  vector< unsigned int > listOf2dRates = rateTable_->getListOf2dRates();
531  vector< unsigned int > listOfConstantRates =
533 
534  //Set constant rates in the Q matrix, if any.
535  innerFillupTable( listOfConstantRates, "constant",
536  0.0, 0.0 );
537 
538  //xIndex loops through all voltages, yIndex loops through all
539  //ligand concentrations.
540  if ( rateTable_->areAnyRates2d() ||
541  ( rateTable_->areAllRates1d() &&
544  ) )
545  {
546  double voltage = xMin_, ligandConc = yMin_;
547 
548  for ( unsigned int xIndex = 0; xIndex < xDivs_ + 1; ++xIndex )
549  {
550  ligandConc = yMin_;
551  for( unsigned int yIndex = 0; yIndex < yDivs_ + 1; ++yIndex )
552  {
553  innerFillupTable( listOf2dRates, "2D", xIndex, yIndex );
554 
555  //This is a very klutzy way of updating 1D rates as the same
556  //lookup is done multiple times. But this all occurs at setup,
557  //and lookups arent that slow either. This way is also easier
558  //to maintain.
559  innerFillupTable( listOf1dRates, "1D", xIndex, yIndex );
560 
561  expMats2d_[xIndex][yIndex] = computeMatrixExponential();
562  ligandConc += dy;
563  }
564  voltage += dx;
565  }
566  }
567  else if ( rateTable_->areAllRatesLigandDep() )
568  {
569  double x = xMin_;
570  vector< unsigned int > listOfLigandRates =
572 
573  for ( unsigned int xIndex = 0; xIndex < xDivs_ + 1; ++xIndex )
574  {
575  innerFillupTable( listOfLigandRates, "1D", xIndex, 0 );
577  x += dx;
578  }
579  }
580  else if ( rateTable_->areAllRatesVoltageDep() )
581  {
582  double x = xMin_;
583  vector< unsigned int > listOfVoltageRates =
585 
586  for ( unsigned int xIndex = 0; xIndex < xDivs_ + 1; ++xIndex )
587  {
588  innerFillupTable( listOfVoltageRates, "1D", xIndex, 0 );
590  x += dx;
591  }
592  }
593  else if ( rateTable_->areAllRatesConstant() )
594  {
596  return;
597  }
598 }
vector< unsigned int > getListOf2dRates()
virtual Matrix * computeMatrixExponential()
vector< unsigned int > getListOfConstantRates()
MarkovRateTable * rateTable_
vector< unsigned int > getListOf1dRates()
vector< Matrix * > expMats1d_
void innerFillupTable(vector< unsigned int >, string, unsigned int, unsigned int)
unsigned int yDivs_
vector< unsigned int > getListOfVoltageRates()
vector< vector< Matrix * > > expMats2d_
unsigned int xDivs_
vector< unsigned int > getListOfLigandRates()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Vector MarkovSolverBase::getInitialState ( ) const

Definition at line 238 of file MarkovSolverBase.cpp.

References initialState_.

Referenced by initCinfo().

239 {
240  return initialState_;
241 }

+ Here is the caller graph for this function:

double MarkovSolverBase::getInvDx ( ) const

Definition at line 278 of file MarkovSolverBase.cpp.

References invDx_.

Referenced by initCinfo().

278  {
279  return invDx_;
280 }

+ Here is the caller graph for this function:

double MarkovSolverBase::getInvDy ( ) const

Definition at line 312 of file MarkovSolverBase.cpp.

References invDy_.

Referenced by initCinfo().

313 {
314  return invDy_;
315 }

+ Here is the caller graph for this function:

Matrix MarkovSolverBase::getQ ( ) const

Definition at line 228 of file MarkovSolverBase.cpp.

References Q_.

Referenced by initCinfo().

229 {
230  return *Q_;
231 }

+ Here is the caller graph for this function:

Vector MarkovSolverBase::getState ( ) const

Definition at line 233 of file MarkovSolverBase.cpp.

References state_.

Referenced by initCinfo().

234 {
235  return state_;
236 }

+ Here is the caller graph for this function:

unsigned int MarkovSolverBase::getXdivs ( ) const

Definition at line 274 of file MarkovSolverBase.cpp.

References xDivs_.

Referenced by initCinfo().

274  {
275  return xDivs_;
276 }
unsigned int xDivs_

+ Here is the caller graph for this function:

double MarkovSolverBase::getXmax ( ) const

Definition at line 264 of file MarkovSolverBase.cpp.

References xMax_.

Referenced by initCinfo().

265 {
266  return xMax_;
267 }

+ Here is the caller graph for this function:

double MarkovSolverBase::getXmin ( ) const

Definition at line 254 of file MarkovSolverBase.cpp.

References xMin_.

Referenced by initCinfo().

255 {
256  return xMin_;
257 }

+ Here is the caller graph for this function:

unsigned int MarkovSolverBase::getYdivs ( ) const

Definition at line 307 of file MarkovSolverBase.cpp.

References yDivs_.

Referenced by initCinfo().

308 {
309  return yDivs_;
310 }
unsigned int yDivs_

+ Here is the caller graph for this function:

double MarkovSolverBase::getYmax ( ) const

Definition at line 297 of file MarkovSolverBase.cpp.

References yMax_.

Referenced by initCinfo().

298 {
299  return yMax_;
300 }

+ Here is the caller graph for this function:

double MarkovSolverBase::getYmin ( ) const

Definition at line 287 of file MarkovSolverBase.cpp.

References yMin_.

Referenced by initCinfo().

288 {
289  return yMin_;
290 }

+ Here is the caller graph for this function:

void MarkovSolverBase::handleLigandConc ( double  ligandConc)

Definition at line 634 of file MarkovSolverBase.cpp.

References ligandConc_.

Referenced by initCinfo().

635 {
636  ligandConc_ = ligandConc;
637 }

+ Here is the caller graph for this function:

void MarkovSolverBase::handleVm ( double  Vm)

Definition at line 629 of file MarkovSolverBase.cpp.

References Vm_.

Referenced by initCinfo().

630 {
631  Vm_ = Vm;
632 }

+ Here is the caller graph for this function:

void MarkovSolverBase::init ( Id  rateTableId,
double  dt 
)

Definition at line 641 of file MarkovSolverBase.cpp.

References MarkovRateTable::areAllRates1d(), MarkovRateTable::areAllRatesLigandDep(), MarkovRateTable::areAllRatesVoltageDep(), MarkovRateTable::areAnyRates2d(), MarkovRateTable::areAnyRatesLigandDep(), MarkovRateTable::areAnyRatesVoltageDep(), Eref::data(), dt_, Id::eref(), expMat_, expMats1d_, expMats2d_, fillupTable(), MarkovRateTable::getSize(), matAlloc(), Q_, rateTable_, resize(), setLookupParams(), size_, xDivs_, and yDivs_.

Referenced by initCinfo().

642 {
643  MarkovRateTable* rateTable = reinterpret_cast< MarkovRateTable* >(
644  rateTableId.eref().data() );
645 
646  size_ = rateTable->getSize();
647  rateTable_ = rateTable;
648  setLookupParams( );
649 
650  if ( rateTable->areAnyRates2d() ||
651  ( rateTable->areAllRates1d() &&
652  rateTable->areAnyRatesVoltageDep() &&
653  rateTable->areAnyRatesLigandDep()
654  ) )
655  {
656  expMats2d_.resize( xDivs_ + 1 );
657  for( unsigned int i = 0; i < xDivs_ + 1; ++i )
658  expMats2d_[i].resize( yDivs_ + 1);
659  }
660  else if ( rateTable->areAllRatesLigandDep() ||
661  rateTable->areAllRatesVoltageDep() )
662  {
663  expMats1d_.resize( xDivs_ + 1);
664  }
665  else //All rates must be constant.
666  {
667  expMat_ = matAlloc( size_ );
668  }
669 
670  //Initializing Q.
671  Q_ = matAlloc( size_ );
672 
673  //The state at t = t0 + dt is exp( dt * Q ) * [state at t = t0].
674  //Hence, we need to scale the terms of Q by dt.
675  dt_ = dt;
676 
677  //Fills up the newly setup tables with exponentials.
678  fillupTable( );
679 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
MarkovRateTable * rateTable_
vector< Matrix * > expMats1d_
unsigned int yDivs_
unsigned int size_
vector< vector< Matrix * > > expMats2d_
vector< vector< T > > resize(vector< vector< T > >table, unsigned int n, T init)
unsigned int getSize() const
unsigned int xDivs_
Matrix * matAlloc(unsigned int n)
Definition: MatrixOps.cpp:480

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Cinfo * MarkovSolverBase::initCinfo ( )
static

Definition at line 28 of file MarkovSolverBase.cpp.

References getInitialState(), getInvDx(), getInvDy(), getQ(), getState(), getXdivs(), getXmax(), getXmin(), getYdivs(), getYmax(), getYmin(), handleLigandConc(), handleVm(), init(), Neutral::initCinfo(), markovSolverBaseCinfo, process(), reinit(), setInitialState(), setXdivs(), setXmax(), setXmin(), setYdivs(), setYmax(), setYmin(), and stateOut().

Referenced by MarkovSolver::initCinfo().

29 {
31  //SharedFinfos
33  static DestFinfo handleVm("handleVm",
34  "Handles incoming message containing voltage information.",
36  );
37 
38  static Finfo* channelShared[] =
39  {
40  &handleVm
41  };
42 
43  static SharedFinfo channel("channel",
44  "This message couples the MarkovSolverBase to the Compartment. The "
45  "compartment needs Vm in order to look up the correct matrix "
46  "exponential for computing the state.",
47  channelShared, sizeof( channelShared ) / sizeof( Finfo* )
48  );
49 
51  //DestFinfos
53 
54  static DestFinfo process( "process",
55  "Handles process call",
57 
58  static DestFinfo reinit( "reinit",
59  "Handles reinit call",
61 
62  static Finfo* processShared[] =
63  {
64  &process, &reinit
65  };
66 
67  static SharedFinfo proc( "proc",
68  "This is a shared message to receive Process message from the"
69  "scheduler. The first entry is a MsgDest for the Process "
70  "operation. It has a single argument, ProcInfo, which "
71  "holds lots of information about current time, thread, dt and"
72  "so on. The second entry is a MsgDest for the Reinit "
73  "operation. It also uses ProcInfo.",
74  processShared, sizeof( processShared ) / sizeof( Finfo* )
75  );
76 
77  static DestFinfo ligandConc("ligandConc",
78  "Handles incoming message containing ligand concentration.",
80  );
81 
82  static DestFinfo init("init",
83  "Setups the table of matrix exponentials associated with the"
84  " solver object.",
86  );
87 
89  //*ValueFinfos
91 
93  "Instantaneous rate matrix.",
95  );
96 
98  "Current state of the channel.",
100  );
101 
102  static ValueFinfo< MarkovSolverBase, Vector > initialstate("initialState",
103  "Initial state of the channel.",
106  );
107 
108  static ValueFinfo< MarkovSolverBase, double > xmin( "xmin",
109  "Minimum value for x axis of lookup table",
112  );
113  static ValueFinfo< MarkovSolverBase, double > xmax( "xmax",
114  "Maximum value for x axis of lookup table",
117  );
118  static ValueFinfo< MarkovSolverBase, unsigned int > xdivs( "xdivs",
119  "# of divisions on x axis of lookup table",
122  );
124  "Reciprocal of increment on x axis of lookup table",
126  );
127  static ValueFinfo< MarkovSolverBase, double > ymin( "ymin",
128  "Minimum value for y axis of lookup table",
131  );
132  static ValueFinfo< MarkovSolverBase, double > ymax( "ymax",
133  "Maximum value for y axis of lookup table",
136  );
137  static ValueFinfo< MarkovSolverBase, unsigned int > ydivs( "ydivs",
138  "# of divisions on y axis of lookup table",
141  );
143  "Reciprocal of increment on y axis of lookup table",
145  );
146 
147  static Finfo* markovSolverFinfos[] =
148  {
149  &channel, //SharedFinfo
150  &proc, //SharedFinfo
151  stateOut(), //SrcFinfo
152  &ligandConc, //DestFinfo
153  &init, //DestFinfo
154  &Q, //ReadOnlyValueFinfo
155  &state, //ReadOnlyValueFinfo
156  &initialstate, //ReadOnlyValueFinfo
157  &xmin, //ValueFinfo
158  &xmax, //ValueFinfo
159  &xdivs, //ValueFinfo
160  &invdx, //ReadOnlyValueFinfo
161  &ymin, //ValueFinfo
162  &ymax, //ValueFinfo
163  &ydivs, //ValueFinfo
164  &invdy //ReadOnlyValueFinfo
165  };
166 
167  static string doc[] =
168  {
169  "Name", "MarkovSolverBase",
170  "Author", "Vishaka Datta S, 2011, NCBS",
171  "Description", "Solver for Markov Channel."
172  };
173  static Dinfo< MarkovSolverBase > dinfo;
175  "MarkovSolverBase",
177  markovSolverFinfos,
178  sizeof( markovSolverFinfos ) / sizeof( Finfo* ),
179  &dinfo,
180  doc,
181  sizeof(doc) / sizeof(string)
182  );
183 
184  return &markovSolverBaseCinfo;
185 }
void init(Id, double)
Definition: Dinfo.h:60
void setInitialState(Vector)
Vector getState() const
void setYdivs(unsigned int)
Matrix getQ() const
unsigned int getYdivs() const
double getXmin() const
Definition: OpFunc.h:40
void setXdivs(unsigned int)
Vector getInitialState() const
unsigned int getXdivs() const
double getInvDx() const
Definition: OpFunc.h:27
double getXmax() const
double getInvDy() const
void handleLigandConc(double)
void reinit(const Eref &, ProcPtr)
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
double getYmin() const
SrcFinfo1< Vector > * stateOut()
Definition: Cinfo.h:18
static const Cinfo * markovSolverBaseCinfo
void process(const Eref &, ProcPtr)
double getYmax() const
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MarkovSolverBase::innerFillupTable ( vector< unsigned int >  ,
string  ,
unsigned  int,
unsigned  int 
)

Definition at line 496 of file MarkovSolverBase.cpp.

References dt_, MarkovRateTable::lookup1dIndex(), MarkovRateTable::lookup1dValue(), MarkovRateTable::lookup2dIndex(), Q_, and rateTable_.

Referenced by fillupTable().

501 {
502  unsigned int n = rateIndices.size(), i, j;
503 
504  for ( unsigned int k = 0; k < n; ++k )
505  {
506  i = ( ( rateIndices[k] / 10 ) % 10 ) - 1;
507  j = ( rateIndices[k] % 10 ) - 1;
508 
509  (*Q_)[i][i] += (*Q_)[i][j];
510 
511  if ( rateType.compare("2D") == 0 )
512  (*Q_)[i][j] = rateTable_->lookup2dIndex( i, j, xIndex, yIndex );
513  else if ( rateType.compare("1D") == 0 )
514  (*Q_)[i][j] = rateTable_->lookup1dIndex( i, j, xIndex );
515  else if ( rateType.compare("constant") == 0 )
516  (*Q_)[i][j] = rateTable_->lookup1dValue( i, j, 1.0 );
517 
518  (*Q_)[i][j] *= dt_;
519 
520  (*Q_)[i][i] -= (*Q_)[i][j];
521  }
522 }
MarkovRateTable * rateTable_
double lookup2dIndex(unsigned int, unsigned int, unsigned int, unsigned int)
double lookup1dValue(unsigned int, unsigned int, double)
double lookup1dIndex(unsigned int, unsigned int, unsigned int)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Vector * MarkovSolverBase::linearInterpolate ( ) const

Definition at line 419 of file MarkovSolverBase.cpp.

References MarkovRateTable::areAllRatesVoltageDep(), expMats1d_, invDx_, ligandConc_, rateTable_, state_, vecMatMul(), vecVecScalAdd(), Vm_, xMax_, and xMin_.

Referenced by computeState().

420 {
421  double x;
422 
424  x = Vm_;
425  else
426  x = ligandConc_;
427 
428  if ( x < xMin_ )
429  return vecMatMul( &state_, expMats1d_[0] );
430  else if ( x > xMax_ )
431  return vecMatMul( &state_, expMats1d_.back() );
432 
433  unsigned int xIndex = static_cast< unsigned int >( ( x - xMin_) * invDx_ );
434 
435  double xv = ( x - xMin_ ) * invDx_;
436  double xF = xv - xIndex;
437 
438  vector< Matrix* >::const_iterator iExpQ =
439  expMats1d_.begin() + xIndex;
440 
441  Vector *state0, *state1, *result;
442 
443  state0 = vecMatMul( &state_, *iExpQ );
444  state1 = vecMatMul( &state_, *( iExpQ + 1 ) );
445 
446  result = vecVecScalAdd( state0, state1, 1 - xF, xF );
447 
448  delete state0;
449  delete state1;
450 
451  return result;
452 }
vector< double > Vector
Definition: MatrixOps.h:23
MarkovRateTable * rateTable_
Vector * vecVecScalAdd(const Vector *v1, const Vector *v2, double alpha, double beta)
Definition: MatrixOps.cpp:249
Vector * vecMatMul(const Vector *v, Matrix *A)
Definition: MatrixOps.cpp:201
vector< Matrix * > expMats1d_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MarkovSolverBase::process ( const Eref e,
ProcPtr  p 
)

Definition at line 622 of file MarkovSolverBase.cpp.

References computeState(), state_, and stateOut().

Referenced by initCinfo(), and MarkovSolver::process().

623 {
624  computeState();
625 
626  stateOut()->send( e, state_ );
627 }
SrcFinfo1< Vector > * stateOut()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MarkovSolverBase::reinit ( const Eref e,
ProcPtr  p 
)

Definition at line 609 of file MarkovSolverBase.cpp.

References initialState_, state_, and stateOut().

Referenced by initCinfo(), and MarkovSolver::reinit().

610 {
611  if ( initialState_.empty() )
612  {
613  cerr << "MarkovSolverBase::reinit : Initial state has not been "
614  "set.\n";
615  return;
616  }
618 
619  stateOut()->send( e, state_ );
620 }
SrcFinfo1< Vector > * stateOut()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MarkovSolverBase::setInitialState ( Vector  state)

Definition at line 243 of file MarkovSolverBase.cpp.

References initialState_, and state_.

Referenced by initCinfo().

244 {
245  initialState_ = state;
247 }

+ Here is the caller graph for this function:

void MarkovSolverBase::setLookupParams ( )
private

Definition at line 697 of file MarkovSolverBase.cpp.

References MarkovRateTable::areAllRates1d(), MarkovRateTable::areAllRatesLigandDep(), MarkovRateTable::areAnyRates1d(), MarkovRateTable::areAnyRates2d(), VectorTable::getDiv(), MarkovRateTable::getInt2dChildTable(), MarkovRateTable::getListOf2dRates(), MarkovRateTable::getListOfLigandRates(), MarkovRateTable::getListOfVoltageRates(), VectorTable::getMax(), VectorTable::getMin(), MarkovRateTable::getVtChildTable(), Interpol2D::getXdivs(), Interpol2D::getXmax(), Interpol2D::getXmin(), Interpol2D::getYdivs(), Interpol2D::getYmax(), Interpol2D::getYmin(), invDx_, invDy_, rateTable_, xDivs_, xMax_, xMin_, yDivs_, yMax_, and yMin_.

Referenced by init().

698 {
699  if ( rateTable_->areAnyRates1d() )
700  {
701  vector< unsigned int > listOfLigandRates
703  vector< unsigned int > listOfVoltageRates
705 
706  double temp;
707  double yMax = DBL_MIN, yMin = DBL_MAX;
708  unsigned int yDivs = 0u;
709  unsigned int divs, i, j;
710 
711  for( unsigned int k = 0; k < listOfLigandRates.size(); ++k )
712  {
713  i = ( ( listOfLigandRates[k] / 10 ) % 10 ) - 1;
714  j = ( listOfLigandRates[k] % 10 ) - 1;
715 
716  temp = rateTable_->getVtChildTable( i, j )->getMin();
717  if ( yMin > temp )
718  yMin = temp;
719 
720  temp = rateTable_->getVtChildTable( i, j )->getMax();
721  if ( yMax < temp )
722  yMax = temp;
723 
724  divs = rateTable_->getVtChildTable( i, j )->getDiv();
725  if ( yDivs < divs )
726  yDivs = divs;
727  }
728 
729  if ( ( rateTable_->areAllRatesLigandDep() &&
731  {
732  xMin_ = yMin;
733  xMax_ = yMax;
734  xDivs_ = yDivs;
735  invDx_ = yDivs / ( yMax - yMin );
736  }
737  else
738  {
739  yMin_= yMin;
740  yMax_ = yMax;
741  yDivs_ = yDivs;
742  invDy_ = yDivs / ( yMax - yMin );
743  }
744 
745  for( unsigned int k = 0; k < listOfVoltageRates.size(); ++k )
746  {
747  i = ( ( listOfVoltageRates[k] / 10 ) % 10 ) - 1;
748  j = ( listOfVoltageRates[k] % 10 ) - 1;
749 
750  temp = rateTable_->getVtChildTable( i, j )->getMin();
751  if ( xMin_ > temp )
752  xMin_ = temp;
753 
754  temp = rateTable_->getVtChildTable( i, j )->getMax();
755  if ( xMax_ < temp )
756  xMax_ = temp;
757 
758  divs = rateTable_->getVtChildTable( i, j )->getDiv();
759  if ( xDivs_ < divs )
760  xDivs_ = divs;
761  }
762  }
763 
764  if ( rateTable_->areAnyRates2d() )
765  {
766  vector< unsigned int > listOf2dRates = rateTable_->getListOf2dRates();
767  double temp;
768  unsigned int divs, i, j;
769 
770  for( unsigned int k = 0; k < listOf2dRates.size(); ++k )
771  {
772  i = ( ( listOf2dRates[k] / 10 ) % 10 ) - 1;
773  j = ( listOf2dRates[k] % 10 ) - 1;
774 
775  temp = rateTable_->getInt2dChildTable( i, j )->getXmin();
776  if ( xMin_ > temp )
777  xMin_ = temp;
778 
779  temp = rateTable_->getInt2dChildTable( i, j )->getXmax();
780  if ( xMax_ < temp )
781  xMax_ = temp;
782 
783  temp = rateTable_->getInt2dChildTable( i, j )->getYmin();
784  if ( yMin_ > temp )
785  yMin_ = temp;
786 
787  temp = rateTable_->getInt2dChildTable( i, j )->getYmax();
788  if ( yMax_ < temp )
789  yMax_ = temp;
790 
791  divs = rateTable_->getInt2dChildTable( i, j )->getXdivs();
792  if ( xDivs_ < divs )
793  xDivs_ = divs;
794 
795  divs = rateTable_->getInt2dChildTable( i, j )->getYdivs();
796  if ( yDivs_ < divs )
797  yDivs_ = divs;
798  }
799 
800  invDx_ = xDivs_ / ( xMax_ - xMin_ );
801  invDy_ = yDivs_ / ( yMax_ - yMin_ );
802  }
803 }
vector< unsigned int > getListOf2dRates()
double getMin() const
Interpol2D * getInt2dChildTable(unsigned int, unsigned int) const
VectorTable * getVtChildTable(unsigned int, unsigned int) const
double getXmin() const
Definition: Interpol2D.cpp:238
MarkovRateTable * rateTable_
unsigned int getXdivs() const
Definition: Interpol2D.cpp:262
double getYmin() const
Definition: Interpol2D.cpp:302
unsigned int yDivs_
vector< unsigned int > getListOfVoltageRates()
double getYmax() const
Definition: Interpol2D.cpp:316
unsigned int getDiv() const
unsigned int getYdivs() const
Definition: Interpol2D.cpp:325
unsigned int xDivs_
vector< unsigned int > getListOfLigandRates()
double getXmax() const
Definition: Interpol2D.cpp:252
double getMax() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MarkovSolverBase::setXdivs ( unsigned int  xDivs)

Definition at line 269 of file MarkovSolverBase.cpp.

References xDivs_.

Referenced by initCinfo().

270 {
271  xDivs_ = xDivs;
272 }
unsigned int xDivs_

+ Here is the caller graph for this function:

void MarkovSolverBase::setXmax ( double  xMax)

Definition at line 259 of file MarkovSolverBase.cpp.

References xMax_.

Referenced by initCinfo().

260 {
261  xMax_ = xMax;
262 }

+ Here is the caller graph for this function:

void MarkovSolverBase::setXmin ( double  xMin)

Definition at line 249 of file MarkovSolverBase.cpp.

References xMin_.

Referenced by initCinfo().

250 {
251  xMin_ = xMin;
252 }

+ Here is the caller graph for this function:

void MarkovSolverBase::setYdivs ( unsigned int  yDivs)

Definition at line 302 of file MarkovSolverBase.cpp.

References yDivs_.

Referenced by initCinfo().

303 {
304  yDivs_ = yDivs;
305 }
unsigned int yDivs_

+ Here is the caller graph for this function:

void MarkovSolverBase::setYmax ( double  yMax)

Definition at line 292 of file MarkovSolverBase.cpp.

References yMax_.

Referenced by initCinfo().

293 {
294  yMax_ = yMax;
295 }

+ Here is the caller graph for this function:

void MarkovSolverBase::setYmin ( double  yMin)

Definition at line 282 of file MarkovSolverBase.cpp.

References yMin_.

Referenced by initCinfo().

283 {
284  yMin_ = yMin;
285 }

+ Here is the caller graph for this function:

Member Data Documentation

double MarkovSolverBase::dt_
private

Definition at line 211 of file MarkovSolverBase.h.

Referenced by init(), and innerFillupTable().

Matrix* MarkovSolverBase::expMat_
private

Definition at line 172 of file MarkovSolverBase.h.

Referenced by fillupTable(), init(), and ~MarkovSolverBase().

vector< Matrix* > MarkovSolverBase::expMats1d_
private

Definition at line 170 of file MarkovSolverBase.h.

Referenced by fillupTable(), init(), linearInterpolate(), and ~MarkovSolverBase().

vector< vector< Matrix* > > MarkovSolverBase::expMats2d_
private

Definition at line 175 of file MarkovSolverBase.h.

Referenced by bilinearInterpolate(), fillupTable(), init(), and ~MarkovSolverBase().

Vector MarkovSolverBase::initialState_
private

Definition at line 198 of file MarkovSolverBase.h.

Referenced by getInitialState(), reinit(), and setInitialState().

double MarkovSolverBase::invDx_
private
double MarkovSolverBase::invDy_
private

Definition at line 183 of file MarkovSolverBase.h.

Referenced by bilinearInterpolate(), getInvDy(), and setLookupParams().

double MarkovSolverBase::ligandConc_
private

Definition at line 207 of file MarkovSolverBase.h.

Referenced by bilinearInterpolate(), handleLigandConc(), and linearInterpolate().

Matrix* MarkovSolverBase::Q_
protected
MarkovRateTable* MarkovSolverBase::rateTable_
private
unsigned int MarkovSolverBase::size_
private

Definition at line 202 of file MarkovSolverBase.h.

Referenced by init().

Vector MarkovSolverBase::state_
private
double MarkovSolverBase::Vm_
private

Definition at line 205 of file MarkovSolverBase.h.

Referenced by bilinearInterpolate(), handleVm(), and linearInterpolate().

unsigned int MarkovSolverBase::xDivs_
private
double MarkovSolverBase::xMax_
private

Definition at line 178 of file MarkovSolverBase.h.

Referenced by fillupTable(), getXmax(), linearInterpolate(), setLookupParams(), and setXmax().

double MarkovSolverBase::xMin_
private
unsigned int MarkovSolverBase::yDivs_
private
double MarkovSolverBase::yMax_
private

Definition at line 182 of file MarkovSolverBase.h.

Referenced by fillupTable(), getYmax(), setLookupParams(), and setYmax().

double MarkovSolverBase::yMin_
private

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