Commit f5cb2e0a authored by Amelie Royer's avatar Amelie Royer
Browse files

Minor correction in utils.hpp and adding count of call to makesampledbelief

parent 5e0e05bb
...@@ -497,7 +497,7 @@ namespace AIToolbox { ...@@ -497,7 +497,7 @@ namespace AIToolbox {
typename PAMCP<M>::SampleBelief PAMCP<M>::makeSampledBelief(const Belief & b, size_t o) { typename PAMCP<M>::SampleBelief PAMCP<M>::makeSampledBelief(const Belief & b, size_t o) {
SampleBelief belief; SampleBelief belief;
belief.reserve(beliefSize_); belief.reserve(beliefSize_);
model_.bottleneck_call();
for ( size_t i = 0; i < beliefSize_; ++i ) for ( size_t i = 0; i < beliefSize_; ++i )
belief.push_back(sampleProbability(E, b, rand_) * O + o); belief.push_back(sampleProbability(E, b, rand_) * O + o);
......
...@@ -167,6 +167,15 @@ public: ...@@ -167,6 +167,15 @@ public:
*/ */
size_t get_rep(size_t s) const { return s % n_observations; }; size_t get_rep(size_t s) const { return s % n_observations; };
/*!
* \brief Returns the number of times the model transition function has been sampled
* since its creation.
*
* \return number of calls to the sampleSR function.
*/
int get_bottleneck_calls() const { return n_bottleneck_calls; };
int bottleneck_call() const { n_bottleneck_calls ++; }
/*! \brief Given a state, returns all its possible predecessors. /*! \brief Given a state, returns all its possible predecessors.
* *
* \param state unique state index. * \param state unique state index.
...@@ -200,6 +209,7 @@ protected: ...@@ -200,6 +209,7 @@ protected:
size_t n_actions; /*!< Number of actions in the model */ size_t n_actions; /*!< Number of actions in the model */
size_t n_observations; /*!< Number of observations in the model */ size_t n_observations; /*!< Number of observations in the model */
size_t n_environments; /*!< Number of environments */ size_t n_environments; /*!< Number of environments */
mutable int n_bottleneck_calls = 0; /*!<Number of times the transition sampling function has been called. Used for POMCP and PAMCP comparison*/
double discount; /*!< Discount factor */ double discount; /*!< Discount factor */
}; };
......
...@@ -362,7 +362,8 @@ void evaluate_from_file(std::string sfile, ...@@ -362,7 +362,8 @@ void evaluate_from_file(std::string sfile,
results.push_back(identification_s); results.push_back(identification_precision_s); results.push_back(identification_s); results.push_back(identification_precision_s);
} }
print_evaluation_result(model.getE(), results, titles, verbose); print_evaluation_result(model.getE(), results, titles, verbose);
std::cout << "\n > avglng: " << total_length / user; std::cout << "\n > avglng: " << (float)total_length / (float)user;
std::cout << "\n > avgsmpl: " << (float)model.get_bottleneck_calls() / (float)user;
std::cout << "\n\n"; std::cout << "\n\n";
} }
...@@ -442,8 +443,6 @@ void evaluate_interactive(int n_sessions, ...@@ -442,8 +443,6 @@ void evaluate_interactive(int n_sessions,
if (verbose) { if (verbose) {
std::cerr << " run " << user + 1 << " ignored: did not reach final state."; std::cerr << " run " << user + 1 << " ignored: did not reach final state.";
} }
identification_s.update(cluster, 0.);
identification_precision_s.update(cluster, 0);
success_s.update(cluster, 0); success_s.update(cluster, 0);
n_failures += 1; n_failures += 1;
continue; continue;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment