This file is indexed.

/usr/include/opengm/inference/external/daoopt.hxx is in libopengm-dev 2.3.6-2.

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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#ifndef DAOOPT_HXX_
#define DAOOPT_HXX_

#include "opengm/inference/inference.hxx"
#include "opengm/graphicalmodel/graphicalmodel.hxx"
#include "opengm/operations/minimizer.hxx"
#include "opengm/inference/inference.hxx"
#include "opengm/inference/visitors/visitors.hxx"


#include <Main.h>
#undef UNKNOWN

namespace daoopt{

   template<class V, class I>
   class OpengmVisitor : public daoopt::VisitorBase{
   public:
      OpengmVisitor(V& v, I& i) : visitor(v), inference(i) {};
      V& visitor;
      I& inference;
      virtual bool visit(){
         if(visitor(inference)==0) {return true;} 
         else {return false;}
      };
   };

}

namespace opengm {
   namespace external {

      /// DAOOPT
      /// DAOOPT inference algorithm class
      /// \ingroup inference
      /// \ingroup external_inference
      ///
      //    DAOOPT
      /// - cite :[?]
      /// - Maximum factor order : ?
      /// - Maximum number of labels : ?
      /// - Restrictions : ?
      /// - Convergent : ?
      template<class GM>
      class DAOOPT : public Inference<GM, opengm::Minimizer> {
      public:
         typedef GM                              GraphicalModelType;
         typedef opengm::Minimizer               AccumulationType;
         OPENGM_GM_TYPE_TYPEDEFS;
         typedef visitors::VerboseVisitor<DAOOPT<GM> > VerboseVisitorType;
         typedef visitors::EmptyVisitor<DAOOPT<GM> >   EmptyVisitorType;
         typedef visitors::TimingVisitor<DAOOPT<GM> >  TimingVisitorType;

         ///Parameter inherits from daoopt ProgramOptions
         struct Parameter : public daoopt::ProgramOptions {
            /// \brief Constructor
            Parameter() : daoopt::ProgramOptions() {
               // set default options, this is not done for all parameters by daoopt
               subprobOrder = 0;
               ibound = 10;
               cbound = 1000;
               cbound_worker = 1000;
               rotateLimit = 1000;
               order_iterations = 25;
               order_timelimit = -1;
               threads = -1;
               sampleDepth = 10;
               sampleRepeat = 1;
               aobbLookahead = 5;
            }
         };

         // construction
         DAOOPT(const GraphicalModelType& gm, const Parameter& para = Parameter());
         // destruction
         ~DAOOPT();
         // query
         std::string name() const;
         const GraphicalModelType& graphicalModel() const;
         // inference
         template<class VISITOR>
         InferenceTermination infer(VISITOR & visitor);
         InferenceTermination infer();
         InferenceTermination arg(std::vector<LabelType>&, const size_t& = 1) const;
         typename GM::ValueType bound() const;
         typename GM::ValueType value() const;

      protected:
         const GraphicalModelType& gm_;
         Parameter parameter_;
         daoopt::Main main_;
      };

      template<class GM>
      inline DAOOPT<GM>::DAOOPT(const typename DAOOPT<GM>::GraphicalModelType& gm, const Parameter& para)
         : gm_(gm), parameter_(para) {

         if(!main_.start()) {
            throw RuntimeError("Error starting DAOOPT main.");
         }

         // check options
         if (!parameter_.in_subproblemFile.empty() && parameter_.in_orderingFile.empty()) {
            throw RuntimeError("Error: Specifying a subproblem requires reading a fixed ordering from file.");
         }

         if (parameter_.subprobOrder < 0 || parameter_.subprobOrder > 3) {
            throw RuntimeError("Error: subproblem ordering has to be 0(width-inc), 1(width-dec), 2(heur-inc) or 3(heur-dec)");
         }

         if(parameter_.problemName.empty()) {
            //Extract the problem name
            if(parameter_.in_problemFile.empty()) {
               // set problem name to openGM
               parameter_.problemName = "openGM";
            } else {
               string& fname = parameter_.in_problemFile;
               size_t len, start, pos1, pos2;
               #if defined(WIN32)
                  pos1 = fname.find_last_of("\\");
               #elif defined(LINUX)
                  pos1 = fname.find_last_of("/");
               #endif
               pos2 = fname.find_last_of(".");
               if (pos1 == string::npos) { len = pos2; start = 0; }
               else { len = (pos2-pos1-1); start = pos1+1; }
               parameter_.problemName = fname.substr(start, len);
            }
         }

         // TODO set executable name (is this required by daoopt)???
         /*if(parameter_.executableName.empty()) {
            parameter_.executableName = ???
         }*/

         main_.setOptions(new daoopt::ProgramOptions(static_cast<daoopt::ProgramOptions>(parameter_)));

         if(!main_.outputInfo()) {
            throw RuntimeError("Error printing DAOOPT info.");
         }

         if(parameter_.in_problemFile.empty()) {
            daoopt::Problem* problem = new daoopt::Problem();
            if(!problem->convertOPENGM(gm_)) {
               throw RuntimeError("Error converting openGM to DAOOPT problem.");
            }
            main_.setProblem(problem);
         } else {
            if(!main_.loadProblem()) {
               throw RuntimeError("Error loading DAOOPT problem.");
            }
         }
      }

