MultiAgentDecisionProcess  Release 0.2.1
RewardModelMappingSparse.h
Go to the documentation of this file.
1 
28 /* Only include this header file once. */
29 #ifndef _REWARDMODELMAPPINGSPARSE_H_
30 #define _REWARDMODELMAPPINGSPARSE_H_ 1
31 
32 /* the include directives */
33 #include <boost/numeric/ublas/matrix_sparse.hpp>
34 #include "Globals.h"
35 #include "RewardModel.h"
36 
39 {
40 private:
41 
42  std::string _m_s_str;
43  std::string _m_ja_str;
44 
45 #if BOOST_1_32_OR_LOWER // they renamed sparse_vector to mapped_vector
46  typedef boost::numeric::ublas::sparse_matrix<double> SparseMatrix;
47 #else
48  typedef boost::numeric::ublas::compressed_matrix<double> SparseMatrix;
49  // if the matrix is really large, we might need to resort to a
50  // mapped matrix:
51  //typedef boost::numeric::ublas::mapped_matrix<double> SparseMatrix;
52 #endif
53 
55 
56 protected:
57 
58 public:
59  // Constructor, destructor and copy assignment.
68  RewardModelMappingSparse(size_t nrS = 1, size_t nrJA = 1, std::string s_str="s",
69  std::string ja_str="ja");
71  //RewardModelMappingSparse(const RewardModelMappingSparse&);
74 
76  double Get(Index s_i, Index ja_i) const
77  { return(_m_R(s_i,ja_i)); }
78 
79  //data manipulation funtions:
81 
84  void Set(Index s_i, Index ja_i, double rew)
85  {
86  // make sure reward is not 0
87  if(fabs(rew) > REWARD_PRECISION)
88  _m_R(s_i,ja_i)=rew;
89  }
90 
93  { return new RewardModelMappingSparse(*this); }
94 
96  std::string SoftPrint() const;
98  void Print() const
99  { std::cout << SoftPrint();}
100 
102 };
103 
104 #endif /* !_REWARDMODELMAPPINGSPARSE_H_*/
105 
106 // Local Variables: ***
107 // mode:c++ ***
108 // End: ***
109