diff --git a/src/examples/test_sparsification_convergence.cpp b/src/examples/test_sparsification_convergence.cpp
index 5564514cc90492563ed986df13b318760bcbcea1..67596f534a3e57c8a164f64e05460b35ba791d8a 100644
--- a/src/examples/test_sparsification_convergence.cpp
+++ b/src/examples/test_sparsification_convergence.cpp
@@ -129,29 +129,30 @@ int main(int argc, char** argv)
 
 
         // COMPARED TOPOLOGIES
+        std::string log_files_path;
         Scalar max_time = 0.1;
         unsigned int max_iter = 10000000;
         std::map<std::string,PruningOptions> options_map;
-        //                                                                 local Topol  Topol        optim     initial             ----------------------------- only for optimization ----------------------------------------------
-        //                   name                      dataset  pruning    solve Method Size   Gamma method    guess    connected (max_iter  max_time  min_gradient  Hessian   init_rho rho_decrease min_gradient_rho cyclic apply_closed_form formulation)
-        options_map.emplace("IP-Id",    PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 1,       0.5,         1,               true,  true,             0));
-//        options_map.emplace("IP-Id",    PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.5,         0.1,             true,  true,             0));
-//        options_map.emplace("IP2-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.5,         0.5,             true,  true,             0));
-//        options_map.emplace("IP3-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.5,         1,               true,  true,             0));
-//        options_map.emplace("IP4-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 1,       0.5,         0.1,             true,  true,             0));
-//        options_map.emplace("IP5-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 1,       0.5,         0.5,             true,  true,             0));
-//        options_map.emplace("IP4-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.1,         0.1,             true,  true,             0));
-//        options_map.emplace("IP5-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.1,         0.5,             true,  true,             0));
-//        options_map.emplace("IP6-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.1,         1,               true,  true,             0));
-//        options_map.emplace("IP7-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.5,         0.1,             true,  true,             0));
-//        options_map.emplace("IP8-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.5,         0.5,             true,  true,             0));
-//        options_map.emplace("IP9-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.5,         1,               true,  true,             0));
-//        options_map.emplace("IP10-Id",  PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.1,         0.1,             true,  true,             0));
-//        options_map.emplace("IP11-Id",  PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.1,         0.5,             true,  true,             0));
-//        options_map.emplace("IP12-Id",  PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.1,         1,               true,  true,             0));
-        options_map.emplace("FD-Id",    PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, FD,       ID,      false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("FD-ODB",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("FD-FFD",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, FD,       FFD,     false,     max_iter, max_time, 1e-9,         ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        //                                                                 local Topol  Topol        optim     initial                            ----------------------------- only for optimization ----------------------------------------------
+        //                   name                      dataset  pruning    solve Method Size   Gamma method    guess    connected  log_files_path (max_iter  max_time  min_gradient  Hessian   init_rho rho_decrease min_gradient_rho cyclic apply_closed_form formulation)
+        options_map.emplace("IP-Id",    PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 1,       0.5,         1,               true,  true,             0));
+//        options_map.emplace("IP-Id",    PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.5,         0.1,             true,  true,             0));
+//        options_map.emplace("IP2-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.5,         0.5,             true,  true,             0));
+//        options_map.emplace("IP3-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.5,         1,               true,  true,             0));
+//        options_map.emplace("IP4-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 1,       0.5,         0.1,             true,  true,             0));
+//        options_map.emplace("IP5-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 1,       0.5,         0.5,             true,  true,             0));
+//        options_map.emplace("IP4-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.1,         0.1,             true,  true,             0));
+//        options_map.emplace("IP5-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.1,         0.5,             true,  true,             0));
+//        options_map.emplace("IP6-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.5,     0.1,         1,               true,  true,             0));
+//        options_map.emplace("IP7-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.5,         0.1,             true,  true,             0));
+//        options_map.emplace("IP8-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.5,         0.5,             true,  true,             0));
+//        options_map.emplace("IP9-Id",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.5,         1,               true,  true,             0));
+//        options_map.emplace("IP10-Id",  PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.1,         0.1,             true,  true,             0));
+//        options_map.emplace("IP11-Id",  PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.1,         0.5,             true,  true,             0));
+//        options_map.emplace("IP12-Id",  PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, IP,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.1,     0.1,         1,               true,  true,             0));
+        options_map.emplace("FD-Id",    PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, FD,       ID,      false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("FD-ODB",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("FD-FFD",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, FD,       FFD,     false,     log_files_path, max_iter, max_time, 1e-9,         ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
 
         unsigned int N_options = options_map.size();
         unsigned int N_problems(0);
diff --git a/src/examples/test_sparsification_topology.cpp b/src/examples/test_sparsification_topology.cpp
index 8c7eba60c085e5ada05de125d3b4cf731c3f40fe..cd67763934f83d969611bf635d6f575edf2804fe 100644
--- a/src/examples/test_sparsification_topology.cpp
+++ b/src/examples/test_sparsification_topology.cpp
@@ -145,39 +145,40 @@ int main(int argc, char** argv)
 
 
         // COMPARED TOPOLOGIES
+        std::string log_files_path;
         Scalar max_time = 0.1;
         unsigned int max_iter = 10000000;
         std::map<std::string,PruningOptions> options_map;
-        //                                                                 local Topol  Topol        optim     initial             ----------------------------- only for optimization ----------------------------------------------
-        //                   name                      dataset  pruning    solve Method Size   Gamma method    guess    connected (max_iter  max_time  min_gradient  Hessian   init_rho rho_decrease min_gradient_rho cyclic apply_closed_form formulation)
-        options_map.emplace("CLT_MI",   PruningOptions(dataset, 0,         true, MI,    N_CLT, 1.0,  NO_OPTIM, NO_INIT, false));
-        options_map.emplace("CLT_TD2",  PruningOptions(dataset, 0,         true, TD2,   N_CLT, 1.0,  NO_OPTIM, NO_INIT, false));
-
-        options_map.emplace("SG_MI",    PruningOptions(dataset, 0,         true, MI,    N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SG_MI2",   PruningOptions(dataset, 0,         true, MI2,   N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SG_MI3",   PruningOptions(dataset, 0,         true, MI3,   N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SG_TD1",   PruningOptions(dataset, 0,         true, TD1,   N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SG_TD2",   PruningOptions(dataset, 0,         true, TD2,   N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        //options_map.emplace("SG_MOR",   PruningOptions(dataset, 0,         true, MOR,   N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SG_OD1",   PruningOptions(dataset, 0,         true, OD1,   N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SG_OD2",   PruningOptions(dataset, 0,         true, OD2,   N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SG_OD3",   PruningOptions(dataset, 0,         true, OD3,   N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-
-        options_map.emplace("SGF_MI",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SGF_MI2",  PruningOptions(dataset, 0,         true, MI2,   N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SGF_MI3",  PruningOptions(dataset, 0,         true, MI3,   N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SGF_TD1",  PruningOptions(dataset, 0,         true, TD1,   N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SGF_TD2",  PruningOptions(dataset, 0,         true, TD2,   N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        //options_map.emplace("SGF_MOR",  PruningOptions(dataset, 0,         true, MOR,   N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SGF_OD1",  PruningOptions(dataset, 0,         true, OD1,   N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SGF_OD2",  PruningOptions(dataset, 0,         true, OD2,   N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-        options_map.emplace("SGF_OD3",  PruningOptions(dataset, 0,         true, OD3,   N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        //                                                                 local Topol  Topol        optim     initial                            ----------------------------- only for optimization ----------------------------------------------
+        //                   name                      dataset  pruning    solve Method Size   Gamma method    guess    connected  log_files_path (max_iter  max_time  min_gradient  Hessian   init_rho rho_decrease min_gradient_rho cyclic apply_closed_form formulation)
+        options_map.emplace("CLT_MI",   PruningOptions(dataset, 0,         true, MI,    N_CLT, 1.0,  NO_OPTIM, NO_INIT, false,     log_files_path));
+        options_map.emplace("CLT_TD2",  PruningOptions(dataset, 0,         true, TD2,   N_CLT, 1.0,  NO_OPTIM, NO_INIT, false,     log_files_path));
+
+        options_map.emplace("SG_MI",    PruningOptions(dataset, 0,         true, MI,    N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SG_MI2",   PruningOptions(dataset, 0,         true, MI2,   N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SG_MI3",   PruningOptions(dataset, 0,         true, MI3,   N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SG_TD1",   PruningOptions(dataset, 0,         true, TD1,   N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SG_TD2",   PruningOptions(dataset, 0,         true, TD2,   N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        //options_map.emplace("SG_MOR",   PruningOptions(dataset, 0,         true, MOR,   N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SG_OD1",   PruningOptions(dataset, 0,         true, OD1,   N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SG_OD2",   PruningOptions(dataset, 0,         true, OD2,   N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SG_OD3",   PruningOptions(dataset, 0,         true, OD3,   N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+
+        options_map.emplace("SGF_MI",   PruningOptions(dataset, 0,         true, MI,    N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SGF_MI2",  PruningOptions(dataset, 0,         true, MI2,   N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SGF_MI3",  PruningOptions(dataset, 0,         true, MI3,   N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SGF_TD1",  PruningOptions(dataset, 0,         true, TD1,   N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SGF_TD2",  PruningOptions(dataset, 0,         true, TD2,   N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        //options_map.emplace("SGF_MOR",  PruningOptions(dataset, 0,         true, MOR,   N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SGF_OD1",  PruningOptions(dataset, 0,         true, OD1,   N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SGF_OD2",  PruningOptions(dataset, 0,         true, OD2,   N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+        options_map.emplace("SGF_OD3",  PruningOptions(dataset, 0,         true, OD3,   N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
 
         if (run_BEST)
         {
-            options_map.emplace("CLT_BEST", PruningOptions(dataset, 0,         true, BEST,  N_CLT, 1.0,  NO_OPTIM, NO_INIT, false));
-            options_map.emplace("SG_BEST",  PruningOptions(dataset, 0,         true, BEST,  N_CLT, 1.5,  FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
-            options_map.emplace("SGF_BEST", PruningOptions(dataset, 0,         true, BEST,  N_FILL,0.75, FD,       ODB,     false,     max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+            options_map.emplace("CLT_BEST", PruningOptions(dataset, 0,         true, BEST,  N_CLT, 1.0,  NO_OPTIM, NO_INIT, false,     log_files_path));
+            options_map.emplace("SG_BEST",  PruningOptions(dataset, 0,         true, BEST,  N_CLT, 1.5,  FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
+            options_map.emplace("SGF_BEST", PruningOptions(dataset, 0,         true, BEST,  N_FILL,0.75, FD,       ODB,     false,     log_files_path, max_iter, max_time, 0.001,        ANALYTIC, 0.0,     0.0,         0.0,             true,  true,             1));
         }
 
         unsigned int N_options = options_map.size();
diff --git a/src/pruning/problem_pruning.cpp b/src/pruning/problem_pruning.cpp
index a05dbb322f0c9042e3c10dc249b44dd8694dce12..be73944a8701ddc0d0db64bed0987ebc0d65465e 100644
--- a/src/pruning/problem_pruning.cpp
+++ b/src/pruning/problem_pruning.cpp
@@ -25,29 +25,20 @@ ProblemPruning::ProblemPruning(const std::string& _frame_structure, const std::s
         Problem(_frame_structure),
         name_(_name),
         options_(_options),
+        t_topology_(0.0),
         t_sparsification_(0.0),
         last_removed_fr_it_(trajectory_ptr_->getFrameList().end())
 
 {
     sensor_ptr_ = installSensor("ODOM 2D", "OdometryBL", Eigen::VectorXs::Zero(3), IntrinsicsBasePtr());
 
-    // store all problems solved
-    if (options_.pruning_T_ != 0)
-    {
-        std::string filepath = getenv("DATASET_PATH") + std::string("/logfiles/") + options_.dataset_ + std::string("/") + name_ + "_" + std::to_string(options_.pruning_T_) + std::string("_problems.txt");
-        problems_file_.open(filepath, std::ofstream::out); //open log file
-        if (!problems_file_.is_open())
-            std::cout << std::endl << "Failed to open the problem sizes file " << filepath << std::endl;
-    }
-
+    // Default log_files_path
+    std::string log_files_path = (options_.log_files_path_.empty() ? getenv("DATASET_PATH") + std::string("/logfiles/") : options_.log_files_path_) ;
     // store all original distributions
-    if (options_.pruning_T_ != 0)
-    {
-        std::string filepath = getenv("DATASET_PATH") + std::string("/logfiles/") + options_.dataset_ + std::string("/topology_test/") + name_ + "_" + std::to_string(options_.pruning_T_) + std::string("_originals.txt");
-        originals_file_.open(filepath, std::ofstream::out); //open log file
-        if (!originals_file_.is_open())
-            std::cout << std::endl << "Failed to open the originals file " << filepath << std::endl;
-    }
+    std::string filepath = log_files_path + options_.dataset_ + std::string("/topology_test/") + name_ + "_" + std::to_string(options_.pruning_T_) + std::string("_originals.txt");
+    originals_file_.open(filepath, std::ofstream::out); //open log file
+    if (!originals_file_.is_open())
+        std::cout << std::endl << "Failed to open the originals file " << filepath << std::endl;
 }
 
 ProblemPruningPtr ProblemPruning::create(const std::string& _frame_structure, const std::string& _name, const PruningOptions& _options) // USE THIS AS A CONSTRUCTOR!
@@ -61,44 +52,51 @@ ProblemPruning::~ProblemPruning()
 {
     if (options_.pruning_T_ != 0)
     {
-        // copy data to problems file
+        // Default log_files_path
+        std::string log_files_path = (options_.log_files_path_.empty() ? getenv("DATASET_PATH") + std::string("/logfiles/") : options_.log_files_path_) ;
+
+        // OPEN FILE
+        // store all problems solved
+        std::string filepath = log_files_path + options_.dataset_ + std::string("/") + name_ + "_" + std::to_string(options_.pruning_T_) + std::string("_problems.txt");
+        problems_file_.open(filepath, std::ofstream::out); //open log file
+        if (!problems_file_.is_open())
+            std::cout << std::endl << "Failed to open the problem sizes file " << filepath << std::endl;
+
+        // FILL FILE
         //std::cout << "Writing file " << name_ << "_problem_sizes.txt" << std::endl;
-        //std::cout << "KLDs:\n";
+
+        // KLD
         for (auto kld : KLDs_)
-        {
-            //std::cout << kld << " ";
             problems_file_ << kld << " ";
-        }
-        //std::cout << std::endl;
         problems_file_ << std::endl;
-        //std::cout << "RMSE:\n";
+
+        // RMSE
         for (auto rmse : RMSEs_)
-        {
-            //std::cout << kld << " ";
             problems_file_ << rmse << " ";
-        }
-        //std::cout << std::endl;
         problems_file_ << std::endl;
-        //std::cout << "MB_sizes_:\n";
+
+        // MB sizes
         for (auto mb_size : MB_sizes_)
-        {
-            //std::cout << mb_size << " ";
             problems_file_ << mb_size << " ";
-        }
-        //std::cout << std::endl;
         problems_file_ << std::endl;
-        //std::cout << "Total sparsification time:" << t_sparsification_ << "s\n";
-        problems_file_ << t_sparsification_;
-        //std::copy(KLDs_.begin(),KLDs_.end(),std::ostream_iterator<Scalar>(problems_file_," "));
-        //problems_file_ << std::endl;
-        //std::copy(MB_sizes_.begin(),MB_sizes_.end(),std::ostream_iterator<Scalar>(problems_file_," "));
+
+        // Sparsification time
+        problems_file_ << t_sparsification_ << std::endl;
+
+        // Topology time
+        problems_file_ << t_topology_ << std::endl;
+
+        // N factors
+        ConstraintBaseList all_ctr;
+        trajectory_ptr_->getConstraintList(all_ctr);
+        problems_file_ << all_ctr.size() << std::endl;
+
         // Close file
         problems_file_.close();
-    }
 
-    // close original distributions file
-    if (options_.pruning_T_ != 0)
+        // close original distributions file
         originals_file_.close();
+    }
 }
 
 void computeAb(const ConstraintBaseList& _ctr_list, const std::map<StateBlockPtr, unsigned int>& _sb_2_col, const std::map<ConstraintBasePtr, unsigned int>& _ctr_2_row,
@@ -966,8 +964,10 @@ void ProblemPruning::sparsify()
 
             // compute topology
             ConstraintBaseList new_ctrs = computeTopology(markov_blanket, Lambda, mean, iD, U, sb_2_col, fr_2_col, options_, options_.optim_options_, sensor_ptr_);
+            t_topology_ += ((Scalar) clock() - clock_0_) / CLOCKS_PER_SEC;
 
             // SPARSIFICATION
+            clock_0_ = clock();
             //std::cout << "SPARSIFICATION" << std::endl;
             // new constraints map
             //std::cout << "new constraints map " << new_ctrs.size() << std::endl;
diff --git a/src/pruning/problem_pruning.h b/src/pruning/problem_pruning.h
index d18a7ae0ba1c82111aeeff4543aa02f315eeb10a..a86a7dc79da2c5152f5074a4ab8fb7c5e5d2994a 100644
--- a/src/pruning/problem_pruning.h
+++ b/src/pruning/problem_pruning.h
@@ -180,10 +180,11 @@ struct PruningOptions
     TopologySize topology_size_;
     Scalar gamma_topology_;
     bool connected_;
+    std::string log_files_path_;
 
     PruningOptimOptions optim_options_;
 
-    PruningOptions(const std::string& dataset, const unsigned int& pruning_T, const bool& local_solve, const TopologyMethod& topology_method, const TopologySize& topology_size, const Scalar& gamma_topology, const optimMethod& optim_metod, const initMethod& initial_guess, const bool connected, const unsigned int& max_iter=0, const Scalar& max_time=0, const Scalar& min_gradient=0, const HessianMethod& hessian_method=ANALYTIC, const Scalar& init_rho = 0, const Scalar& rho_decrease=0, const Scalar& min_gradient_rho=0, const int cyclic=0, const bool& apply_closed_form=false, const int& formulation=0) :
+    PruningOptions(const std::string& dataset, const unsigned int& pruning_T, const bool& local_solve, const TopologyMethod& topology_method, const TopologySize& topology_size, const Scalar& gamma_topology, const optimMethod& optim_metod, const initMethod& initial_guess, const bool connected, const std::string& log_files_path = std::string(), const unsigned int& max_iter=0, const Scalar& max_time=0, const Scalar& min_gradient=0, const HessianMethod& hessian_method=ANALYTIC, const Scalar& init_rho = 0, const Scalar& rho_decrease=0, const Scalar& min_gradient_rho=0, const int cyclic=0, const bool& apply_closed_form=false, const int& formulation=0) :
         dataset_(dataset),
         pruning_T_(pruning_T),
         local_solve_(local_solve),
@@ -191,6 +192,7 @@ struct PruningOptions
         topology_size_(topology_size),
         gamma_topology_(gamma_topology),
         connected_(connected),
+        log_files_path_(log_files_path),
         optim_options_(optim_metod, initial_guess, max_iter, max_time, min_gradient, hessian_method, init_rho, rho_decrease, min_gradient_rho, cyclic, apply_closed_form, formulation)
     {
     }
@@ -242,6 +244,7 @@ class ProblemPruning : public Problem
 
     protected:
         SensorBasePtr sensor_ptr_;
+        Scalar t_topology_;
         Scalar t_sparsification_;
         FrameBaseIter last_removed_fr_it_;
         std::ofstream problems_file_;