Hello,
I'am new to using nlopt an ran in something that i hope is just a
typical newbie problem.
(c++)
I want to use nlopt inside a object that acts as nearestneighbour
locator on an parametric manifold.
therefore i defined within my class SurfLocator
- a objective function
double SurfLocator::FunctionWrapperNLopt(const std::vector<double> &x,
std::vector<double> &grad, void *my_func_data)
{
double uvw[] = {x[0],x[1],0};
double Pt[3];
double Duvw[9];
this->Surf->Evaluate(uvw,Pt,Duvw);
return
pow(Pt[0]-reinterpret_cast<double*>(my_func_data)[0],2)+
pow(Pt[1]-reinterpret_cast<double*>(my_func_data)[1],2)+
pow(Pt[2]-reinterpret_cast<double*>(my_func_data)[2],2);
}
This function generates the return value (distance between point and
Surface Point) for nlopt by calling a function of the manifold object
with the parameters x
- and a routine to handle nlopt that gets a point to find the nearest
neighbour to as input and returns the nearest neighbour (not
implemented here)
void SurfLocator::FindNearestPointNLopt(double P[3], double OutPoint[3])
{
nlopt::opt opt(nlopt::LD_MMA, 2);
std::vector<double> lb(2);
lb[0] = -HUGE_VAL; lb[1] = 0;
opt.set_lower_bounds(lb);
opt.set_min_objective(&SurfLocator::FunctionWrapperNLopt,
reinterpret_cast<void*>(P));
opt.set_xtol_rel(1e-4);
std::vector<double> x(2);
x[0] = 0; x[1] = 0;
double minf;
nlopt::result result = opt.optimize(x, minf);
}
Everything seems fine so far but when i try to compile (Visual Studio
2010 Ex) i get an error stating that the
compiler cannot match the arguments in the call of
opt.set_min_objective to any of its overloadings.
So whats wrong here... For me it looks quite like the tutorial on the
nlopt webpage, but obviously this is not the case!
Thanks for any help
Elias
_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss