Multistart and lsqnonlin - Parallelization doesn't seem to provide any benefit.

5 views (last 30 days)
I'm using Multistart and Lsqnonlin to do curve fitting and get parameters.
A quick overveiw of the problem: I have a Numerical DiffEq solver (in the form of a mex file) that is operated through MATLAB, a function blackboxfunction(A,t, X). The DiffEq solver provides my 'model' data (from theory).
We perform experients with known experimental values 'A' and for a known time from 0 to t.
X are parameters that are unknown, but can be obtained by inverse fitting the 'model' data to the 'experimental' data. Both experimental and model data are plotted in the form of curves.
This is essentially a non-convex optimization problem: What are the parameters (X) such that the function @(X)blackboxfunction(A,t,X) - y_experimental(t) is minimized.
In other words - what parameters 'X' gets the experimental and model curves to overlap perfectly?
I have a system with 16 nodes.
%% An excerpt of my code:_________________
% Function definition
fun = @(X)blackboxfunction( ...
A, ...
time_start,time_stop, ...
X) ...
-Experimental;
% Set up Lsqnonlin options
options = optimoptions(@lsqnonlin,...
'Algorithm','trust-region-reflective', ...
'Display', 'iter', ...
'UseParallel', false, ...
'StepTolerance', 5e-6, ... Step-size stopping criterion
'FunctionTolerance', 1e-6, ... Function stoppping criterion
'TypicalX', TypicalX, ...
'FiniteDifferenceStepSize', 1e-4, ... % This seems to work fine, and faster
'DiffMinChange', 1e-6); %, ...
% Create optimization problem
problem = createOptimProblem('lsqnonlin', ...
'objective', fun, ...
'x0', initial, ...
'lb', lowlimit, ...
'ub', uplimit, ...
'options', options);
% Create and run MultiStart object
ms = MultiStart('FunctionTolerance',2e-4,'XTolerance',5e-3,...
'StartPointsToRun','bounds-ineqs', 'Display', 'iter', 'UseParallel', true);
[ms_params,ms_fval,ms_eflag,ms_output,ms_manymins] = run(ms, problem, 10)
My questions are:
  1. UseParallel should be 'true' for MultiStart alone, or both for MultiStart and the optimoptions object?
  2. Neither options above seem to be making the parallelization work. I don't have tic/toc data right now, but it's going no faster than when I did lsqnonlin for a single starting point. Is MultiStart with 'n' start points supposed to take as much time as n*lsqnonlin runs with one start point? (I suppose that makes sense, but I thought I'd still ask)
  3. What is the meaning of the error below:
[Error: idasErrorHandler::183] In function 'IDASolve' of module 'IDAS', error code 'IDA_ILL_INPUT':
At t = 14.3214, , mxstep steps taken before reaching tout.
[Error: integrate::1378] IDASolve returned IDA_TOO_MUCH_WORK at t = 14.3214

Accepted Answer

Alan Weiss
Alan Weiss on 19 Jun 2020
I have to ask: do you have Parallel Computing Toolbox installed? It is required for MultiStart to run in parallel.
I do not understand the error that you show, but it seems to be an error thrown from your ODE solver. IIs the ODE being solved for the time interval you specify?
If you read parfor Characteristics and Caveats, you will see that you do not have to set parallel computing for your local optimizer, lsqnonlin in your case, but it doesn't matter whether you do or not, because MultiStart takes the outer parallel loop, and this disables parallel lsqnonlin.
Alan Weiss
MATLAB mathematical toolbox documentation
  14 Comments
Marylen Sun
Marylen Sun on 9 Dec 2020
i find the problem, my differential equation is a stiff problem and i use ODE45 and this one is not totally adapt tot stiff equation , so i change to ode15s and multistart run well.
Alan Weiss
Alan Weiss on 9 Dec 2020
Thanks for letting us know. Glad you were able to fix the issue.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!