Is it possible to perform parallel computing with lsqnonlin?

11 views (last 30 days)
Hello,
Could anybody please tell me if parallel computations are possible with the MATLAB optimization routine "lsqnonlin"? For my applications, this nonlinear optimization function seems to be the best one out of many, but I was disappointed to find out parallel computations were not supported for "lsqnonlin" in R2012a. What about the newest release?
I understand that it might be inherently impossible to make this function work in a parallelized way, but I would like to make sure whether or not the feature is now implemented.
Thank you in advance.

Accepted Answer

Jill Reese
Jill Reese on 21 Mar 2013
In the latest release (R2013a), lsqnonlin does not support parallel computations. The most up-to-date information on what optimization routines support parallel computations can be found by looking at the documentation for optimoptions. Optimization routines that support parallel computations will have 'UseParallel' listed as one of their options.

More Answers (1)

William Smith
William Smith on 3 Nov 2016
This is now supported (since around 2016a). Pass the { 'UseParallel' , true } flag in the optimoptions.
  2 Comments
Daniel Haxton
Daniel Haxton on 23 Aug 2017
Hello,
I am also wondering if I can use lsqnonlin for parallel computation.
This is what I mean: I have a function that returns a vector that is distributed among workers.
function localvectorpart = parallelfunction(parameters)
it is called within a spmd block. I run my program in a spmd block.
>> spmd; myprogram; end
My vector is distributed among workers and I want to minimize the sum of squares of all the entries in the vector. I would like to pass lsqnonlin a function that returns a distributed or codistributed vector, in some fashion.
Is it true, what it seems to me, that lsqnonlin cannot do this?
[1] I can call it like this,
function myprogram
..
fitparams = lsqnonlin(@(x) gather(codistributed.build(parallelfunction(x),mycodist)), guessparams, ...)
end
[2] but I would prefer to call
function myprogram
..
fitparams = lsqnonlin(@(x) codistributed.build(parallelfunction(x),mycodist), guessparams, ...)
end
[3] or simply
function myprogram
..
fitparams = lsqnonlin(parallelfunction, guessparams, ...)
end
Are [2] or [3] possible? [2] appears impossible because lsqnonlin does not accept functions that return codistributed vectors. [3] does not work regardless of the value of "UseParallel." Is there an option that would enable [3]? Is [1] actually equivalent, just as good? I suppose that gather() in [1] is indeed actually gathering the vectors, performing an allgather, and incurring extra communication. That is why I am asking.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!