X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bayeswf.cpp;h=eee6882e4e18f59dcc9c2b8f37f950e22b3d6e13;hb=b0ef1678544b47f3ea93cf976f193d1976f29dc6;hp=bf92cc802a56290d980d399ba843e5abc54d1a18;hpb=ec604df6d1b32016fdb890d8c1f9d0df7e1fd2c1;p=wloh diff --git a/bayeswf.cpp b/bayeswf.cpp index bf92cc8..eee6882 100644 --- a/bayeswf.cpp +++ b/bayeswf.cpp @@ -264,9 +264,9 @@ void compute_mu_uncertainty(const float *mu, const vector &players) #else for (unsigned i = 0; i < players.size(); ++i) { for (unsigned j = 0; j < players.size(); ++j) { - printf("covariance %s %s %f\n", - players[i].c_str(), - players[j].c_str(), + printf("covariance %d %d %f\n", + players[i], + players[j], ih(i, j)); } } @@ -275,8 +275,6 @@ void compute_mu_uncertainty(const float *mu, const vector &players) void process_file(const char *filename) { - printf("%s...\n", filename); - global_sigma = 70.0f; prior_sigma = 70.0f; matches_for_player.clear(); @@ -408,7 +406,7 @@ void process_file(const char *filename) int main(int argc, char **argv) { #if USE_DB - pqxx::connection conn("dbname=wloh_dev host=127.0.0.1 user=wloh password=oto4iCh5"); + pqxx::connection conn("dbname=wloh host=127.0.0.1 user=wloh password=oto4iCh5"); #endif for (int i = 1; i < argc; ++i) { @@ -424,6 +422,23 @@ int main(int argc, char **argv) pqxx::work txn(conn); txn.exec("SET client_min_messages TO WARNING"); + // Dump aux_params. + { + txn.exec("TRUNCATE aux_params"); + pqxx::tablewriter writer(txn, "aux_params"); + for (map, float>::const_iterator it = aux_params.begin(); it != aux_params.end(); ++it) { + char str[128]; + snprintf(str, 128, "%f", it->second); + + vector tuple; + tuple.push_back(it->first.first); // locale + tuple.push_back(it->first.second); // parameter name + tuple.push_back(str); + writer.push_back(tuple); + } + writer.complete(); + } + // Dump ratings. { txn.exec("TRUNCATE ratings"); @@ -466,27 +481,12 @@ int main(int argc, char **argv) txn.exec("ALTER TABLE new_covariance ADD PRIMARY KEY ( player1, player2 );"); txn.exec("DROP TABLE IF EXISTS covariance"); txn.exec("ALTER TABLE new_covariance RENAME TO covariance"); - - // Dump aux_params. - { - txn.exec("TRUNCATE aux_params"); - pqxx::tablewriter writer(txn, "aux_params"); - for (map, float>::const_iterator it = aux_params.begin(); it != aux_params.end(); ++it) { - char str[128]; - snprintf(str, 128, "%f", it->second); - - vector tuple; - tuple.push_back(it->first.first); // locale - tuple.push_back(it->first.second); // parameter name - tuple.push_back(str); - writer.push_back(tuple); - } - writer.complete(); - } #else //fprintf(stderr, "Optimal sigma: %f (two-player: %f)\n", sigma[0], sigma[0] * sqrt(2.0f)); for (map, float>::const_iterator it = aux_params.begin(); it != aux_params.end(); ++it) { - printf("%s: aux_param %s %f\n", it->first->first, it->first->second, it->second); + printf("%s: aux_param %s %f\n", it->first.first.c_str(), it->first.second.c_str(), it->second); } #endif + + txn.commit(); }