Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GA parallel computing toolbox error

59 views
Skip to first unread message

Dave Brackett

unread,
Aug 20, 2008, 10:16:03 AM8/20/08
to
Hi, I have a genetic algorithm optimization function which
I am trying to run using the parallel computing toolbox as
explained here:
http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i
ndex.html?/access/helpdesk/help/toolbox/gads/f7928.html&http
://www.google.co.uk/search?
hl=en&q=matlab+custom+plot+function&meta=

The GA works fine without running it in parallel, but when
I open the matlabpool, the GA then returns the following
error: ??? Error using ==> makeState at 50
GA cannot continue because user supplied fitness function
failed with the following error:
Error using ==> reshape
To RESHAPE the number of elements must not change.

From the debugger, this appears to be happening when it is
trying to score each member of the population:

% Score each member of the population
if strcmpi(options.Vectorized, 'off')
try
Score = fcnvectorizer(state.Population
(initScoreProvided+1:end,:),FitnessFcn,1,options.SerialUserF
cn);
catch
error('gads:makestate:fitnessCheck', ...
'GA cannot continue because user supplied
fitness function failed with the following error:\n%s',
lasterr)
end

Anyone any ideas why this would be happening? I'm not sure
what details of my code are needed so feel free to ask for
additional information. My version is 2008a (7.6.0.324).

Thanks.

Dave Brackett

unread,
Aug 20, 2008, 11:47:02 AM8/20/08
to
> I am trying to run using the parallel computing toolbox
as
> explained here:
>
http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i
>
ndex.html?/access/helpdesk/help/toolbox/gads/f7928.html&http
> ://www.google.co.uk/search?
> hl=en&q=matlab+custom+plot+function&meta=

Sorry, the correct url for this is

http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i
ndex.html?/access/helpdesk/help/toolbox/gads/f7928.html


Dave Brackett

unread,
Aug 21, 2008, 6:09:02 AM8/21/08
to
As i am using global variables i wonder if it is related to
this:

"Persistent or global variables. If your objective or
constraint functions use persistent or global variables,
these variables may take different values on different
worker processors. Furthermore, they may not be cleared
properly on the worker processors."

Does anyone know how to use local variables with the GA
objective function?

Dave Brackett

unread,
Aug 26, 2008, 9:25:03 AM8/26/08
to
> Does anyone know how to use local variables with the GA
> objective function?

I have since solved this problem myself. To pass variables
to a GA the fitness function must be specified as shown in
the example below:

FitnessFcn=@(x)m_file_fitness_calc(x,other variables...)

then the ga is called using as: ga(FitnessFcn,other
options...) etc.

Global variables was indeed causing the initial problem and
once changed into local varibles using this method, the
errors were eliminated.

0 new messages