KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_integral_optimization.h
Go to the documentation of this file.
1 /* =========================================================================== *
2 |
3 | Copyright (c) 1994-2008 by Kobus Barnard (author).
4 |
5 | Personal and educational use of this code is granted, provided that this
6 | header is kept intact, and that the authorship is not misrepresented, that
7 | its use is acknowledged in publications, and relevant papers are cited.
8 |
9 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10 |
11 | Please note that the code in this file has not necessarily been adequately
12 | tested. Naturally, there is no guarantee of performance, support, or fitness
13 | for any particular task. Nonetheless, I am interested in hearing about
14 | problems that you encounter.
15 |
16 | Authors:
17 | Ernesto Brau, Jinyan Guan
18 |
19 * =========================================================================== */
20 
21 /* $Id: pt_integral_optimization.h 18973 2015-04-29 23:56:03Z jguan1 $ */
22 
23 #ifndef PT_INTEGRAL_OPTIMIZATION_H
24 #define PT_INTEGRAL_OPTIMIZATION_H
25 
33 #include <string>
34 #include <vector>
35 #include <boost/foreach.hpp>
36 #include <boost/optional.hpp>
37 #include <boost/ref.hpp>
38 
39 #ifdef KJB_HAVE_ERGO
40 #include <ergo/hmc.h>
41 #include <ergo/mh.h>
42 #include <ergo/record.h>
43 #endif
44 
45 namespace kjb {
46 namespace pt {
47 
56 {
57 public:
58  Optimize_likelihood(const Scene_posterior& posterior, bool infer_head_off) :
59  sample_scenes_(posterior, !infer_head_off),
60  hess_step_size_(0.01),
61  estimate_hess_step_size_(true),
62  record_log_(false),
63  record_samples_(false),
64  record_proposals_(false),
65  record_pd_(false),
66  infer_head_(!infer_head_off)
67  {}
68 
70  void set_output_directory(const std::string& output_dir)
71  {
72  out_dir_ = output_dir;
73  }
74 
76  void set_hess_step_size(double hss)
77  {
78  hess_step_size_ = hss;
79  estimate_hess_step_size_ = false;
80  }
81 
83  void record_log(bool rl) { record_log_ = rl; }
84 
86  void record_samples(bool rs) { record_samples_ = rs; }
87 
89  void record_proposals(bool rp) { record_proposals_ = rp; }
90 
92  void record_posterior_details(bool rp) { record_pd_ = rp; }
93 
95  const Sample_scenes& sampler() const { return sample_scenes_; }
96 
98  Sample_scenes& sampler() { return sample_scenes_; }
99 
101  double operator()(const Scene& scene) const;
102 
103 private:
104  Sample_scenes sample_scenes_;
105  double hess_step_size_;
106  bool estimate_hess_step_size_;
107  std::string out_dir_;
108  bool record_log_;
109  bool record_samples_;
110  bool record_proposals_;
111  bool record_pd_;
112  bool infer_head_;
113 };
114 
115 }} // namespace kjb::pt
116 
117 #endif /*PT_INTEGRAL_OPTIMIZATION_H */
118 
void record_proposals(bool rp)
Turn recording of proposals on/off.
Definition: pt_integral_optimization.h:89
double operator()(const Scene &scene) const
Optimize likelihood.
Definition: pt_integral_optimization.cpp:56
Class that represents a full scene in the PT universe.
Definition: pt_scene.h:40
void record_samples(bool rs)
Turn recording of samples on/off.
Definition: pt_integral_optimization.h:86
Approximate complete-data likelihood via HMC optimziation.
Definition: pt_integral_optimization.h:55
const Sample_scenes & sampler() const
Return the internal sampler used to compute likelihood.
Definition: pt_integral_optimization.h:95
void set_hess_step_size(double hss)
Have HMC log its steps to the given file.
Definition: pt_integral_optimization.h:76
Use HMC to draw samples from the scene posterior using HMC.
Definition: pt_sample_scenes.h:96
Posterior distribution of a scene.
Definition: pt_scene_posterior.h:53
Sample_scenes & sampler()
Return the internal sampler used to compute likelihood.
Definition: pt_integral_optimization.h:98
void set_output_directory(const std::string &output_dir)
Have HMC log its steps to the given file.
Definition: pt_integral_optimization.h:70
Optimize_likelihood(const Scene_posterior &posterior, bool infer_head_off)
Definition: pt_integral_optimization.h:58
void record_posterior_details(bool rp)
Turn recording posterior details on/off.
Definition: pt_integral_optimization.h:92
void record_log(bool rl)
Turn recording of logs on/off.
Definition: pt_integral_optimization.h:83