MATLAB Answers

0

Fmincon with UseParrallel option + Simulink model with variant control in rapid accelerator mode

Asked by Eyefujirin Ejegi on 23 Sep 2019
Latest activity Edited by Eyefujirin Ejegi on 26 Sep 2019
Hi all,
I've got a Simulink model with variant control, which I call (using "sim" command) from an optimisation script. The optimisation uses the fmincon function and I am setting the "UseParrallel" option to true. Moreover, the "sim" command uses the rapid accelerator mode option. I get the error below:
>> Optimisation
### Building the rapid accelerator target for model: FMCPAMG_R00_MOD
### Successfully built the rapid accelerator target for model: FMCPAMG_R00_MOD
Starting parallel pool (parpool) using the 'local' profile ...
connected to 6 workers.
IdleTimeout has been reached.
Parallel pool using the 'local' profile is shutting down.
### Build procedure for model: 'FMCPAMG_R00_MOD' aborted due to an error.
### Build procedure for model: 'FMCPAMG_R00_MOD' aborted due to an error.
### Build procedure for model: 'FMCPAMG_R00_MOD' aborted due to an error.
Error using build_rapid_accel_target
Unable to build a standalone executable to simulate the model 'FMCPAMG_R00_MOD' in rapid accelerator mode.
Error in sl (line 15)
[varargout{1:nargout}]=feval(varargin{:});
Error in Optimise/objFun (line 47)
WSdata = sim(OPT_INPUT.model_name, 'SimulationMode', 'rapid',...
Error in finDiffEvalAndChkErr
Error in parfinitedifferences
Error in parfinitedifferences
Error in nlconst (line 347)
parfinitedifferences(XOUT,lb,ub,f, ...
Error in fmincon (line 751)
nlconst(funfcn,X,l,u,full(A),B,full(Aeq),Beq,confcn,options,defaultopt, ...
Error in Optimise (line 32)
[x,fval] = fmincon(@objFun,OPT_INPUT.x0,A,b,Aeq,beq,lb,ub,@conFun,options);
Error in Optimisation (line 80)
[x,fval] = Optimise(OPT_INPUT);
Caused by:
Error using tlc_c (line 176)
Error due to multiple causes.
Error using tlc_c (line 176)
Variant control 'ctrl_mode == 1' used by block 'FMCPAMG_R00_MOD/Control/Control Subsystem' should return a logical
value.
Error using tlc_c (line 176)
Undefined function or variable 'ctrl_mode'.
Error using tlc_c (line 176)
Variable 'ctrl_mode' does not exist.
Error using tlc_c (line 176)
Variant control 'ctrl_mode == 3' used by block 'FMCPAMG_R00_MOD/Control/Control Subsystem' should return a logical
value.
Error using tlc_c (line 176)
Undefined function or variable 'ctrl_mode'.
Error using tlc_c (line 176)
Variable 'ctrl_mode' does not exist.
Error using tlc_c (line 176)
Variant control 'ctrl_mode == 2' used by block 'FMCPAMG_R00_MOD/Control/Control Subsystem' should return a logical
value.
Error using tlc_c (line 176)
Undefined function or variable 'ctrl_mode'.
Error using tlc_c (line 176)
Variable 'ctrl_mode' does not exist.
Things work well when I set UseParallel to false. Any idea(s) on how I can move forward?
Ps: Here is my sim command:
WSdata = sim(OPT_INPUT.model_name, 'SimulationMode', 'rapid',...
'InlineParams', 'on',...
'SolverType', 'Fixed-step',...
'Solver', 'ode3',...
'FixedStep', num2str(OPT_INPUT.sim_step),...
'StopTime', num2str(OPT_INPUT.sim_stop_time),...
'SaveFormat', 'StructureWithTime');

  0 Comments

Sign in to comment.

1 Answer

Answer by Divya Yerraguntla on 26 Sep 2019

  1 Comment

Many thanks for your response; the question in the link didn't really capture my challenge completely. To reiterate my challenge:
1) I have a Simulink model with a variant control block which is called from an optimisation script using the fmincon alogirthm.
2) The simulink model is used to compute the objective function and nonlinear constraints.
3) The Simulink model is called using the 'sim' function in matlab and runs in rapid accelerator mode.
4) Now, I have the problem when I attempt to set the UseParallel option in fmincon to true as I want to speed-up my optimisation.
5) Everything runs fine when I set the UseParrallel option in fmincon to false

Sign in to comment.