-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.cpp
More file actions
119 lines (100 loc) · 2.17 KB
/
Copy pathstate.cpp
File metadata and controls
119 lines (100 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* state.cpp
*
* Created on: 13 Oct 2011
* Author: nathan
*/
#include <string>
#include <iostream>
#include "individual.h"
#include "state_parameter.h"
#include "state.h"
using namespace std;
using namespace microsimulator;
State::State(string name, int id) :
initializeFunction_(0),
transitionFunction_(0),
name_(name),
id_(id)
{};
double State::initialize() {
if (initializeFunction_) {
return initializeFunction_();
}
return 0.0;
}
double State::transition(double value, StateVector& states,
IndividualVector& individuals, Individual& individual)
{
if (transitionFunction_) {
return transitionFunction_(value, states, individuals, individual);
}
return value;
}
void State::prepare(double timePeriod)
{
this->normalizeParameters(timePeriod);
}
void State::normalizeParameters(double timePeriod)
{
map <int, StateParameter*>::iterator it;
for (it=stateParameters_.begin(); it!= stateParameters_.end(); ++it){
it->second->computeNormalizedValue(timePeriod);
}
}
void State::addFilterFunction(On o)
{
filterFunctions_.push_back(o);
}
void State::setInitializeFunction(const InitializeFunction f)
{
this->initializeFunction_ = f;
}
void State::setTransitionFunction(const TransitionFunction f)
{
this->transitionFunction_ = f;
}
void State::setParameterValue(Parameter parameter, double value)
{
stateParameters_[parameter]->setValue(value);
}
void State::setName(const string& name)
{
name_ = name;
}
void State::setId(int id)
{
id_ = id;
}
double State::getParameterValue(Parameter parameter) const
{
map <int, StateParameter*>::const_iterator it;
it = stateParameters_.find(parameter);
if (it != stateParameters_.end())
{
return it->second->getValue();
}
return 0.0;
}
double State::getParameterNormalizedValue(Parameter parameter) const
{
map <int, StateParameter*>::const_iterator it;
it = stateParameters_.find(parameter);
if (it != stateParameters_.end())
{
return it->second->getNormalizedValue();
}
return 0.0;
}
string State::getName() const
{
return name_;
}
int State::getId() const
{
return id_;
}
FilterFunctionList* State::getFilterFunctions()
{
return &filterFunctions_;
}