Simple function minimization

55 views
Skip to first unread message

scot.sh...@gmail.com

unread,
Feb 12, 2016, 12:10:01 PM2/12/16
to Ceres Solver
I'm new to Ceres and wanted to start w/ a simple learning exercise: min(x,y) { x^2+y^2 }. 
     In the attached project I tried some different CostFunctors (Value, Jacobian, AutoDifferentiate) and they all appear to get stuck with an answer around 0.002, 1.82.     Is this function somehow not suitable for the solver or are some of the options getting in the way?  
  By changing the initial conditions from 2.0,3.0 to 2.0,2.0 it behaves much better (converging to 0.0002,0.0002 after 13 iterations) but that feels like it's playing more to the specific geometry of the objective function/derivatives.
thanks!
test1.cpp

Sameer Agarwal

unread,
Feb 12, 2016, 1:11:37 PM2/12/16
to Ceres Solver
The first thing that stands out is that you are modeling the function wrong.

your residual is x^2 + y^2, which means what you are actually minimizing is 1/2 (x^2 + y^2)^2

you should have a two dimensional residual r = {x, y} and that would imply 1/2 (x^2 + y^2).

I recommend working through the tutorial.

The second thing is that there is no reason to indicate line search stuff, because the default algorithm is a levenberg-marquardt algorithm. 

also it is worth looking at why the solver says it the reason for convergence.

Sameer


--
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/89b9bf0d-2775-4da8-8d84-a14091737078%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Scot Shinderman

unread,
Feb 12, 2016, 2:38:07 PM2/12/16
to ceres-...@googlegroups.com
Sameer -- thanks for the help and quick response!

yup expressing the residual as {x,y} works well but comparing the geometry i was expecting that the "squared" function (1/2 (x^2 + y^2)^2)  could solve better than (-.002, 1.8).      I took out the line-search solve options but get the same result. 

the geometry here looks easier to minimize...

i'll start digging though the docs and output from the iterations a little more to try to learn the mechanics here.

  fwiw, I found the parameter "residual" in the CostFunctors a little confusing since it's returning the f_i( x_i_1,...,x_i_k) value, not the residual itself ;)

thanks!
--s




--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/4V5dTDmqyuI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUBzE_Dhi0vwPQNzqfAc9ebypaOiqasgRAP4SgOpqkhMcw%40mail.gmail.com.

Sameer Agarwal

unread,
Feb 12, 2016, 3:15:10 PM2/12/16
to ceres-...@googlegroups.com
f_i(x) is the residual.
f_i^2() is the squared residual.

My sense is that x^2 + y^2 as a single residual does not give enough information to the solver. a single dimensional residual and the corresponding jacobian is rank 1.

Reply all
Reply to author
Forward
0 new messages