      template<class GM>
      inline DAOOPT<GM>::~DAOOPT() {

      }

      template<class GM>
      inline std::string DAOOPT<GM>::name() const {
         return "DAOOPT";
      }

      template<class GM>
      inline const typename DAOOPT<GM>::GraphicalModelType& DAOOPT<GM>::graphicalModel() const {
         return gm_;
      }

      template<class GM>
      inline InferenceTermination DAOOPT<GM>::infer() {
         EmptyVisitorType visitor;
         return this->infer(visitor);
      }

      template<class GM>
      template<class VISITOR>
      inline InferenceTermination DAOOPT<GM>::infer(VISITOR & visitor) {

         visitor.begin(*this);
         // TODO check for possible visitor injection method
 visitor(*this);
         if(!main_.runSLS()) {
            throw RuntimeError("Error running DAOOPT SLS.");
         }
visitor(*this);
         if(!main_.findOrLoadOrdering()) {
            throw RuntimeError("Error running DAOOPT find/load ordering.");
         }
 visitor(*this);
         if(!main_.initDataStructs()) {
            throw RuntimeError("Error initializing DAOOPT data structs.");
         }
 visitor(*this);
         if(!main_.compileHeuristic()) {
            throw RuntimeError("Error compiling DAOOPT heuristic.");
         }
 visitor(*this);
         if(!main_.runLDS()) {
            throw RuntimeError("Error running DAOOPT LDS.");
         }
 visitor(*this);
         if(!main_.finishPreproc()) {
            throw RuntimeError("Error finishing DAOOPT preprocessing.");
         }
visitor(*this);
         daoopt::OpengmVisitor<VISITOR, DAOOPT<GM> > v(visitor,*this);
         if(!main_.runSearch(v)) {
            throw RuntimeError("Error running DAOOPT search.");
         }
 visitor(*this);
         if(!main_.outputStats()) {
            throw RuntimeError("Error output DAOOPT stats.");
         }
 visitor(*this);
         visitor.end(*this);
         return NORMAL;
      }

      template<class GM>
      inline InferenceTermination DAOOPT<GM>::arg(std::vector<LabelType>& arg, const size_t& n) const {
         const daoopt::Problem& problem = main_.getProblem();

         const std::vector<daoopt::val_t>& assignment = problem.getSolutionAssg();
         if(assignment.size() == gm_.numberOfVariables()){
            arg.assign(assignment.begin(), assignment.end()-1);
         }
         else{
            std::cout <<"Warning: DAOOPT return labeling of wrong size!"<<std::endl;
            arg.resize(gm_.numberOfVariables(),0);
         }
         return NORMAL;
      }

      template<class GM>
      inline typename GM::ValueType DAOOPT<GM>::bound() const {
         return AccumulationType::ineutral<ValueType>();
      }

      template<class GM>
      inline typename GM::ValueType DAOOPT<GM>::value() const {
         //std::vector<LabelType> c;
         //arg(c);
         //return gm_.evaluate(c);

         const daoopt::Problem& problem = main_.getProblem();
         const ValueType v =  static_cast<ValueType>(-problem.getSolutionCost());
         if(isnan(v))
            return  std::numeric_limits<ValueType>::infinity();
         else
            return v;
      }
   } // namespace external
} // namespace opengm

#endif /* DAOOPT_HXX_ */