Commit 1ad04219 authored by Alexis Lebis's avatar Alexis Lebis

frame for decay

parent 6dfc228f
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <model/magnitude.h> #include <model/magnitude.h>
#include <model/tools.h> #include <model/tools.h>
#include <model/competency.h> #include <model/competency.h>
#include <model/decay.h>
#include <model/ea/cursus.h> #include <model/ea/cursus.h>
#include <model/ea/initializer.h> #include <model/ea/initializer.h>
......
...@@ -61,7 +61,7 @@ Competency Competency::buildTMP(double d, std::string name) ...@@ -61,7 +61,7 @@ Competency Competency::buildTMP(double d, std::string name)
// === CONSTRUCTOR // === CONSTRUCTOR
Competency::Competency(int id, Magnitude m, std::string s) Competency::Competency(int id, Magnitude m, std::string s)
: _id(id), _m(m), _name(s) : _id(id), _m(m), _undecayedMag(m), _name(s)
{ {
} }
...@@ -120,6 +120,23 @@ const double Competency::competencyValue() const ...@@ -120,6 +120,23 @@ const double Competency::competencyValue() const
return this->_m.value(); return this->_m.value();
} }
double Competency::decay()
{
if(!this->_isDecaying)
return this->_m.value();
try
{
this->evolveTowards((-1) * DecayEngine::defaultDecay(this->_howLongDecaying));
}
catch(CompetencyEvolvingException & e)
{
//NTD
}
return this->_m.value();
}
// === OPERATOR // === OPERATOR
std::ostream& operator<<(std::ostream& Stream, const Competency & c) std::ostream& operator<<(std::ostream& Stream, const Competency & c)
{ {
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include <string> #include <string>
#include "magnitude.h" #include "magnitude.h"
#include "decay.h"
/** /**
* Represents the notion of a competency (a.k.a. "non operationalisable" skill). * Represents the notion of a competency (a.k.a. "non operationalisable" skill).
...@@ -19,6 +21,11 @@ class Competency ...@@ -19,6 +21,11 @@ class Competency
std::string _name; std::string _name;
int _id; int _id;
//Decay related
Magnitude _undecayedMag;
bool _isDecaying;
int _howLongDecaying;
//Constructor //Constructor
Competency(int, Magnitude, std::string); Competency(int, Magnitude, std::string);
...@@ -65,6 +72,16 @@ class Competency ...@@ -65,6 +72,16 @@ class Competency
void setMagnitude(Magnitude & m){this->_m = m;} void setMagnitude(Magnitude & m){this->_m = m;}
void setName(std::string s){this->_name = s;} void setName(std::string s){this->_name = s;}
// === DECAY
const bool isDecaying() const {return this->_isDecaying;}
void decayState(bool state) {this->_isDecaying = state;}
int increaseDecay(){this->_isDecaying = true; this->_howLongDecaying++; return this->_howLongDecaying;}
void resetDecay(){this->_isDecaying = false; this->_howLongDecaying = 0;}
void setTimeDecay(unsigned int time){this->_howLongDecaying = time;}
Magnitude getUndecayedMagnitude(){return this->_undecayedMag;}
double decay();
double decayAndReset(){this->decay(); this->resetDecay(); return this->_m.value();}
// === OPERATOR // === OPERATOR
/// A competency is equal to another iff their id are the same, or their name /// A competency is equal to another iff their id are the same, or their name
bool operator==(const Competency & c) const; bool operator==(const Competency & c) const;
......
#ifndef SRC_MODEL_DECAY_H_
#define SRC_MODEL_DECAY_H_
#include <cmath>
class DecayEngine
{
private:
public:
/** Expresses the decay over the time x.
*/
static double defaultDecay(int t)
{
if(t == 0)
return 0;
return (exp(t / 1.25) + 5)/100;
}
};
#endif //SRC_MODEL_DECAY_H_
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment