Hi guys!

I want to use NLopt for my nonlinear optimization problem. I test the
sample code in tutorial page enter link description here
<http://ab-initio.mit.edu/wiki/index.php/NLopt_Tutorial>, C++ example. It
works good. But the function I want to minimize should a return a vector.
Which is, in the tutorial page it has

double minf;
nlopt::result result = opt.optimize(x, minf);
printf("found minimum at f(%g,%g) = %g ", x[0],x[1],minf);

I hope minf is a vector, so I change it to one dimension vector for just
test.

std::vector<double> minf(1);
nlopt::result result = opt.optimize(x, minf);
printf("found minimum at f(%g,%g) = %g ", x[0],x[1],minf[0]);

Then it has errorsnltest2.cpp:44:44: error: no matching function for call
to ‘nlopt::opt::optimize(std::vector<double>&, std::vector<double>&)’

Is there any way I can let it recturn an vector? What's more(if you cannot
answer this that's OK.) I hope to use armadillo matrix library. The better
if I could (I have included the h file needed)

mat minf(1,1);
nlopt::result result = opt.optimize(x, minf);
printf("found minimum at f(%g,%g) = %g ", x[0],x[1],minf(1,1));

This causes errors of course...

Thanks for your answer!!
_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to