KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Semantic_step_proposal.h
Go to the documentation of this file.
1 #ifndef SEMANTIC_STEP_PROPOSAL_H_
2 #define SEMANTIC_STEP_PROPOSAL_H_
3 
15 #include <boost/random/mersenne_twister.hpp>
16 #include <boost/random/discrete_distribution.hpp>
17 
18 namespace
19 {
20  const double minimum = 0.001;
21  const double mutability = 0.3;
22 }
23 
24 namespace semantics
25 {
27  {
28  public:
29  typedef boost::shared_ptr<Semantic_step_proposal> Self_ptr;
34  typedef boost::tuple<Step_code_t, Elab_ptr_const, Sem_event_ptr, Syn_event_ptr>
36  typedef boost::array<Proposal, Step_code::NUM_STEPS> Proposal_array;
38  typedef boost::random::discrete_distribution<> Proposal_dist;
39  static boost::mt19937 urng;
40  static bool VERBOSE;
41  public:
43 
49  bool propose(
50  const Elab_ptr_const semantic_parent,
51  const Sem_event_ptr sem_event,
52  const Syn_event_ptr syn_event,
53  const Step_code_t& curr_step,
54  const bool& tree_is_altered,
55  const bool& collins = false
56  );
57 
64  static double evaluate_a_proposal(
65  const Elab_ptr_const semantic_parent,
66  const Sem_event_ptr sem_event,
67  const Syn_event_ptr syn_event,
68  const Step_code_t step,
69  const bool& tree_is_altered,
70  const bool& collins = false
71  );
72 
75  static const double& min_prob()
76  {
77  static double mp = minimum;
78  return mp;
79  }
80 
83  static const double& mutability_prob()
84  {
85  static double mp = mutability;
86  return mp;
87  }
88 
89  Proposal state(){return state_;}
90  double prob(){return prob_;}
91  private:
94  void sample_a_proposal(
95  const Proposal_array& proposals,
96  const Proposal_dist& dist
97  );
98 
99  Proposal state_;
100  double prob_;
101  };
102 }
103 
104 #endif
boost::shared_ptr< Syntactic_event > Event_ptr
Definition: Syntactic_event.h:27
Elaboration_tree::Elab_ptr_const Elab_ptr_const
Definition: Semantic_step_proposal.h:31
static const double & min_prob()
a smoothing factor
Definition: Semantic_step_proposal.h:75
Semantic_step_proposal::Proposal Proposal
Definition: Semantic_step_proposal.cpp:38
Proposal state()
Definition: Semantic_step_proposal.h:89
Definition: Semantic_step_proposal.h:26
Elaboration_tree::Step_result Step_result
Definition: Semantic_step_proposal.h:37
Semantic_elaboration::Step_result Step_result
Definition: Elaboration_tree.h:40
bool propose(const Elab_ptr_const semantic_parent, const Sem_event_ptr sem_event, const Syn_event_ptr syn_event, const Step_code_t &curr_step, const bool &tree_is_altered, const bool &collins=false)
generate a proposal and store the result and the log prob
Definition: Semantic_step_proposal.cpp:202
double prob()
Definition: Semantic_step_proposal.h:90
Semantic_step_event::Event_ptr Sem_event_ptr
Definition: Semantic_step_proposal.h:33
Semantic_elaboration::Self_ptr Elab_ptr
Definition: Elaboration_tree.h:33
Semantic_step_proposal()
Definition: Semantic_step_proposal.cpp:160
Semantic_step_proposal::Proposal_dist Proposal_dist
Definition: Semantic_step_proposal.cpp:41
double dist(const pt a, const pt b)
compute approx. Great Circle distance between two UTM points
Definition: layer.cpp:45
Elaboration_tree::Elab_ptr Elab_ptr
Definition: Semantic_step_proposal.h:30
static double evaluate_a_proposal(const Elab_ptr_const semantic_parent, const Sem_event_ptr sem_event, const Syn_event_ptr syn_event, const Step_code_t step, const bool &tree_is_altered, const bool &collins=false)
given the current step, compute the probability of proposing it
Definition: Semantic_step_proposal.cpp:226
boost::shared_ptr< Semantic_step_event > Event_ptr
Definition: Semantic_step_event.h:18
boost::array< Proposal, Step_code::NUM_STEPS > Proposal_array
Definition: Semantic_step_proposal.h:36
Semantic_step_proposal::Proposal_array Proposal_array
Definition: Semantic_step_proposal.cpp:39
boost::random::discrete_distribution Proposal_dist
Definition: Semantic_step_proposal.h:38
static const double & mutability_prob()
probability of initiating a move for a subtree
Definition: Semantic_step_proposal.h:83
boost::shared_ptr< Semantic_step_proposal > Self_ptr
Definition: Semantic_step_proposal.h:29
static boost::mt19937 urng
Definition: Semantic_step_proposal.h:39
static bool VERBOSE
Member definitions.
Definition: Semantic_step_proposal.h:40
Semantic_elaboration::Self_ptr_const Elab_ptr_const
Definition: Elaboration_tree.h:34
Code
Definition: SemanticIO.h:54
Syntactic_event::Event_ptr Syn_event_ptr
Definition: Semantic_step_proposal.h:32
boost::tuple< Step_code_t, Elab_ptr_const, Sem_event_ptr, Syn_event_ptr > Proposal
Definition: Semantic_step_proposal.h:35