Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
transitionStructure.h
1 #ifndef TRANSITIONSTRUCTURE_H
2 #define TRANSITIONSTRUCTURE_H
3 
4 #include "../marmoteConstants.h"
5 #include "../Distribution/discreteDistribution.h"
6 #include <stdio.h>
7 #include <string>
8 
18 {
19  protected:
20  timeType _type;
22  long int _size;
25  public:
26  // constructors
27  // transitionStructure(int);
32  virtual ~transitionStructure() {};
33 
34  public:
35  //accessors
41  int size() { return _size; };
47  timeType type() { return _type; };
60  void setType(timeType t) { _type = t; };
66  void setUniformizationRate(double rate) { _uniformizationRate = rate; };
75  virtual bool setEntry(int i, int j, double val) = 0;
84  virtual double getEntry(int i, int j) = 0;
92  virtual int getNbElts(int i) = 0;
101  virtual int getCol(int i, int k) = 0;
110  virtual double getEntryByCol(int i, int k) = 0;
117  virtual discreteDistribution* getTransDistrib(int i) = 0; // transitions from some state and their probas
118 
127  bool readEntry(FILE *input);
134  virtual double rowSum(int i) = 0;
135 
136  public:
142  virtual transitionStructure* copy() = 0;
151  virtual transitionStructure* uniformize() = 0;
161  virtual void evaluateMeasure(double* d,double* res) {
162  fprintf( stderr, "Warning in transitionStructure::evaluateDistribution: not implemented.\n" ); };
170  fprintf( stderr, "Warning in transitionStructure::evaluateDistribution: not implemented.\n" ); };
179  virtual void evaluateValue(double* v, double* res) = 0;
180 
181 protected:
182  // specific technical methods
194  int consolidate(int i, int* destinations, double* values);
195 
196 public:
203  virtual void write(FILE* out, std::string format) = 0;
204 
205 };
206 
207 #endif // TRANSITIONSTRUCTURE_H
virtual discreteDistribution * getTransDistrib(int i)=0
Method to get the transition from some state as a probability distribution.
virtual void evaluateMeasure(double *d, double *res)
Computing the action of the transition structure on some measure, the measure being represented as a ...
Definition: transitionStructure.h:161
int consolidate(int i, int *destinations, double *values)
Method to consolidate (aggregate) transition probabilities from a given state. The method returns the...
Definition: transitionStructure.cpp:36
timeType _type
the time type of the structure: discrete or continuous.
Definition: transitionStructure.h:20
virtual transitionStructure * uniformize()=0
Uniformizing a transition structure. The structure should be of continuous time type. The resulting one will be of discrete time type. If uniformization fails, a NULL pointer should be returned. If the origin structure is already of discrete-time type, a copy should be returned.
virtual int getCol(int i, int k)=0
Method to get the number of the state corresponding to transition number k in the list of possible tr...
virtual double getEntryByCol(int i, int k)=0
Method to get the value attached to transition number k in the list of possible transitions from some...
virtual int getNbElts(int i)=0
Method to get the number of non-zero entries in a transition from some state. This can be seen as the...
double _uniformizationRate
value related to the uniformization procedure.
Definition: transitionStructure.h:23
virtual void write(FILE *out, std::string format)=0
Output method for a transition structure.
long int _size
size of the state space.
Definition: transitionStructure.h:22
virtual void evaluateValue(double *v, double *res)=0
Computing the action of the transition structure on some vector of values. This corresponds to the mu...
bool readEntry(FILE *input)
Reading from a file, and adding an element to the matrix. The field must be in the form "row column v...
Definition: transitionStructure.cpp:19
virtual double rowSum(int i)=0
Calculating the sum of values corresponding to transitions from some state.
virtual bool setEntry(int i, int j, double val)=0
Method to set the value associated with some transition.
Abstract class for transition structures. These are structures which describe transitions to one stat...
Definition: transitionStructure.h:17
void setUniformizationRate(double rate)
Write accessor for the uniformization rate.
Definition: transitionStructure.h:66
virtual ~transitionStructure()
Destructor of the class.
Definition: transitionStructure.h:32
timeType type()
Read accessor for the time type.
Definition: transitionStructure.h:47
virtual double getEntry(int i, int j)=0
Method to get the value associated with some transition. When state parameters are out of bounds...
virtual void evaluateMeasure(discreteDistribution *d, discreteDistribution *res)
Computing the action of the transition structure on some probability distribution.
Definition: transitionStructure.h:169
void setType(timeType t)
Write accessor for the time type.
Definition: transitionStructure.h:60
int size()
Read accessor for the size of the state space.
Definition: transitionStructure.h:41
virtual transitionStructure * copy()=0
Copying a transition structure.
The general discrete distribution with finite support.
Definition: discreteDistribution.h:25
double uniformizationRate()
Read accessor for the uniformization rate. Relevant mostly for discrete-time structures created by un...
Definition: transitionStructure.h:54