This file is indexed.

/usr/include/JAGS/model/Model.h is in jags 3.4.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#ifndef MODEL_H_
#define MODEL_H_

#include <graph/Graph.h>
#include <model/MonitorControl.h>

#include <vector>
#include <list>
#include <string>

class Sampler;
class SamplerFactory;
class RNG;
class RNGFactory;
class MonitorFactory;
class StochasticNode;
class DeterministicNode;
class ConstantNode;

/**
 * @short Graphical model 
 *
 * The purpose of the model class is to collect together all the
 * elements necessary to run an MCMC sampler on a graphical model.
 */
class Model {
protected:
  std::vector<Sampler*> _samplers;
private:
  unsigned int _nchain;
  std::vector<RNG *> _rng;
  unsigned int _iteration;
  Graph _graph;
  std::set<Node*> _extra_nodes;
  std::vector<Node*> _sampled_extra;
  std::list<MonitorControl> _monitors;
  std::list<Monitor*> _default_monitors;
  std::vector<StochasticNode*> _stochastic_nodes;
  bool _is_initialized;
  bool _adapt;
  bool _data_gen;
  void initializeNodes();
  void chooseRNGs();
  void chooseSamplers();
  void setSampledExtra();
public:
  /**
   * @param nchain Number of parallel chains in the model.
   */
  Model(unsigned int nchain);
  virtual ~Model();
  /**
   * Returns the Graph associated with the model. This graph contains
   * all the nodes in the model
   */
  Graph const &graph();
  /**
   * Initializes the model.  Initialization takes place in three steps.
   *
   * Firstly, random number generators are assigned to any chain that
   * doesn not already have an RNG.
   * 
   * Secondly, all nodes in the graph are initialized in forward
   * sampling order. 
   *
   * Finally, samplers are chosen for informative nodes in the graph.
   *
   * @param datagen Boolean flag indicating whether the model should
   * be considered a data generating model. If false, then
   * non-informative nodes will not be updated unless they are being
   * monitored.  This makes sampling more efficient by avoiding
   * redundant updates.  If true, then all nodes in the graph will be
   * updated in each iteration.
   *
   * @see Node#initialize, Model#rngFactories
   */
  void initialize(bool datagen);
  /** Returns true if the model has been initialized */
  bool isInitialized();
  /**
   * Updates the model by the given number of iterations. A
   * logic_error is thrown if the model is uninitialized.
   *
   * @param niter Number of iterations to run
   */
  void update(unsigned int niter);
  /**
   * Returns the current iteration number 
   */
  unsigned int iteration() const;
  /**
   * Adds a monitor to the model so that it will be updated at each
   * iteration.  This can only be done if Model#adaptOff has been
   * successfully called. Otherwise, a logic_error is thrown.
   */
  void addMonitor(Monitor *monitor, unsigned int thin);
  /**
   * Clears the monitor from the model, so that it will no longer
   * be updated. If the monitor has not previously been added to the
   * model, this function has no effect.
   */
  void removeMonitor(Monitor *monitor);
  /**
   * Returns the list of Monitors 
   */
  std::list<MonitorControl> const &monitors() const;
  /**
   * Adds a stochastic node to the model.  The node must be
   * dynamically allocated.  The model is responsible for memory
   * management of the added node and will delete the node when it is
   * destroyed.
   */
  void addNode(StochasticNode *node);
  /**
   * Adds a deterministc node to the model.  The node must be
   * dynamically allocated.  The model is responsible for memory
   * management of the added node and will delete the node when it is
   * destroyed.
   */
  void addNode(DeterministicNode *node);
  /**
   * Adds a constant node to the model.  The node must be dynamically
   * allocated.  The model is responsible for memory management of the
   * added node and will delete the node when it is destroyed.
   */
  void addNode(ConstantNode *node);
  /**
   * After the model is initialized, extra uninformative nodes may be
   * added to the graph.  The model takes responsibility for updating
   * the extra node.
   *
   * The extra node cannot be observed, it must not already be in the
   * model graph, it may not have any children, and all of its parents
   * must be in the graph.
   */
  void addExtraNode(Node *node);
  /**
   * Access the list of sampler factories, which is common to all
   * models. This is used during initialization to choose samplers.
   * Each sampler factory is paired with a boolean flag which is used
   * to determine whether the factory is active or not
   *
   * @seealso Model#chooseSamplers
   */
  static std::list<std::pair<SamplerFactory *, bool> > &samplerFactories();
  /**
   * Access the list of RNG factories, which is common to all models.
   * Each factory is paired with a boolean flag which is used to determine
   * whether the factory is active or not.
   */
  static std::list<std::pair<RNGFactory *, bool> > &rngFactories();
  /**
   * Access the list of monitor factories, which is commmon to all models
   * Each factory is paired with a boolean flag which is used to determine
   * whether the factory is active or not.
   */
  static std::list<std::pair<MonitorFactory *, bool> > &monitorFactories();
  /**
   * Returns the number of chains in the model
   */
  unsigned int nchain() const;
  /**
   * Returns the RNG object associated with the given chain. If no RNG
   * has been assigned, then a NULL pointer is returned.
   */
  RNG *rng(unsigned int nchain) const;
  /**
   * Assigns a new RNG object to the given chain. The list of
   * RNGFactory objects is traversed and each factory is requested to
   * generate a new RNG object of the given name.
   *
   * @return success indicator.
   */
  bool setRNG(std::string const &name, unsigned int chain);
  /**
   * Assigns an existing RNG object to the given chain
   *
   * @return success indicator
   */
  bool setRNG(RNG *rng, unsigned int chain);
  /**
   * Tests whether all samplers in adaptive mode have passed the
   * efficiency test that allows adaptive mode to be switched off
   *
   * @see Sampler#checkAdaptation
   */
  bool checkAdaptation() const;
  /**
   * Turns off adaptive phase of all samplers.
   *
   * @see Sampler#adaptOff
   */
  void adaptOff();
  /**
   * Indicates whether the model is in adaptive mode (before the
   * adaptOff function has been called).
   */
  bool isAdapting() const;
  /**
   * Returns a vector of all stochastic nodes in the model
   */
  std::vector<StochasticNode*> const &stochasticNodes() const;
};

#endif /* MODEL_H_ */