Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/stochasticdata.h
[mareframe] / trunk / gadget / stochasticdata.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/stochasticdata.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (view) (download)

1 : agomez 1 #ifndef stochasticdata_h
2 :     #define stochasticdata_h
3 :    
4 :     #include "doublevector.h"
5 :     #include "intvector.h"
6 :     #include "parameter.h"
7 :     #include "parametervector.h"
8 :     #include "charptrvector.h"
9 :     #include "commentstream.h"
10 :     #include "initialinputfile.h"
11 :     #include "gadget.h"
12 :    
13 :     #ifdef GADGET_NETWORK
14 :     #include "mpi.h"
15 :     #include "slavecommunication.h"
16 :     #endif
17 :    
18 :     /**
19 :     * \class StochasticData
20 :     * \brief This is the class used to get values for the variables used in the model simulation. These values are either read from an InitialInputFile, or received from the network if the simulation is part of a parallel optimisation, using paramin
21 :     */
22 :     class StochasticData {
23 :     public:
24 :     /**
25 :     * \brief This is the default StochasticData constructor
26 :     */
27 : ulcessvp 2 StochasticData();
28 :     /**
29 :     * \brief This is the StochasticData constructor specifying a file to read the data from
30 :     * \param filename is the name of the file to read the data from
31 :     * \param p is the number of the node
32 :     */
33 : agomez 1 StochasticData(const char* const filename, int p);
34 :     /**
35 :     * \brief This is the StochasticData constructor specifying a file to read the data from
36 :     * \param filename is the name of the file to read the data from
37 :     */
38 :     StochasticData(const char* const filename);
39 :     /**
40 :     * \brief This is the default StochasticData destructor
41 :     */
42 :     virtual ~StochasticData();
43 :     /**
44 :     * \brief This function will read the next line of data from the input file
45 :     * \note This function is only called if the input file has data using the 'repeated values' format
46 :     */
47 :     void readNextLine();
48 :     /**
49 :     * \brief This function will check to see if there is more data to read in the input file
50 :     * \return 1 if there is more data to read from the input file, 0 otherwise
51 :     */
52 :     int isDataLeft() { return readInfo->isDataLeft(); };
53 :     /**
54 :     * \brief This function will return the number of variables read from the input file
55 :     * \return number of variables
56 :     */
57 :     int numVariables() const { return values.Size(); };
58 :     /**
59 :     * \brief This function will return the number of switches read from the input file
60 :     * \return number of switches
61 :     */
62 :     int numSwitches() const { return switches.Size(); };
63 :     /**
64 :     * \brief This function will check to see if optimising flags have been specified in the input file
65 :     * \return 1 if the optimising flags have been specified, 0 otherwise
66 :     */
67 :     int isOptGiven() const;
68 :     /**
69 :     * \brief This function will return the optimising flag for a switch in the input file
70 :     * \param i is the index for the switch
71 :     * \return optimise flag for the switch
72 :     */
73 :     int getOptFlag(int i) const;
74 :     /**
75 :     * \brief This function will return the value of a switch in the input file
76 :     * \param i is the index for the switch
77 :     * \return value of the switch
78 :     */
79 :     double getValue(int i) const { return values[i]; };
80 :     /**
81 :     * \brief This function will return the lower bound for a switch in the input file
82 :     * \param i is the index for the switch
83 :     * \return lower bound for the switch
84 :     */
85 :     double getLowerBound(int i) const { return lowerbound[i]; };
86 :     /**
87 :     * \brief This function will return the upper bound for a switch in the input file
88 :     * \param i is the index for the switch
89 :     * \return upper bound for the switch
90 :     */
91 :     double getUpperBound(int i) const { return upperbound[i]; };
92 :     /**
93 :     * \brief This function will return the paramter name for a switch in the input file
94 :     * \param i is the index for the switch
95 :     * \return parameter name for the switch
96 :     */
97 :     Parameter getSwitch(int i) const { return switches[i]; };
98 :     #ifdef GADGET_NETWORK
99 :     /**
100 :     * \brief This function will read all the initial data that is sent to the model from the PVM network
101 :     */
102 :     void readFromNetwork();
103 :     /**
104 :     * \brief This function will send data to the PVM network from the model
105 :     * \param score is the likelihood score obtained from the current run, to be sent to the PVM master
106 :     */
107 :     void sendDataToNetwork(double score);
108 :     /**
109 :     * \brief This function will read updated data that is sent to the model from the PVM network
110 :     */
111 :     void readNextLineFromNetwork();
112 :     /**
113 :     * \brief This function will check to ensure that network communication has been successful
114 :     * \return getdata, a flag to denote whether network communication has been succesful or not
115 :     */
116 :     int getDataFromNetwork() { return getdata; };
117 :     #endif
118 :     protected:
119 :     /**
120 :     * \brief This is the InitialInputFile used to read from file the initial values and bounds of the parameters for the current model
121 :     */
122 :     InitialInputFile* readInfo;
123 :     /**
124 :     * \brief This is the ParameterVector used to store the parameters read from file
125 :     */
126 :     ParameterVector switches;
127 :     /**
128 :     * \brief This is the DoubleVector used to store the values of the parameters read from file
129 :     */
130 :     DoubleVector values;
131 :     /**
132 :     * \brief This is the DoubleVector used to store the lower bounds of the parameters read from file
133 :     */
134 :     DoubleVector lowerbound;
135 :     /**
136 :     * \brief This is the DoubleVector used to store the upper bounds of the parameters read from file
137 :     */
138 :     DoubleVector upperbound;
139 :     /**
140 :     * \brief This is the IntVector used to store the flag to denote whether to optimise the parameters read from file
141 :     */
142 :     IntVector optimise;
143 :     /**
144 :     * \brief This is the flag to denote whether gadget is running in network mode or not
145 :     */
146 :     int netrun;
147 :     #ifdef GADGET_NETWORK
148 :     /**
149 :     * \brief This is the SlaveCommunication that handles the network communication to send and receive data
150 :     */
151 :     SlaveCommunication* slave;
152 :     /**
153 :     * \brief This is the vector of parameters received from the network communication
154 :     */
155 :     double* dataFromMaster;
156 :     /**
157 :     * \brief This is the flag used to denote whether network communication has been succesful or not
158 :     */
159 :     int getdata;
160 :     #endif
161 :     };
162 :    
163 :     #endif

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge