4

I would like to perform a non-linear optimization algorithm using C.

The problem is: optimization problem over the five points that are in vector X.

X, Y(X), lower and upper bounds are known.

I have found the nlopt library on C but I do not know if It is possible to perform the optimization over the five discrete points.

Anything to suggest, even another library?

Thanks!

Frank Schmitt
  • 30,195
  • 12
  • 73
  • 107
yooyle
  • 77
  • 2
  • 10

2 Answers2

3

I would suggest Octave. For nonlinear programming on Octave, refer to Octave Optimization. You could implement using matlab-like language.

It also has C/C++ api.
See this post: How to embed the GNU Octave in C/C++ program?.

And also, this pdf

Community
  • 1
  • 1
gongzhitaao
  • 6,566
  • 3
  • 36
  • 44
  • Thanks for your quick response! I have already implement the optimization in Matlab but the algorithm is quite slow, that's why I want to switch in C. Do you think in Octave it will be sufficient fast? Thanks! – yooyle Apr 26 '13 at 14:24
  • 1
    @user2010599 octave is implemented in C++, but has C/C++ api. It might be easier if you already know matlab. As to the efficiency, I'm not quite sure, you might have to try. – gongzhitaao Apr 26 '13 at 14:26
  • @koel, Matlab is generally faster than Octave. – Prof. Falken Apr 26 '13 at 14:41
0

Consider optimizing matlab code instead of reimplementing algorithm in another language - matlab can be pretty fast if optimized properly (avoid using for loop, use vectorized computations, pre-allocate memory).

Take a look at http://www.mathworks.com/company/newsletters/news_notes/june07/patterns.html

Ilya Kobelevskiy
  • 5,245
  • 4
  • 24
  • 41
  • I am solving the optimization problem using the matlab function **lsqnonlin**, so there is not a lot of code to change. (it takes time to finish because I run the optimization for every voxel of a 3D image). Maybe I can resolve the problem using my own method (like Langrange multipliers) but I do not know if it worths to do this compared with the execution time I will save. – yooyle Apr 26 '13 at 18:08
  • Does running optimization for each voxel if 3D image means that isqnonlin is executed separately for each voxel? So, you have N X arrays, each containing 5 points, and optimization is performed independently for all of them? – Ilya Kobelevskiy Apr 26 '13 at 19:13
  • Yes, the image is 512*256 and I have 5 of these arrays. The optimmization is performed for each voxel of the image. – yooyle Apr 26 '13 at 19:27
  • *for each slice. But don't be confused. The opimizations are uncorellated. I want to solve the problem efficiently for a single voxel. – yooyle Apr 26 '13 at 19:51