Registered Member
|
I tried to look through LevenbergMarquardt.h, but I didn't get very far. I tried to make a very simple example that minimizes the function f(x) = x^2 :
http://programmingexamples.net/index.ph ... gMarquardt The first error I run into is: error: ‘struct MyFunctor’ has no member named ‘values’ I'm not sure what the Functor is supposed to store in 'values'? Can anyone explain the structure of this LM implementation a bit more? Thanks, David |
Moderator
|
have a look at the file unsupported/test/NonLinearOptimizaiton.cpp, line 104 to 162 for an example.
|
Registered Member
|
Yea I looked at that - that's how I got as far as I did . I don't understand what 'values' and 'inputs' are? I thought operator() should just return f(x), while df() should return a derivative? Why does the Functor have to have a state (i.e. 'values' and 'inputs')?
|
Moderator
|
values() is the number of constraints, and inputs() the number of unknows.
|
Registered Member
|
I recently started using the NonLinearOptimization library, and I had similar issues with the interface for the NonLinearOptimization functor, which is really much more than just a functor. Here is what I found:
LevenbergMarquardt requires the functor to have the methods values(), operator() and df(), and it requires that the input vector and Jacobian matrix are Eigen::Dynamic. Compile-time constant lengths are not supported. (This took me way to long to figure out). Although not used, the examples all include the method input(). To numerically compute your Jacobian, use the NumericalDiff library which requires the methods values(), operator() and the typedefs Scalar, InputType, ValueType and JacobianType. It also requires the enums InputsAtCompileTime and ValuesAtCompileTime which MUST be Eigen::Dynamic for use with LevenbergMarquardt. |
Registered Member
|
mliberty -
I got a (very simple) example working with a numerical derivative: http://programmingexamples.net/index.ph ... tNumerical If you would add an example on that wiki of a more complicated one (using NumericalDiff as you mentioned) it would be a big help! David |
Registered Member
|
I'm having a similar issue figure out what is needed for the functor: see viewtopic.php?f=74&t=97683
Is there a requirement in the LM algorithm for you to have an over-constrained problem (functor.values() >= functor.inputs())? The algorithm is returning LevenbergMarquardtSpace::ImproperInputParameters when I give it an under constrained problem. Any suggestions? thanks, Forrest |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]