Marcelo Silva
unread,Jan 29, 2013, 7:33:07 AM1/29/13You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hello all,
I am trying for the first time to use parallelization in Matlab to obtain a set of parameters that minimise a nonlinear least squares problem. I am using lsqnonlin like this:
matlabpool open local 4
lb = [4,0.5];
ub = [13,5];
p0 = lb + rand*(ub-lb);
ObjectiveFunction = @(par)cost_ctmi(time,meas,exp_cond,par);
problem = createOptimProblem('lsqnonlin','objective',ObjectiveFunction,...
'x0',p0,'lb',lb,'ub',ub);
ms = MultiStart('UseParallel','always');
[par_ctmi,~] = run(MultiStart,problem,100);
My objective function is nested:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function res = cost_ctmi(time,meas,exp_cond,par_ctmi)
npoints = length(time);
ncond = size(exp_cond,1);
Yout = zeros(npoints,ncond);
for i=1:ncond
[~,Yout(:,i)] = ctmi(time,exp_cond(i,:),par_ctmi);
end
% Compute cost function
res = meas-Yout; k = numel(res);
res = reshape(res,k,1);
matlabpool close
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
So, in the end, the objective function delivers a vector with all the residuals for each set of experimental conditions to be minimised by lsqnonlin.
The problem is that although this works without 'UseParallel', when 'UseParallel' is set to 'always', it gives a -10 exit flag error: Failures encountered in user-provided functions.
I have already tried also fmincon with the ObjectiveFunction returning a scalar value (sum of squared residuals), but this error persists.
Do you have any idea for the solution?
Kind regards