Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
transitionStructure.h
1 /* Marmote is free software: you can redistribute it and/or modify
2 it under the terms of the GNU General Public License as published by
3 the Free Software Foundation, either version 3 of the License, or
4 (at your option) any later version.
5 
6 Marmote is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 GNU General Public License for more details.
10 
11 You should have received a copy of the GNU General Public License
12 along with Marmote. If not, see <http://www.gnu.org/licenses/>.
13 
14 Copyright 2015 Alain Jean-Marie, Jean-Michel Fourneau, Jean-Marc Vincent, Issam Rabhi */
15 
16 #ifndef TRANSITIONSTRUCTURE_H
17 #define TRANSITIONSTRUCTURE_H
18 
19 #include "../marmoteConstants.h"
20 #include "../Distribution/discreteDistribution.h"
21 #include <stdio.h>
22 #include <string>
23 
34 {
35  protected:
36  timeType _type;
38  long int _origSize;
39  long int _destSize;
42  public:
43  // constructors
44  // transitionStructure(int);
49  virtual ~transitionStructure() {};
50 
51  public:
52  //accessors
59  int size() { return _origSize; };
65  int origSize() { return _origSize; };
71  int destSize() { return _destSize; };
77  timeType type() { return _type; };
90  void setType(timeType t) { _type = t; };
96  void setUniformizationRate(double rate) { _uniformizationRate = rate; };
105  virtual bool setEntry(int i, int j, double val) = 0;
114  virtual double getEntry(int i, int j) = 0;
122  virtual int getNbElts(int i) = 0;
131  virtual int getCol(int i, int k) = 0;
140  virtual double getEntryByCol(int i, int k) = 0;
147  virtual discreteDistribution* getTransDistrib(int i) = 0; // transitions from some state and their probas
148 
157  bool readEntry(FILE *input);
164  virtual double rowSum(int i) = 0;
165 
166  public:
172  virtual transitionStructure* copy() = 0;
181  virtual transitionStructure* uniformize() = 0;
191  virtual transitionStructure* embed() = 0;
201  virtual void evaluateMeasure(double* d,double* res) {
202  fprintf( stderr, "Warning in transitionStructure::evaluateDistribution: not implemented.\n" ); };
210  fprintf( stderr, "Warning in transitionStructure::evaluateDistribution: not implemented.\n" );
211  return d;
212  };
221  virtual void evaluateValue(double* v, double* res) = 0;
222 
223 protected:
224  // specific technical methods
236  int consolidate(int i, int* destinations, double* values);
237 
238 public:
245  void write(FILE* out, std::string format);
246 
252  std::string toString(std::string format);
253 
254 };
255 
256 #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:201
long int _destSize
size of the destination state space.
Definition: transitionStructure.h:39
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:42
long int _origSize
size of the origin state space.
Definition: transitionStructure.h:38
timeType _type
the time type of the structure: discrete or continuous.
Definition: transitionStructure.h:36
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 discreteDistribution * evaluateMeasure(discreteDistribution *d)
Computing the action of the transition structure on some probability distribution.
Definition: transitionStructure.h:209
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:40
virtual transitionStructure * embed()=0
Embedding a discrete-time transition structure at jump times of a transition structure. The structure should be of continuous time type. The resulting one will be of discrete time type. If embedding fails, a NULL pointer should be returned. If the origin structure is already of discrete-time type, a copy should be returned.
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...
std::string toString(std::string format)
String serialization method for a transition structure.
Definition: transitionStructure.cpp:204
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:25
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.
int origSize()
Read accessor for the size of the origin state space.
Definition: transitionStructure.h:65
Abstract class for transition structures. These are structures which describe transitions to one stat...
Definition: transitionStructure.h:33
void setUniformizationRate(double rate)
Write accessor for the uniformization rate.
Definition: transitionStructure.h:96
virtual ~transitionStructure()
Destructor of the class.
Definition: transitionStructure.h:49
timeType type()
Read accessor for the time type.
Definition: transitionStructure.h:77
virtual double getEntry(int i, int j)=0
Method to get the value associated with some transition. When state parameters are out of bounds...
void setType(timeType t)
Write accessor for the time type.
Definition: transitionStructure.h:90
int size()
Read accessor for the size of the state space. This is the origin state space by default.
Definition: transitionStructure.h:59
int destSize()
Read accessor for the size of the destination state space.
Definition: transitionStructure.h:71
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:84
void write(FILE *out, std::string format)
File output method for a transition structure.
Definition: transitionStructure.cpp:57