Uri Merhav
Uri Merhav

Reputation: 300

Nonlinear function minimization C++

I've been trying to port a code from MATLAB to C++, and stumbled on a very unexpected difficulty. I can't seem to find the C++ equivalant to MATLAB's fminunc.

Simply put, the problems definition is minimizing f(x), for a vector x, a scalar function f(x), and intial guess x_0.

My search endeavors thus far have only cropped up a library called MinPack, which fails to adress the case where f(x) is a scalar and x is vector.

Surely a programming language that's as old as time has some freely available implementation of classic numerical recipes for nonlinear optimization? Or am I being overly optimistic here? Even basic approaches such as gradient descent would be a huge improvement over nothing...

Upvotes: 0

Views: 2304

Answers (3)

alexandre iolov
alexandre iolov

Reputation: 582

Here's another good one: GSL, in particular http://www.gnu.org/software/gsl/manual/gsl-ref_36.html#SEC498

Upvotes: 1

Ali
Ali

Reputation: 58501

My personal choice would be IPOPT, a general purpose nonlinear solver. It knows far more than you asked for.

The other options would include:

The latter would unfortunately involve interfacing with FORTRAN; it is painful and boring but really not a rocket science.

Upvotes: 1

jmbr
jmbr

Reputation: 3348

Check NLopt out. That's what I use first when porting stuff from MATLAB to C / C++ and it works very well.

Upvotes: 1

Related Questions