| 73 | } |
| 74 | |
| 75 | void SetupCommonMinimizerOptions(PreprocessedProblem* pp) { |
| 76 | const Solver::Options& options = pp->options; |
| 77 | Program* program = pp->reduced_program.get(); |
| 78 | |
| 79 | // Assuming that the parameter blocks in the program have been |
| 80 | // reordered as needed, extract them into a contiguous vector. |
| 81 | pp->reduced_parameters.resize(program->NumParameters()); |
| 82 | double* reduced_parameters = pp->reduced_parameters.data(); |
| 83 | program->ParameterBlocksToStateVector(reduced_parameters); |
| 84 | |
| 85 | auto context = pp->problem->context(); |
| 86 | Minimizer::Options& minimizer_options = pp->minimizer_options; |
| 87 | minimizer_options = Minimizer::Options(options); |
| 88 | minimizer_options.evaluator = pp->evaluator; |
| 89 | minimizer_options.context = context; |
| 90 | |
| 91 | if (options.logging_type != SILENT) { |
| 92 | pp->logging_callback = std::make_unique<LoggingCallback>( |
| 93 | options.minimizer_type, options.minimizer_progress_to_stdout); |
| 94 | minimizer_options.callbacks.insert(minimizer_options.callbacks.begin(), |
| 95 | pp->logging_callback.get()); |
| 96 | } |
| 97 | |
| 98 | if (options.update_state_every_iteration) { |
| 99 | pp->state_updating_callback = |
| 100 | std::make_unique<StateUpdatingCallback>(program, reduced_parameters); |
| 101 | // This must get pushed to the front of the callbacks so that it |
| 102 | // is run before any of the user callbacks. |
| 103 | minimizer_options.callbacks.insert(minimizer_options.callbacks.begin(), |
| 104 | pp->state_updating_callback.get()); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | } // namespace ceres::internal |
no test coverage detected