ALGLIB forum
It is currently Thu Jul 25, 2024 12:20 am

All times are UTC

Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: LMA calculation of sum of squares in an extern function
PostPosted: Thu Jun 23, 2011 9:28 am 

Joined: Thu Jun 23, 2011 9:21 am
Posts: 1
Hey guys,

I have a non-linear optimization problem and I want to use the alglib's LMA implementation to solve it. However, it is very unpractical for me to give the algorithm all the N points, i.e. the x and y to solve:

F(c) = (f(c,x[0])-y[0])^2 + ... + (f(c,x[n-1])-y[n-1])^2

I'd rather calculate the sum of squares by myself in a function, since I want to do the calculations on the GPU. Is there any drawback if I simple pass a dummy x and dummy y containing only 1 element and doing all the complex calculations, which actually involve 100k points bymyself in a function?


 Post subject: Re: LMA calculation of sum of squares in an extern function
PostPosted: Fri Jun 24, 2011 10:42 am 
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 921
There are two units which implement LM algorithm: lsfit and minlm.

lsfit is a high-level wrapper which solves fitting problem, i.e. minimizes F(c) = (f(c,x[0])-y[0])^2 + ... + (f(c,x[n-1])-y[n-1])^2. It needs a list of points, it automatically passes them one by one to the user-defined function and so on... You probably talk about this unit because this is the only unit which explicitly mentions points and c, x, y arrays. lsfit will work with dummy arrays - you may pass dummy x containing only one element - index of the point, and to fetch data from already calculated array of f's using this index. y, however, must be non-dummy, because its value is used by the algorithm.

minlm unit, from the other side, solves general form minimization problem without any explicit connection with some data to be fitted: min f(c) = f0(c)^2 + ... + fn_1(c)^2. It does not mention x and y, which is exactly the thing you need. Maybe it is better to use minlm in your situation.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group