int main()
{
double x1 = 20.0;
double x2 = 5.00;
Problem TestProblem;
CostFunction * cost_function = new
AutoDiffCostFunction<testfunctor,1,1,1>(
new
testfunctor());
Solver::Summary summary;
Solver::Options solver_options;
solver_options.minimizer_progress_to_stdout = true;
Solve(solver_options,&TestProblem,&summary);
}
template <typename T>
bool testfunctor::operator()(const T* x,
const T* y,
T* value) const
{
T res = ceres::sqrt((x0] )*
(x[0]) +
(y[0])*
(y[0]);
value[0] = res;
if(ceres::IsNaN(value[0]))
{
std::cout <<"IsNan"<<std::endl;
value[0] = T(0.);
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
which means nothing else than minimising (x^2 + y^2)/2. Obviously the solution is xsol=0, ysol=0. But ceres does not converge properly.
Instead i get x1:-0.00392972 x2: 1.4489 :/.
I received the following output:
Solver Summary (v 1.13.0-eigen-(3.2.92)-lapack-suitesparse-(4.4.6)-cxsparse-(3.1.4)-openmp)
Original Reduced
Parameter blocks 2 2
Parameters 2 2
Residual blocks 1 1
Residual 1 1
Minimizer TRUST_REGION
Sparse linear algebra library SUITE_SPARSE
Trust region strategy LEVENBERG_MARQUARDT
Given Used
Linear solver SPARSE_NORMAL_CHOLESKY SPARSE_NORMAL_CHOLESKY
Threads 1 1
Linear solver threads 1 1
Linear solver ordering AUTOMATIC 2
Cost:
Initial 2.125000e+02
Final 1.049660e+00
Change 2.114503e+02
Minimizer iterations 51
Successful steps 33
Unsuccessful steps 18
Time (in seconds):
Preprocessor 0.0001
Residual evaluation 0.0007
Jacobian evaluation 0.0011
Linear solver 0.0003
Minimizer 0.0027
Postprocessor 0.0000
Total 0.0027
Termination: NO_CONVERGENCE (Maximum number of iterations reached. Number of iterations: 50.)
What i am doing wrong? Thanks for your help!
kind regards,
Max
--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/c53bd9ec-587a-43a0-8dab-5ad510d1ee4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.