From: Seung-Yong on
I'm struggling to run a built-in GA code in a parallel computing mode for simulink model. The simulink model contains the fuzzy block. Below is the options that I've used.

%%%%
options = GAOPTIMSET('UseParallel','always');
matlabpool open
[x] = ga(@(x)evaluate_objective(x,params),....);

function f = evaluate_objective(x,params)

FuzGain = x;
GenerateFuzzyBlock(FuzGain); % This is a user-defined function to generate fuzzy 'FIS' file.
load_system('model');
set_param('model','PreloadFcn','SetSysParams');
sim('model',[0 Tf],OPTIONS);
%%%

However, it doesn't work. Is there anyone who can give helpful comments for me?
From: Steven_Lord on


"Seung-Yong " <syok71(a)gmail.com> wrote in message
news:i2ov18$moc$1(a)fred.mathworks.com...
> I'm struggling to run a built-in GA code in a parallel computing mode for
> simulink model. The simulink model contains the fuzzy block. Below is the
> options that I've used.
>
> %%%%
> options = GAOPTIMSET('UseParallel','always');
> matlabpool open [x] = ga(@(x)evaluate_objective(x,params),....);
>
> function f = evaluate_objective(x,params)
>
> FuzGain = x;
> GenerateFuzzyBlock(FuzGain); % This is a user-defined function to generate
> fuzzy 'FIS' file.
> load_system('model');
> set_param('model','PreloadFcn','SetSysParams');
> sim('model',[0 Tf],OPTIONS);
> %%%
>
> However, it doesn't work. Is there anyone who can give helpful comments
> for me?

I don't think anyone is going to be able to offer any helpful comments
without knowing what you mean by "it doesn't work". Does it throw a
warning? Does it error? Does it work but not use the parallel cluster?
Does it return an answer other than what you expected?

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Seung-Yong on
"Steven_Lord" <slord(a)mathworks.com> wrote in message <i2pbun$jr2$1(a)fred.mathworks.com>...
>
>
> "Seung-Yong " <syok71(a)gmail.com> wrote in message
> news:i2ov18$moc$1(a)fred.mathworks.com...
> > I'm struggling to run a built-in GA code in a parallel computing mode for
> > simulink model. The simulink model contains the fuzzy block. Below is the
> > options that I've used.
> >
> > %%%%
> > options = GAOPTIMSET('UseParallel','always');
> > matlabpool open [x] = ga(@(x)evaluate_objective(x,params),....);
> >
> > function f = evaluate_objective(x,params)
> >
> > FuzGain = x;
> > GenerateFuzzyBlock(FuzGain); % This is a user-defined function to generate
> > fuzzy 'FIS' file.
> > load_system('model');
> > set_param('model','PreloadFcn','SetSysParams');
> > sim('model',[0 Tf],OPTIONS);
> > %%%
> >
> > However, it doesn't work. Is there anyone who can give helpful comments
> > for me?
>
> I don't think anyone is going to be able to offer any helpful comments
> without knowing what you mean by "it doesn't work". Does it throw a
> warning? Does it error? Does it work but not use the parallel cluster?
> Does it return an answer other than what you expected?
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Thank you for your kindness. The error appears when running the simulink model in parallel mode with the following messages:
"Warning: sys_adj_fuzMR10_v02_GA.mdl, line 14: Error evaluating 'PreLoadFcn'
callback of block_diagram 'sys_adj_fuzMR10_v02_GA'. Error: Unexpected MATLAB
expression.
> In evaluate_objective_FC at 37
In @(x)evaluate_objective_FC(x,params)
In globaloptim\private\validate>@(x)fitness(x,FitnessFcnArgs{:}) at 136
In globaloptim\private\fcnvectorizer>(parfor body) at 18
In parallel_function>make_general_channel/channel_general at 879
In remoteParallelFunction at 31
Warning: Error: Unexpected MATLAB expression.
> In evaluate_objective_FC at 37
In @(x)evaluate_objective_FC(x,params)
In globaloptim\private\validate>@(x)fitness(x,FitnessFcnArgs{:}) at 136
In globaloptim\private\fcnvectorizer>(parfor body) at 18
In parallel_function>make_general_channel/channel_general at 879
In remoteParallelFunction at 31"

The above message appears 4 times since I used the command "matlabpool open 4".

I guess the problem is, "4 different MATLAB workers simultaneously open the same simulink model with different parameters".