PostureTransition.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        PostureTransition.h
00003  *
00004  * author:      Majid Nabi <m.nabi@tue.nl>
00005  *
00006  *
00007  *              http://www.es.ele.tue.nl/nes
00008  *
00009  * copyright:   (C) 2010 Electronic Systems group(ES),
00010  *              Eindhoven University of Technology (TU/e), the Netherlands.
00011  *
00012  *
00013  *              This program is free software; you can redistribute it
00014  *              and/or modify it under the terms of the GNU General Public
00015  *              License as published by the Free Software Foundation; either
00016  *              version 2 of the License, or (at your option) any later
00017  *              version.
00018  *              For further information see file COPYING
00019  *              in the top level directory
00020  ***************************************************************************
00021  * part of:    MoBAN (Mobility Model for wireless Body Area Networks)
00022  * description: A class to manage and store the posture transition matrices
00023  ***************************************************************************
00024  * Citation of the following publication is appreciated if you use MoBAN for
00025  * a publication of your own.
00026  *
00027  * M. Nabi, M. Geilen, T. Basten. MoBAN: A Configurable Mobility Model for Wireless Body Area Networks.
00028  * In Proc. of the 4th Int'l Conf. on Simulation Tools and Techniques, SIMUTools 2011, Barcelona, Spain, 2011.
00029  *
00030  * BibTeX:
00031  *    @inproceedings{MoBAN,
00032  *    author = "M. Nabi and M. Geilen and T. Basten.",
00033  *    title = "{MoBAN}: A Configurable Mobility Model for Wireless Body Area Networks.",
00034  *      booktitle = "Proceedings of the 4th Int'l Conf. on Simulation Tools and Techniques.",
00035  *      series = {SIMUTools '11},
00036  *      isbn = {978-963-9799-41-7},
00037  *      year = {2011},
00038  *      location = {Barcelona, Spain},
00039  *      publisher = {ICST} }
00040  *
00041  **************************************************************************/
00042 
00043 
00044 #include <iostream>
00045 #include <omnetpp.h>
00046 #include <BaseWorldUtility.h>
00047 #include <sstream>
00048 
00062 class PostureTransition {
00063 protected:
00064 
00066   int numPos;
00067 
00072   int defaultMatrixID;
00073 
00075     typedef struct{
00076       std::string name;
00077       double** matrix;
00078     }TransMatrix;
00079 
00081     typedef std::vector<TransMatrix*> TransMatrixList;
00082 
00084     TransMatrixList matrixList;
00085 
00087     typedef struct{
00088       Coord low;
00089       Coord high;
00090     }AreaBound;
00091 
00093     typedef struct{
00094       std::string name;
00095         std::vector<AreaBound*> boundries;
00096     }AreaType;
00097 
00099     typedef std::vector<AreaType*> AreaTypeList;
00100 
00102     AreaTypeList areaTypeList;
00103 
00105     typedef struct{
00106     simtime_t low;
00107     simtime_t high;
00108     }TimeBound;
00109 
00111     typedef struct{
00112         std::string name;
00113         std::vector<TimeBound*> boundries;
00114     }TimeDomainType;
00115 
00117     typedef std::vector<TimeDomainType*> TimeDomainList;
00118 
00120     TimeDomainList timeDomainList;
00121 
00123     typedef struct{
00124         int timeID;
00125         int areaID;
00126         int matrixID;
00127     }CombinationType;
00128 
00130     typedef std::vector<CombinationType*> CombinationList;
00131 
00133     CombinationList combinationList;
00134 
00135 
00139     double** extractMatrixFromSteadyState(double* );
00140 
00142     int findTimeDomain(simtime_t );
00143 
00145     int findAreaType(Coord);
00146 
00150     bool isMarkovian(double**);
00151 
00155     bool isMarkovian(double*);
00156 
00158     void multMatrix(double** , double** ,double** );
00159 
00161     void addMatrix(double** , double** ,double** );
00162 
00164     void subtractMatrix(double** , double** ,double** );
00165 
00167     void multVector(double* ,double** );
00168 
00169 public:
00170 
00174   PostureTransition(int);
00175 
00177   int addMatrix(std::string , double**, bool);
00178 
00182   int addSteadyState(std::string, double* );
00183 
00185   int addAreaType(std::string);
00186 
00188   bool setAreaBoundry(int, Coord, Coord );
00189 
00191   int addTimeDomain(std::string);
00192 
00194   bool setTimeBoundry(int, simtime_t, simtime_t);
00195 
00197   bool addCombination(std::string, std::string, std::string);
00198 
00200   double** getMatrix(simtime_t, Coord);
00201 
00202 };