26 Drive(std::string d_name,
double d_period, std::string d_key=
"default",
double d_value=0.5,
double d_homeo_min=0.25,
double d_homeo_max=0.75,
double d_decay = 0.05,
double d_value_min=std::numeric_limits<double>::min(),
double d_value_max=std::numeric_limits<double>::max(),
bool d_gradient =
false) :
31 homeostasisMin(d_homeo_min),
32 homeostasisMax(d_homeo_max),
34 valueMin(d_value_min),
35 valueMax(d_value_max),
36 default_value((d_homeo_max + d_homeo_min)/2.),
39 start_sleep(time(NULL)),
44 if (d_value_min == std::numeric_limits<double>::min() && d_value_max == std::numeric_limits<double>::max()){
46 valueMin = homeostasisMin - 0.5 * homeoRange;
47 valueMax = homeostasisMax + 0.5 * homeoRange;
63 this->value += d_value;
68 this->homeostasisMin = d_homeo_min;
72 this->homeostasisMin += d_homeo_min;
77 this->homeostasisMax = d_homeo_max;
81 this->homeostasisMax += d_homeo_max;
86 this->decay = d_decay;
90 this->decay += d_decay;
95 this->decay_multiplier = mult;
103 start_sleep = time(NULL);
112 start_sleep = time(NULL);
114 time_to_sleep = 1e10;
137 if (difftime(time(NULL), start_sleep) > time_to_sleep) {
141 else if (! ((this->value > valueMax && this->decay<0) || (this->value < valueMin && this->decay>0))) {
142 this->value -= (this->decay * this->decay_multiplier *
period);
void setValue(double d_value)
void setHomeostasisMax(double d_homeo_max)
void setHomeostasisMin(double d_homeo_min)
Drive()=delete
No default constructor!
double time_to_sleep
Timespan to be sleeping.
void deltaValue(double d_value)
Drive(std::string d_name, double d_period, std::string d_key="default", double d_value=0.5, double d_homeo_min=0.25, double d_homeo_max=0.75, double d_decay=0.05, double d_value_min=std::numeric_limits< double >::min(), double d_value_max=std::numeric_limits< double >::max(), bool d_gradient=false)
std::string name
Name of the drive.
bool is_sleeping
Whether drive is sleeping.
void reset()
reset Set value back to default_value
std::string key
Deprecated, not used anymore.
void deltaHomeostasisMax(double d_homeo_max)
void setName(std::string n)
void setDecay(double d_decay)
void freeze()
freeze Freeze (sleep) drive indefinitely
void deltaDecay(double d_decay)
void setDecayMultiplier(double mult)
void sleep(double t)
sleep Sleep drive for t seconds, i.e.
void deltaHomeostasisMin(double d_homeo_min)
void unfreeze()
unfreeze Unfreeze drive
void setKey(std::string d_key)
time_t start_sleep
Time when the drive started to be sleeping.
void update()
update Let drive decay