Hi there!

NLopt is designed for minimising /single functions/ of the form f(X)
where X represents a vector of input values.

I would first recommend to make sure you fully understand what it is you
actually want to solve. Why do you think you want minf to be a vector?

1) If by "vector" you mean something simple and geometric like a 3- or
4-vector, it sounds like you might be getting confused between the model
for the problem you're solving and the minimisation itself.

2) If you instead mean that you actually have F(X), where F is a vector
of M function results and X a vector of N input values, it means you
actually have a nonlinear equation /system/. You then have two options:
   a) Use NLopt, and this forces you to minimise some scalar f(X) merit
function, usually constructed as f = F.F
   b) Use a dedicated nonlinear equation solving package (examples
include MINPACK, which I'm sure has a C++ interface, and the the GNU
Scientific Library, which definitely does). Either you have M=N (same
number of functions as variables), in which case you should use one of
the "Hybrid Powell Method" drivers, or M>N (more functions than
variables), and use one of the "Levenberg-Marquardt" drivers which will
solve your system in a least-squares sense.
   Note: If you have N>M (more variables than functions) I believe you
need to reformulate your problem, either increasing the number of
functions to >=N, decreasing the number of variables to <=M, or
explicitly scalarise your F, as suggested in a).

Feel free to get back in touch, and @ everyone else, if you think my
advice is lacking in some way, please don't hesitate to let me know.
Otherwise, good luck!

Best regards,
Adam Hirst

On 19/03/17 21:11, Zhaozhong Chen wrote:
> 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
> 
> |doubleminf;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 errors|nltest2.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
> NLopt-discuss@ab-initio.mit.edu
> http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss
> 

-- 
Using GPG? Add my key, and respond to me with it enabled!
Also, feel free to verify my key with me online or in person!

Not using GPG? You should, it's easy!
https://www.enigmail.net/documentation/quickstart.php

_______________________________________________
NLopt-discuss mailing list
NLopt-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to