Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
 All Classes Functions Variables
markovChain.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 MARKOVCHAIN_H
17 #define MARKOVCHAIN_H
18 
19 #include "marmoteConstants.h"
20 #include "Distribution/Distribution.h"
21 #include "simulationResult.h"
22 #include "transitionStructure/transitionStructure.h"
23 #include <string>
24 #include <iostream>
25 
26 using namespace std;
27 
33 {
34 
35  protected:
36 
37  timeType _type;
40  // someType _reward; to be defined later
41  // int _initState;
43  bool _debug;
45  bool _isAbstract;
47  string* _abstract;
48  string _format;
49  string _modelName;
51  public:
52  // constructors
53 
61  markovChain(int sz, timeType t);
62 
63 
72 
89  markovChain(string format, string param[], int nbreParam, string modelName,
90  bool isAbstract);
91 
97  virtual ~markovChain();
98 
99 public:
100  // accessors
101 
106  int stateSpaceSize() { return _stateSpaceSize; }
112  transitionStructure* generator() { return _generator; }
118  void setInitDistribution( discreteDistribution* d ) { if ( _initDistribution != NULL ){ delete(_initDistribution); }; _initDistribution = d; }
124  void setGenerator( transitionStructure* tr ) { _generator = tr; }
125 
132 Distribution * read();
138 void setFormat(string format){_format=format;}
144 void setModelName(string modelName){_modelName=modelName;}
145 
151  void setAbstractNbre(int abstractNbre){_abstractNbre=abstractNbre;}
152 
159  void setAbstract(string abstract[]);
160 
168  int abstractNbre(){return _abstractNbre;}
169 
176  string modelName(){return _modelName;}
182  string format(){return _format;}
183 
189  void abstract()
190  {
191 
192  for(int i=0; i<_abstractNbre;i++)
193  {
194  cout<<i<<":"<<_abstract[i];
195  }
196 
197  }
198 
199  public:
200  // solution methods
214  virtual simulationResult* simulateChain( double tMax,
215  bool Stats, bool Traj,
216  bool withIncrements, bool Print );
217 
228  virtual simulationResult* simulateChainDT( int tMax,
229  bool stats, bool traj,
230  bool trace );
242  virtual simulationResult* simulateChainCT( double tMax,
243  bool stats, bool traj,
244  bool withIncrements,
245  bool trace );
260  simulationResult* simulatePSI( int tMax,
261  bool stats, bool Traj,
262  bool Print );
263 
272  virtual Distribution* stationaryDistribution( bool progress );
281  virtual Distribution* stationaryDistributionCT( bool progress );
289  virtual Distribution* stationaryDistributionDT( bool progress );
290 
298  Distribution* stationaryDistributionGthLD();
299 
307  Distribution* stationaryDistributionSOR();
308 
318  simulationResult* stationaryDistributionSample( int nbSamples );
319 
328  Distribution* hittingTimeDistribution( int iState, bool *hitSetIndicator );
329 
341  int* simulateHittingTime(int iState, bool *hittingSet,
342  int nbSamples, int tMax );
349  double* averageHittingTime( bool *hitSetIndicator );
350 
358  double* averageHittingTimeDT( bool *hitSetIndicator );
359 
367  double* averageHittingTimeDT_iterative( bool *hitSetIndicator );
368 
369  public:
370 
376  virtual markovChain* copy();
377 
378 
386  virtual markovChain* uniformize();
387 
396  void setSizeType(const string path);
397  // virtual void makeMarkovChain();
398 
399  public:
400 
408  virtual void write( FILE *out, bool withReward );
409  virtual void write( string format, string modelName);
410 
411 };
412 
413 #endif // MARKOVCHAIN_H