This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Help with Nonlinear Optimization Module

Tags: None
(comma "," separated)
yifeiw
Registered Member
Posts
3
Karma
0
Hi guys, I've been trying to get the Nonlinear Optimization module (Levenberg Marquardt) in Eigen to work and I'm running into a little trouble.

The examples listed in the tests all have preentered data hardcoded in the objective functions. How do you pass in a data set into the function e.g. at runtime?

For instance, lets say I was making a program that fits a curve to a set of points that I read in from a file (defined at user prompt). Much appreciated, thanks!
Dee33
Registered Member
Posts
54
Karma
0
OS
When you create your functor class with operator() and df(), you can simply define another function in that class, say initDataPoints(...) which will set all the required data; for your case, these are the data points you read from a file.
yifeiw
Registered Member
Posts
3
Karma
0
Thanks, I ended up adding member objects to do the job

struct Objective_functor : Functor<double>
{
Objective_functor(int n_par, int m_dat, vtkPolyData *BdryElms, vtkPolyData *LRS) : Functor<double>(n_par,m_dat) ,myBdryElms(BdryElms), myLRS(LRS) {}
//Put data objects here
vtkPolyData *myBdryElms;
vtkPolyData *myLRS;
int operator()(const VectorXd &x, VectorXd &fvec) const
//fvec evaulation {....
..}
}

//Calling the instance
Objective_functor functor(n_par,m_dat,BdryElms,LRS_post);
...


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]