| 25 | namespace libRSF |
| 26 | { |
| 27 | void EvaluateCostSurfacePoints(ceres::Problem &Graph, |
| 28 | double* const StatePointer, |
| 29 | const int Dim, |
| 30 | const VectorVectorSTL<Dynamic> Points, |
| 31 | std::vector<double> &Costs) |
| 32 | { |
| 33 | |
| 34 | /** save original value */ |
| 35 | VectorRef<double, Dynamic> State(StatePointer, Dim); |
| 36 | const Vector OriginalState = State; |
| 37 | |
| 38 | /** configure evaluation */ |
| 39 | ceres::Problem::EvaluateOptions Options; |
| 40 | Options.apply_loss_function = true; |
| 41 | Options.num_threads = std::thread::hardware_concurrency(); |
| 42 | Options.parameter_blocks = {StatePointer}; |
| 43 | |
| 44 | /** loop over grid */ |
| 45 | Costs.clear(); |
| 46 | for (int n = 0; n < static_cast<int>(Points.size()); ++n) |
| 47 | { |
| 48 | State = Points.at(n); |
| 49 | |
| 50 | /** evaluate */ |
| 51 | double Cost; |
| 52 | Graph.Evaluate(Options, &Cost, nullptr, nullptr, nullptr); |
| 53 | |
| 54 | /** save result */ |
| 55 | Costs.push_back(Cost); |
| 56 | } |
| 57 | |
| 58 | /** restore original cost */ |
| 59 | State = OriginalState; |
| 60 | } |
| 61 | } |
no test coverage detected