#include <iostream>
#include <fstream>
+#include <stdlib.h>
using namespace std;
<< endl
<< " If a configuration file name is provided, the program processes it" << endl
<< " and prints information about the files it generates. Otherwise, it" << endl
- << " reads the standard input and does not produce any printout on the" <<
+ << " reads the standard input and does not produce any printout on the" << endl
<< " standard output unless an error occurs." << endl
<< endl;
exit(0);
else
solver.solve(room, &prior, proba_views, &proba_presence, f, 0);
- if(strcmp(result_view_format, "") != 0)
+ if(strcmp(result_view_format, "") != 0) {
for(int c = 0; c < room->nb_cameras(); c++) {
pomsprintf(buffer, buffer_size, result_view_format, c, f, 0);
if(configuration_file)
cout << "Saving " << buffer << endl;
room->save_stochastic_view(buffer, c, (*proba_views)[c], &proba_presence);
}
+ }
if(strcmp(result_format, "") != 0) {
pomsprintf(buffer, buffer_size, result_format, 0, f, 0);
else if(strcmp(buffer, "") == 0 || buffer[0] == '#') { }
else {
- cerr << "Unknown token " << token << ".";
+ cerr << "Unknown token " << token << "." << endl;
exit(1);
}
}
void POMSolver::solve(Room *room,
Vector<scalar_t> *prior,
Vector<ProbaView *> *views,
- Vector<scalar_t> *proba_presence,
+ Vector<scalar_t> *result_proba_presence,
int nb_frame,
char *convergence_file_format) {
scalar_t e = 0;
for(int i = 0; i < room->nb_positions(); i++) {
- scalar_t np = global_smoothing_coefficient * proba_absence[i] + (1 - global_smoothing_coefficient) / (1 + exp(log_prior_ratio[i] + sum[i]));
+ scalar_t np = global_smoothing_coefficient * proba_absence[i] +
+ (1 - global_smoothing_coefficient) / (1 + exp(log_prior_ratio[i] + sum[i]));
if(abs(proba_absence[i] - np) > e) e = abs(proba_absence[i] - np);
proba_absence[i] = np;
}
if(convergence_file_format) {
char buffer[buffer_size];
- for(int p = 0; p < room->nb_positions(); p++) (*proba_presence)[p] = 1 - proba_absence[p];
+ for(int p = 0; p < room->nb_positions(); p++) {
+ (*result_proba_presence)[p] = 1 - proba_absence[p];
+ }
+
for(int c = 0; c < room->nb_cameras(); c++) {
pomsprintf(buffer, buffer_size, convergence_file_format, c, nb_frame, it);
cout << "Saving " << buffer << "\n"; cout.flush();
- room->save_stochastic_view(buffer, c, (*views)[c], proba_presence);
+ room->save_stochastic_view(buffer, c, (*views)[c], result_proba_presence);
}
}
}
- for(int p = 0; p < room->nb_positions(); p++) (*proba_presence)[p] = 1 - proba_absence[p];
+ for(int p = 0; p < room->nb_positions(); p++) {
+ (*result_proba_presence)[p] = 1 - proba_absence[p];
+ }
}
POMSolver(Room *room);
// Uses the computation above for the various cameras and the prior
- // to refresh proba_absence. Iterates as many times as specified.
+ // to refresh proba_absence. Iterates as many times as
+ // specified. The two last parameters are used only to save images
+ // showing the convergence
void solve(Room *room,
Vector<scalar_t> *prior,
Vector<ProbaView *> *views,
- Vector<scalar_t> *proba_presence,
+ Vector<scalar_t> *result_proba_presence,
int nb_frame,
char *convergence_file_format);
};
#include <iostream>
#include <stdio.h>
+#include <stdlib.h>
using namespace std;