-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.h
75 lines (58 loc) · 1.9 KB
/
state.h
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
/*
* state.h
*
* Created on: 13 Oct 2011
* Author: nathan
*/
#ifndef STATE_H_
#define STATE_H_
#include <map>
#include <vector>
#include "simutils.h"
#include "state_parameter.h"
using namespace std;
namespace microsimulator {
// This class encapsulates a simulation state. A Simulation has multiple states.
// A simulation also consists of multiple individuals.
// Each individual in the simulation has a value for each state.
class State
{
public:
// Parameters used by the State are stored in the Parameter enumeration
enum Parameter {
DEFAULT_PARAMETER=0
};
State( string name="", int id=0 );
virtual ~State() {};
// Determine the initial value for a state for a particular individual.
virtual double initialize();
// Given a value for an individual's state, this method calculates what the
// new value should be.
virtual double transition(double value,
StateVector& states,
IndividualVector& individuals,
Individual& individual);
virtual void registerRequiredState(string stateName, int indexTo) {};
virtual void prepare(double timePeriod);
void normalizeParameters(double timePeriod);
void addFilterFunction(On o);
void setInitializeFunction(const InitializeFunction f);
void setTransitionFunction(const TransitionFunction f);
void setParameterValue(Parameter parameter, double value);
void setName(const string& name);
void setId(int id);
double getParameterValue(Parameter parameter) const;
double getParameterNormalizedValue(Parameter parameter) const;
string getName() const;
int getId() const;
FilterFunctionList* getFilterFunctions();
protected:
InitializeFunction initializeFunction_;
TransitionFunction transitionFunction_;
FilterFunctionList filterFunctions_;
map <int, StateParameter*> stateParameters_;
string name_;
int id_;
};
}
#endif /* STATE_H_ */