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 1 - (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 :     StochasticData(const char* const filename, int p);
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 :     */
32 :     StochasticData(const char* const filename);
33 :     /**
34 :     * \brief This is the default StochasticData destructor
35 :     */
36 :     virtual ~StochasticData();
37 :     /**
38 :     * \brief This function will read the next line of data from the input file
39 :     * \note This function is only called if the input file has data using the 'repeated values' format
40 :     */
41 :     void readNextLine();
42 :     /**
43 :     * \brief This function will check to see if there is more data to read in the input file
44 :     * \return 1 if there is more data to read from the input file, 0 otherwise
45 :     */
46 :     int isDataLeft() { return readInfo->isDataLeft(); };
47 :     /**
48 :     * \brief This function will return the number of variables read from the input file
49 :     * \return number of variables
50 :     */
51 :     int numVariables() const { return values.Size(); };
52 :     /**
53 :     * \brief This function will return the number of switches read from the input file
54 :     * \return number of switches
55 :     */
56 :     int numSwitches() const { return switches.Size(); };
57 :     /**
58 :     * \brief This function will check to see if optimising flags have been specified in the input file
59 :     * \return 1 if the optimising flags have been specified, 0 otherwise
60 :     */
61 :     int isOptGiven() const;
62 :     /**
63 :     * \brief This function will return the optimising flag for a switch in the input file
64 :     * \param i is the index for the switch
65 :     * \return optimise flag for the switch
66 :     */
67 :     int getOptFlag(int i) const;
68 :     /**
69 :     * \brief This function will return the value of a switch in the input file
70 :     * \param i is the index for the switch
71 :     * \return value of the switch
72 :     */
73 :     double getValue(int i) const { return values[i]; };
74 :     /**
75 :     * \brief This function will return the lower bound for a switch in the input file
76 :     * \param i is the index for the switch
77 :     * \return lower bound for the switch
78 :     */
79 :     double getLowerBound(int i) const { return lowerbound[i]; };
80 :     /**
81 :     * \brief This function will return the upper bound for a switch in the input file
82 :     * \param i is the index for the switch
83 :     * \return upper bound for the switch
84 :     */
85 :     double getUpperBound(int i) const { return upperbound[i]; };
86 :     /**
87 :     * \brief This function will return the paramter name for a switch in the input file
88 :     * \param i is the index for the switch
89 :     * \return parameter name for the switch
90 :     */
91 :     Parameter getSwitch(int i) const { return switches[i]; };
92 :     #ifdef GADGET_NETWORK
93 :     /**
94 :     * \brief This function will read all the initial data that is sent to the model from the PVM network
95 :     */
96 :     void readFromNetwork();
97 :     /**
98 :     * \brief This function will send data to the PVM network from the model
99 :     * \param score is the likelihood score obtained from the current run, to be sent to the PVM master
100 :     */
101 :     void sendDataToNetwork(double score);
102 :     /**
103 :     * \brief This function will read updated data that is sent to the model from the PVM network
104 :     */
105 :     void readNextLineFromNetwork();
106 :     /**
107 :     * \brief This function will check to ensure that network communication has been successful
108 :     * \return getdata, a flag to denote whether network communication has been succesful or not
109 :     */
110 :     int getDataFromNetwork() { return getdata; };
111 :     #endif
112 :     protected:
113 :     /**
114 :     * \brief This is the InitialInputFile used to read from file the initial values and bounds of the parameters for the current model
115 :     */
116 :     InitialInputFile* readInfo;
117 :     /**
118 :     * \brief This is the ParameterVector used to store the parameters read from file
119 :     */
120 :     ParameterVector switches;
121 :     /**
122 :     * \brief This is the DoubleVector used to store the values of the parameters read from file
123 :     */
124 :     DoubleVector values;
125 :     /**
126 :     * \brief This is the DoubleVector used to store the lower bounds of the parameters read from file
127 :     */
128 :     DoubleVector lowerbound;
129 :     /**
130 :     * \brief This is the DoubleVector used to store the upper bounds of the parameters read from file
131 :     */
132 :     DoubleVector upperbound;
133 :     /**
134 :     * \brief This is the IntVector used to store the flag to denote whether to optimise the parameters read from file
135 :     */
136 :     IntVector optimise;
137 :     /**
138 :     * \brief This is the flag to denote whether gadget is running in network mode or not
139 :     */
140 :     int netrun;
141 :     #ifdef GADGET_NETWORK
142 :     /**
143 :     * \brief This is the SlaveCommunication that handles the network communication to send and receive data
144 :     */
145 :     SlaveCommunication* slave;
146 :     /**
147 :     * \brief This is the vector of parameters received from the network communication
148 :     */
149 :     double* dataFromMaster;
150 :     /**
151 :     * \brief This is the flag used to denote whether network communication has been succesful or not
152 :     */
153 :     int getdata;
154 :     #endif
155 :     };
156 :    
157 :     #endif

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

Powered By FusionForge