Hello,
I didn't reallys get how to use this forum, like I can't see this page :
http://ab-initio.mit.edu/pipermail/nlopt-discuss/
Whatever, I'm using nlopt in cpp for a robotic controller and I'm facing
the problem that s/et_min_objective(costFunction, NULL) /need a static
function.
All my controller is a class, so I want to use a cost function which is
a member function that I can't make static. I saw that a note is in the
tutorial :
|static double wrap(const std::vector`<double>` &x,
std::vector`<double>` &grad, void *data) {
return (*reinterpret_cast`<MyFunction*>`(data))(x, grad); } |||
||But I'm not sure to understand how to use it. The cost function I'm
using is also using other member functions. The problem is so as :
class Class
{ private:
T m_a;
T m_b;
public:
double f1(...){};
double f2(...){};
double costFunction(const std::vector<double> &x,
std::vector<double> &grad, void* f_data){
double cost = 0;
cost += f1(x, m_a);
cost += f2(x, m_b);
return cost;
}
void optimize(){
nlopt::opt opt;
opt.set_min_objective(costFunction, NULL);
}
}
Does someone know how can I solve my problem ? Could someone explain me
the method ?
Thanks for your time !
||
_______________________________________________
NLopt-discuss mailing list
NLopt-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss