| 32 | #include "App_Robust_Models_1D.h" |
| 33 | |
| 34 | int CreateGraphAndSolve(std::vector<std::string> &Arguments, |
| 35 | libRSF::FactorGraphConfig &Config, |
| 36 | libRSF::StateDataSet &CostSurfaceData, |
| 37 | libRSF::StateDataSet &PreOptimizationData, |
| 38 | libRSF::StateDataSet &PostOptimizationData, |
| 39 | libRSF::StateDataSet &SolverData) |
| 40 | { |
| 41 | /** parse testing parameter */ |
| 42 | const int NumberPoints = std::stoi(Arguments.at(3)); |
| 43 | const double Range = std::stod(Arguments.at(4)); |
| 44 | const string ErrorModel = Arguments.at(5); |
| 45 | |
| 46 | /** parse GMM parameter */ |
| 47 | libRSF::Vector1 Mean1, Mean2, StdDev1, StdDev2, Weight1, Weight2; |
| 48 | Mean1 << std::stod(Arguments.at(6)); |
| 49 | Mean2 << std::stod(Arguments.at(7)); |
| 50 | StdDev1 << std::stod(Arguments.at(8)); |
| 51 | StdDev2 << std::stod(Arguments.at(9)); |
| 52 | Weight1 << std::stod(Arguments.at(10)); |
| 53 | Weight2 << std::stod(Arguments.at(11)); |
| 54 | |
| 55 | /** DCS parameter is based on the second mean for some "randomness" */ |
| 56 | const double ScalingDCS = std::pow(10, Mean2(0)); |
| 57 | |
| 58 | /** create our own graph object */ |
| 59 | libRSF::FactorGraph SimpleGraph; |
| 60 | |
| 61 | /** set the solver options for ceres */ |
| 62 | ceres::Solver::Options SolverOptions; |
| 63 | SolverOptions.linear_solver_type = ceres::LinearSolverType::DENSE_QR; |
| 64 | SolverOptions.minimizer_type = ceres::MinimizerType::TRUST_REGION; |
| 65 | SolverOptions.trust_region_strategy_type = ceres::TrustRegionStrategyType::LEVENBERG_MARQUARDT; |
| 66 | SolverOptions.num_threads = 1; |
| 67 | SolverOptions.max_num_iterations = 100; |
| 68 | SolverOptions.max_solver_time_in_seconds = 1.0; |
| 69 | SolverOptions.minimizer_progress_to_stdout = false; |
| 70 | |
| 71 | /** decrease tolerances for an accurate result */ |
| 72 | SolverOptions.function_tolerance = 1e-8; |
| 73 | SolverOptions.gradient_tolerance = SolverOptions.function_tolerance * 1e-4; |
| 74 | |
| 75 | /** additional debugging */ |
| 76 | // std::vector<int> Iterations(100); |
| 77 | // std::iota (std::begin(Iterations), std::end(Iterations), 1); |
| 78 | // SolverOptions.trust_region_minimizer_iterations_to_dump = Iterations; |
| 79 | // SolverOptions.trust_region_problem_dump_directory = "."; |
| 80 | // SolverOptions.trust_region_problem_dump_format_type = ceres::DumpFormatType::TEXTFILE; |
| 81 | |
| 82 | /** configure Gaussian error model */ |
| 83 | libRSF::GaussianDiagonal<1> Noise; |
| 84 | Noise.setStdDevDiagonal(StdDev1); |
| 85 | |
| 86 | /** configure Gaussian Identity model for cDCE */ |
| 87 | libRSF::GaussianDiagonal<1> NoiseIdentity; |
| 88 | NoiseIdentity.setStdDevSharedDiagonal(1.0); |
| 89 | |
| 90 | /** create Gaussian mixture object */ |
| 91 | libRSF::GaussianComponent<1> Gaussian; |
no test coverage detected