MultiAgentDecisionProcess  Release 0.2.1
AlphaVector.cpp
Go to the documentation of this file.
1 
28 #include "AlphaVector.h"
29 
30 using namespace std;
31 
34 {
35  _m_values.assign(0,0);
36  _m_betaI=-1;
37 }
38 
40 {
41  _m_values.assign(nrS,0);
42  _m_betaI=-1;
43 }
44 
45 AlphaVector::AlphaVector(size_t nrS, double val)
46 {
47  _m_values.assign(nrS,val);
48  _m_betaI=-1;
49 }
50 
51 //Destructor
53 {
54 }
55 //Copy assignment operator
57 {
58  if (this == &o) return *this; // Gracefully handle self assignment
59  // Put the normal assignment duties here...
60 
61  this->_m_action=o._m_action;
62  this->_m_values=o._m_values;
63  this->_m_betaI=o._m_betaI;
64 
65  return *this;
66 }
67 
68 string AlphaVector::SoftPrint() const
69 {
70  stringstream ss;
71  ss << "a " << _m_action << " bI " << _m_betaI
72  << " : values";
73  vector<double>::const_iterator it=_m_values.begin();
74  while(it!=_m_values.end())
75  {
76  ss << " " << *it;
77  it++;
78  }
79  return(ss.str());
80 }
81 
82 void AlphaVector::SetValues(const vector<double> &vs)
83 {
84  if(vs.size()!=_m_values.size())
85  throw(E("AlphaVector::SetValues vector sizes do not match"));
86  else
87  _m_values=vs;
88 }
89 
90 bool AlphaVector::Equal(const AlphaVector &alpha) const
91 {
92  if(this->GetNrValues()!=alpha.GetNrValues())
93  return(false);
94 
95  if(this->GetAction()!=alpha.GetAction())
96  return(false);
97 
98  if(this->GetBetaI()!=alpha.GetBetaI())
99  return(false);
100 
101  vector<double> values=alpha.GetValues();
102 
103  if(_m_values!=values)
104  return(false);
105 
106  // else
107  return(true);
108 }