<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/234893</link>
    <title>MATLAB Central Newsreader - GA parallel computing toolbox error</title>
    <description>Feed for thread: GA parallel computing toolbox error</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 20 Aug 2008 14:16:03 -0400</pubDate>
      <title>GA parallel computing toolbox error</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/234893#596550</link>
      <author>Dave Brackett</author>
      <description>Hi, I have a genetic algorithm optimization function which &lt;br&gt;
I am trying to run using the parallel computing toolbox as &lt;br&gt;
explained here: &lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i&lt;/a&gt;&lt;br&gt;
ndex.html?/access/helpdesk/help/toolbox/gads/f7928.html&amp;http&lt;br&gt;
://www.google.co.uk/search?&lt;br&gt;
hl=en&amp;q=matlab+custom+plot+function&amp;meta=&lt;br&gt;
&lt;br&gt;
The GA works fine without running it in parallel, but when &lt;br&gt;
I open the matlabpool, the GA then returns the following &lt;br&gt;
error: ??? Error using ==&amp;gt; makeState at 50&lt;br&gt;
GA cannot continue because user supplied fitness function &lt;br&gt;
failed with the following error:&lt;br&gt;
Error using ==&amp;gt; reshape&lt;br&gt;
To RESHAPE the number of elements must not change.&lt;br&gt;
&lt;br&gt;
From the debugger, this appears to be happening when it is &lt;br&gt;
trying to score each member of the population:&lt;br&gt;
&lt;br&gt;
% Score each member of the population&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if strcmpi(options.Vectorized, 'off')&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Score = fcnvectorizer(state.Population&lt;br&gt;
(initScoreProvided+1:end,:),FitnessFcn,1,options.SerialUserF&lt;br&gt;
cn);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;catch&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;error('gads:makestate:fitnessCheck', ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'GA cannot continue because user supplied &lt;br&gt;
fitness function failed with the following error:\n%s', &lt;br&gt;
lasterr)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
Anyone any ideas why this would be happening? I'm not sure &lt;br&gt;
what details of my code are needed so feel free to ask for &lt;br&gt;
additional information. My version is 2008a (7.6.0.324).&lt;br&gt;
&lt;br&gt;
Thanks.</description>
    </item>
    <item>
      <pubDate>Wed, 20 Aug 2008 15:47:02 -0400</pubDate>
      <title>Re: GA parallel computing toolbox error</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/234893#596586</link>
      <author>Dave Brackett</author>
      <description>&amp;gt; I am trying to run using the parallel computing toolbox &lt;br&gt;
as &lt;br&gt;
&amp;gt; explained here: &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
ndex.html?/access/helpdesk/help/toolbox/gads/f7928.html&amp;http&lt;br&gt;
&amp;gt; ://www.google.co.uk/search?&lt;br&gt;
&amp;gt; hl=en&amp;q=matlab+custom+plot+function&amp;meta=&lt;br&gt;
&lt;br&gt;
Sorry, the correct url for this is&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/gads/i&lt;/a&gt;&lt;br&gt;
ndex.html?/access/helpdesk/help/toolbox/gads/f7928.html</description>
    </item>
    <item>
      <pubDate>Thu, 21 Aug 2008 10:09:02 -0400</pubDate>
      <title>Re: GA parallel computing toolbox error</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/234893#596729</link>
      <author>Dave Brackett</author>
      <description>As i am using global variables i wonder if it is related to &lt;br&gt;
this:&lt;br&gt;
&lt;br&gt;
&quot;Persistent or global variables. If your objective or &lt;br&gt;
constraint functions use persistent or global variables, &lt;br&gt;
these variables may take different values on different &lt;br&gt;
worker processors. Furthermore, they may not be cleared &lt;br&gt;
properly on the worker processors.&quot;&lt;br&gt;
&lt;br&gt;
Does anyone know how to use local variables with the GA &lt;br&gt;
objective function?</description>
    </item>
    <item>
      <pubDate>Tue, 26 Aug 2008 13:25:03 -0400</pubDate>
      <title>Re: GA parallel computing toolbox error</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/234893#597403</link>
      <author>Dave Brackett</author>
      <description>&amp;gt; Does anyone know how to use local variables with the GA &lt;br&gt;
&amp;gt; objective function?&lt;br&gt;
&lt;br&gt;
I have since solved this problem myself. To pass variables &lt;br&gt;
to a GA the fitness function must be specified as shown in &lt;br&gt;
the example below:&lt;br&gt;
&lt;br&gt;
FitnessFcn=@(x)m_file_fitness_calc(x,other variables...)&lt;br&gt;
&lt;br&gt;
then the ga is called using as: ga(FitnessFcn,other &lt;br&gt;
options...) etc.&lt;br&gt;
&lt;br&gt;
Global variables was indeed causing the initial problem and &lt;br&gt;
once changed into local varibles using this method, the &lt;br&gt;
errors were eliminated.</description>
    </item>
  </channel>
</rss>

