Commit 81f7f29f authored by Amelie Royer's avatar Amelie Royer

Cleaning main_MDP

parent 9d7d206b
...@@ -122,7 +122,7 @@ void load_model_parameters(std::string tfile, std::string rfile, ...@@ -122,7 +122,7 @@ void load_model_parameters(std::string tfile, std::string rfile,
kahan_correction = (aux - nrm) - val; kahan_correction = (aux - nrm) - val;
nrm = aux; nrm = aux;
} }
} }
// Else basic sum // Else basic sum
else { else {
nrm = std::accumulate(transition_matrix[s1][a], nrm = std::accumulate(transition_matrix[s1][a],
...@@ -133,65 +133,7 @@ void load_model_parameters(std::string tfile, std::string rfile, ...@@ -133,65 +133,7 @@ void load_model_parameters(std::string tfile, std::string rfile,
transition_matrix[s1][a] + n_actions, transition_matrix[s1][a] + n_actions,
transition_matrix[s1][a], transition_matrix[s1][a],
[nrm](const double t){ return t / nrm; } [nrm](const double t){ return t / nrm; }
); );
//double kahan_sum = 0
//KahanAccumulation init = {0.0};
//nrm = (std::accumulate(transition_matrix[s1][a],
// transition_matrix[s1][a] + n_actions, init, KahanSum)).sum;
//std::transform(transition_matrix[s1][a],
// transition_matrix[s1][a] + n_actions,
// transition_matrix[s1][a],
// [nrm](const double t){ return ((t/nrm < 0.0001) ? 0 : t / nrm); }
// );
//double nrm = normalization[s1][a];
//nrm = std::accumulate(numbers.begin(), numbers.end(), init, KahanSum);
// KahanAccumulation init = {0.0};
// nrm = (std::accumulate(transition_matrix[s1][a],
// transition_matrix[s1][a] + n_actions, init, KahanSum)).sum;
// std::transform(transition_matrix[s1][a],
// transition_matrix[s1][a] + n_actions,
// transition_matrix[s1][a],
// [nrm](const double t){ return ((t/nrm < 0.0001) ? 0 : t / nrm); }
// );
// init = {0.0};
// nrm = (std::accumulate(transition_matrix[s1][a],
// transition_matrix[s1][a] + n_actions, init, KahanSum)).sum;
//nrm = std::accumulate(transition_matrix[s1][a],
//transition_matrix[s1][a] + n_actions, 0.0);
// std::transform(transition_matrix[s1][a],
// transition_matrix[s1][a] + n_actions,
// transition_matrix[s1][a],
// [nrm](const double t){ return t / nrm; }
// );
// nrm = std::accumulate(transition_matrix[s1][a],
// transition_matrix[s1][a] + n_actions, 0.0);
/// if (AIToolbox::checkDifferentSmall(1.0, nrm)) {
// std::cout << "it is working though";
// std::cout << std::setprecision(15) << nrm << "wtf";
// }
/*std::transform(transition_matrix[s1][a],
transition_matrix[s1][a] + n_actions,
transition_matrix[s1][a],
[nrm](const double t){ return ((AIToolbox::checkDifferentSmall(t / nrm, 0.0)) ? t / nrm : 0.0); }
);
nrm = std::accumulate(transition_matrix[s1][a],
transition_matrix[s1][a] + n_actions, 0.0);
std::transform(transition_matrix[s1][a],
transition_matrix[s1][a] + n_actions,
transition_matrix[s1][a],
[nrm](const double t){ return t / nrm; }*
);*/
//double test = 0;
//for (size_t s2 = 0; s2 < n_actions; s2++) {
// test += transition_matrix[s1][a][s2];
// assert(("Im seriously crying", transition_matrix[s1][a][s2] >= 0 && transition_matrix[s1][a][s2] <= 1));
//}
//std::cout << "compare " << test << " " << nrm << "\n";
} }
} }
...@@ -320,7 +262,7 @@ int main(int argc, char* argv[]) { ...@@ -320,7 +262,7 @@ int main(int argc, char* argv[]) {
load_model_parameters(datafile_base + ".transitions", load_model_parameters(datafile_base + ".transitions",
datafile_base + ".rewards", datafile_base + ".rewards",
datafile_base + ".profiles", datafile_base + ".profiles",
datafile_base + ".summary", std::pow(10, precision)); datafile_base + ".summary", std::pow(10, precision));
auto elapsed = std::chrono::high_resolution_clock::now() - start; auto elapsed = std::chrono::high_resolution_clock::now() - start;
double loading_time = std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count() / 1000000.; double loading_time = std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count() / 1000000.;
......
...@@ -85,7 +85,7 @@ If needed, first set the correct library pathes in ``run.sh``. The script can th ...@@ -85,7 +85,7 @@ If needed, first set the correct library pathes in ``run.sh``. The script can th
* ``[8]`` Convergence criterion for mdp and ip. Defaults to 0.01. * ``[8]`` Convergence criterion for mdp and ip. Defaults to 0.01.
* ``[9]`` Exploration parameter for pomcp and memcp. Defaults to 10000 (high exploration). * ``[9]`` Exploration parameter for pomcp and memcp. Defaults to 10000 (high exploration).
* ``[10]`` Number of particles for the belief approximation in pomcp and memcp. Defaults to 100. * ``[10]`` Number of particles for the belief approximation in pomcp and memcp. Defaults to 100.
* ``[-p]`` If present, use Kahan summation for more precision while handling small probabilities. Use this option if AIToolbox throws an ``Input transition table does not contain valid probabilities`` error when creating the SparseModel object. (*Note*: this requires to use the ``SparseModel.hpp`` file given in ``Code/AiToolBox`` instead of the default AIToolBox one, as described in the first section). * ``[-p]`` If present, use Kahan summation for more precision while handling small probabilities. Use this option if AIToolbox throws an ``Input transition table does not contain valid probabilities`` error when creating the SparseModel object. (*Note*: this requires to use the ``SparseModel.hpp`` file given in ``Code/AiToolBox`` instead of the default AIToolbox one, as described in the first section).
* ``[-c]`` If present, recompile the code before running (*Note*: this should be used whenever using a dataset with different parameters as the number of items, environments etc are determined at compilation time). * ``[-c]`` If present, recompile the code before running (*Note*: this should be used whenever using a dataset with different parameters as the number of items, environments etc are determined at compilation time).
**Example** *(foodmart, 6 environments, 3 actions, 13 states)* : **Example** *(foodmart, 6 environments, 3 actions, 13 states)* :
......
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