MATLAB: Problem using OPTIMOPTIONS with FMINCON for PARALLEL COMPUTING

fminconformulastudentGlobal Optimization ToolboxMATLABparallel computingParallel Computing Toolbox

Hi All, I am performing an optimization of parameters of a Simulink model using fmincon The options I am using are the followings
options = optimoptions('fmincon'); % Start with the default options
options = optimoptions(options,'Algorithm', 'interior-point');
options = optimoptions(options,'Display', 'iter-detailed');
options = optimoptions(options,'MaxIter', 1000);
options = optimoptions(options,'PlotFcns', { @optimplotfval });
So far so good, the optimization run and arrives to a minimum with no problems at all However, as the optimization takes few hours to perform I wish to speed up the process by using parallel computing (I have a 2 core processor computer)
Then, I add the following line to the options listed above
options = optimoptions('fmincon','UseParallel',true);
Before I run the optimization with the new line of code, I set the parallel computing on manually using the following command in Matlab Command Line
parpool
Matlab gives the following message
Starting parallel pool (parpool) using the 'local' profile ... connected to 2 workers.
ans =
Pool with properties:
Connected: true
NumWorkers: 2
Cluster: local
AttachedFiles: {}
IdleTimeout: 30 minutes (30 minutes remaining)
SpmdEnabled: true
I then run the optimization but I get this error
Error using optimoptions (line 114)
Invalid value for OPTIONS parameter UseParallel:
must be 'always' or 'never'.
Error in Damper_Optimization_v1 (line 134)
options = optimoptions('fmincon','UseParallel',true);
Please not the Damper_Optimization_v1 is the name of my script (where fmincon is used) and that line 134 is the line of
options = optimoptions('fmincon','UseParallel',true);
Does anybone know why I am getting this error?
I tried to use "always" instead of "true" but this did not work, I got the following error
Undefined function or variable 'always'.
Error in Damper_Optimization_v1 (line 151)
options = optimoptions('fmincon','UseParallel',always);
PS: I noted that when I add the line with the parallel computing option, the word "options" in the previous line is underlined in red and the warning message that I get for it is
The value assigned to variable 'options' might be unused
See below the rest of the code where I use fmincon
options = optimoptions('fmincon'); % Start with the default options options = optimoptions(options,'Algorithm', 'interior-point'); options = optimoptions(options,'Display', 'iter-detailed'); options = optimoptions(options,'MaxIter', 1000); options = optimoptions(options,'PlotFcns', { @optimplotfval }); %options = optimoptions('fmincon','UseParallel',true);
options = optimoptions('fmincon'); % Start with the default options options = optimoptions(options,'Algorithm', 'interior-point'); options = optimoptions(options,'Display', 'iter-detailed'); options = optimoptions(options,'MaxIter', 1000); options = optimoptions(options,'PlotFcns', { @optimplotfval }); %options = optimoptions('fmincon','UseParallel',true);
OPTIMIZATION
tic % Start stopwatch to measure elapsed time
[Optimum_Damper,fun_value,exitflag,output_details] = fmincon(...
@Objective,... % Cost Function
Damper_Parameter_Initial_Guess,...% Initial Guess
A,B,... % Damper Parameters Constrains
[],[],... % Damper Parameters Inequalities
Damper_Parameters_Lower_Bound,... % Damper Parameter Lower Bounds
Damper_Parameters_Upper_Bound,... % Damper Parameter Lower Bounds
[], ... % Non-linear conditions (NONE)
options); % Options
toc
Thanks in advance for your help
G

Best Answer

I think there might be two issues here.
  1. The value true for UseParallel was added in R2014a. If you use an earlier version, set UseParallel to 'always'. Include the single quotes.
  2. In your fmincon call, do you pass options? I mean, does your call look like this:
[x,fval,exitflag] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)
Alan Weiss
MATLAB mathematical toolbox documentation