diff options
| author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-03-23 17:48:38 -0400 | 
|---|---|---|
| committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-03-23 17:48:38 -0400 | 
| commit | 0c7e078d14dd7078ec4a5b3e77007609aec5e54c (patch) | |
| tree | e8c42237d3193ab83da42c1c0f8061a97674b013 /utils | |
| parent | 225ccd7b5a242e2a4381b71e4c794d82f560f8a3 (diff) | |
pf test
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/ccrp.h | 6 | 
1 files changed, 5 insertions, 1 deletions
| diff --git a/utils/ccrp.h b/utils/ccrp.h index 390d4994..8635b422 100644 --- a/utils/ccrp.h +++ b/utils/ccrp.h @@ -97,8 +97,10 @@ class CCRP {    }    // returns +1 or 0 indicating whether a new table was opened +  //   p = probability with which the particular table was selected +  //       excluding p0    template <typename T> -  int increment(const Dish& dish, const T& p0, MT19937* rng) { +  int increment(const Dish& dish, const T& p0, MT19937* rng, T* p = NULL) {      DishLocations& loc = dish_locs_[dish];      bool share_table = false;      if (loc.total_dish_count_) { @@ -112,6 +114,7 @@ class CCRP {             ti != loc.table_counts_.end(); ++ti) {          r -= (*ti - discount_);          if (r <= 0.0) { +          if (p) { *p = T(*ti - discount_) / T(strength_ + num_customers_); }            ++(*ti);            break;          } @@ -123,6 +126,7 @@ class CCRP {        }      } else {        loc.table_counts_.push_back(1u); +      if (p) { *p = T(strength_ + discount_ * num_tables_) / T(strength_ + num_customers_); }        ++num_tables_;      }      ++loc.total_dish_count_; | 
