COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### parfor, can not be classified help

• Email
• Follow

```Hi,
I'm new to the Parallel Computing toolbox and am having trouble converting some of my code to be compliant to support variable classification within my 'parfor' loop. Could someone help explain what is wrong with this simplified example?

Pop(40,10) = zeros;
[pop_size, pop_cols] = size(Pop);

parfor a = 1 : pop_size
Child = rand(1,pop_cols);
Pop(a, :) = Child();
Pop(a, pop_cols) = inf; %This line causes Pop not to be able to be classified
end

"??? Error: The variable Pop in a parfor cannot be classified.
See Parallel for Loops in MATLAB, "Overview".

Error in ==> test at 5
parfor a = 1 : pop_size"

In my other program even the prior line with the Child assignment flags the same error. As I'm only effecting individual rows it should be able to be made parallel.

```
 0

See related articles to this posting

```"Paul Matthews" wrote in message <io21gc\$isj\$1@fred.mathworks.com>...
> Hi,
>     I'm new to the Parallel Computing toolbox and am having trouble converting some of my code to be compliant to support variable classification within my 'parfor' loop. Could someone help explain what is wrong with this simplified example?
>
> Pop(40,10) = zeros;
> [pop_size, pop_cols] = size(Pop);
>
> parfor a = 1 : pop_size
>     Child = rand(1,pop_cols);
>     Pop(a, :) = Child();
>     Pop(a, pop_cols) = inf; %This line causes Pop not to be able to be classified
> end
>
> "??? Error: The variable Pop in a parfor cannot be classified.
>  See Parallel for Loops in MATLAB, "Overview".
>
> Error in ==> test at 5
> parfor a = 1 : pop_size"
>
> In my other program even the prior line with the Child assignment flags the same error. As I'm only effecting individual rows it should be able to be made parallel.
>

If I rearrange the code it works, but it doesn't answer the question of why in the first place.

Pop(40,10) = zeros;
[pop_size, pop_cols] = size(Pop); % pop_size and pop_cols are broadcast variables

parfor a = 1 : pop_size
Child = rand(1,pop_cols); %Child is temporary variable
Child(pop_cols) = inf;
Pop(a, :) = Child(); % Pop is sliced output variable
%Pop(a, pop_cols) = inf; %This line causes Pop not to be able to be classified
end
```
 0

```
"Paul Matthews" <paul.matthews@agcocorp.com> wrote in message
news:io21gc\$isj\$1@fred.mathworks.com...
> Hi,
>    I'm new to the Parallel Computing toolbox and am having trouble
> converting some of my code to be compliant to support variable
> classification within my 'parfor' loop. Could someone help explain what is
> wrong with this simplified example?
>
> Pop(40,10) = zeros;
> [pop_size, pop_cols] = size(Pop);
>
> parfor a = 1 : pop_size
>    Child = rand(1,pop_cols);
>    Pop(a, :) = Child();
>    Pop(a, pop_cols) = inf; %This line causes Pop not to be able to be
> classified

I think you're expecting this to be a sliced variable:

http://www.mathworks.com/help/toolbox/distcomp/brdqtjj-1.html#bq_tcng-1

but it fails the criterion listed in the second bullet "Fixed Index Listing"
because you're indexing into it with both (a, :) and (a, pop_cols) in the
loop.

Preallocate Pop to be an appropriately sized random matrix prior to entering
the PARFOR loop and fill in the particular element whose values you want to
replace by inf inside the loop, or preallocate the entire array to be Inf
and fill in all but the last column with random data, or just eliminate the
PARFOR loop entirely.

--
Steve Lord
slord@mathworks.com
http://www.mathworks.com

```
 0
Reply slord (13686) 4/12/2011 5:49:38 PM

```"Steven_Lord" <slord@mathworks.com> wrote in message <io23ba\$kls\$1@fred.mathworks.com>...
>
>
> "Paul Matthews" <paul.matthews@agcocorp.com> wrote in message
> news:io21gc\$isj\$1@fred.mathworks.com...
> > Hi,
> >    I'm new to the Parallel Computing toolbox and am having trouble
> > converting some of my code to be compliant to support variable
> > classification within my 'parfor' loop. Could someone help explain what is
> > wrong with this simplified example?
> >
> > Pop(40,10) = zeros;
> > [pop_size, pop_cols] = size(Pop);
> >
> > parfor a = 1 : pop_size
> >    Child = rand(1,pop_cols);
> >    Pop(a, :) = Child();
> >    Pop(a, pop_cols) = inf; %This line causes Pop not to be able to be
> > classified
>
> I think you're expecting this to be a sliced variable:
>
> http://www.mathworks.com/help/toolbox/distcomp/brdqtjj-1.html#bq_tcng-1
>
> but it fails the criterion listed in the second bullet "Fixed Index Listing"
> because you're indexing into it with both (a, :) and (a, pop_cols) in the
> loop.
>
> Preallocate Pop to be an appropriately sized random matrix prior to entering
> the PARFOR loop and fill in the particular element whose values you want to
> replace by inf inside the loop, or preallocate the entire array to be Inf
> and fill in all but the last column with random data, or just eliminate the
> PARFOR loop entirely.
>
> --
> Steve Lord
> slord@mathworks.com
> http://www.mathworks.com

Hi Steven,
Thanks for the response. I've read the referenced content, but am still struggling to determine how to change the code to address the issue. I've enclosed the actual function in case you're able to offer any explicit suggestions(the error is at the end and there's a warning halfway down commented);

function [ Pop2 ] = NextGen( Pop )
%for a given population take a weighted random selection from the
%current population (Pop) for two parents and cross them over to
%create a new child. Repeat this process for 3/4 of the population
%creating a new population (Pop2) that still contains the best 1/4
%from the initial population.

[pop_size, pop_cols] = size(Pop);
Pop2 = Pop; %Create new population (we'll keep the best)

%Breed
parfor a = pop_size / 4 + 1: pop_size %replace 3/4 of pop
%Select Parent ID's
p1 = floor(randw(pop_size, 1)) + 1;
p2 = p1;
while p1 == p2 %No mating with yourself
p2 = floor(randw(pop_size, 1)) + 1;
end

%create child
pp1 = Pop(p1,:); % <-- WARNING : Pop is indexed,but not sliced...
pp2 = Pop(p2,:);
Child = Crossover(pp1, pp2);
while row_exists(Pop2, Child) == 1 %no identical twins
%Select Parents
p1 = floor(randw(pop_size, 1)) + 1;
p2 = p1;
while p1 == p2 %Make sure they're unique
p2 = floor(randw(pop_size, 1)) + 1;
end
Child = Crossover(Pop2(p1,:), Pop2(p2,:));
end
Child(pop_cols) = inf;  %reset performance field
Pop2(a,:) = Child; % <-- ERROR can't classify Parfor
end;
end

Thanks, Paul.
```
 0

```Ok,
I believe I have it now. I think it was the size of Child was changing each pass which then had the knock on of effecting Pop2. The solution was to define the size of Child outside of the parfor such that the parfor know that only the context are being updated and not the size, which then made Pop2 happy.

Paul.
```
 0

``` Sir Are you finally classify the variable pop2 are not?
```
 0
Reply p.priyanga19 (2) 6/28/2012 5:41:06 AM

```"Paul Matthews" wrote in message <io21gc\$isj\$1@fred.mathworks.com>...
> Hi,
>     I'm new to the Parallel Computing toolbox and am having trouble converting some of my code to be compliant to support variable classification within my 'parfor' loop. Could someone help explain what is wrong with this simplified example?
>
> Pop(40,10) = zeros;
> [pop_size, pop_cols] = size(Pop);
>
> parfor a = 1 : pop_size
>     Child = rand(1,pop_cols);
>     Pop(a, :) = Child();
>     Pop(a, pop_cols) = inf; %This line causes Pop not to be able to be classified
> end
>
> "??? Error: The variable Pop in a parfor cannot be classified.
>  See Parallel for Loops in MATLAB, "Overview".
>
> Error in ==> test at 5
> parfor a = 1 : pop_size"
>
> In my other program even the prior line with the Child assignment flags the same error. As I'm only effecting individual rows it should be able to be made parallel.
>

How to classify that Pop2 variable in this program Finally sir?
```
 0
Reply p.priyanga19 (2) 6/28/2012 5:45:07 AM

```
"PRIYANGA " <p.priyanga19@gmail.com> wrote in message
news:jsgr13\$981\$1@newscl01ah.mathworks.com...
> "Paul Matthews" wrote in message <io21gc\$isj\$1@fred.mathworks.com>...
>> Hi,
>>     I'm new to the Parallel Computing toolbox and am having trouble
>> converting some of my code to be compliant to support variable
>> classification within my 'parfor' loop. Could someone help explain what
>> is wrong with this simplified example?
>>
>> Pop(40,10) = zeros;
>> [pop_size, pop_cols] = size(Pop);
>>
>> parfor a = 1 : pop_size
>>     Child = rand(1,pop_cols);
>>     Pop(a, :) = Child();
>>     Pop(a, pop_cols) = inf; %This line causes Pop not to be able to be
>> classified
>> end

http://www.mathworks.com/help/toolbox/distcomp/brdqtjj-1.html#bq_of7_-1

Is Pop the loop variable? No, that's a.
Is Pop a sliced variable? Does it satisfy the four requirements given on
that page? It does not, so it is not a sliced variable. In particular it
fails the "Fixed Index Listing" requirement; in one place you index into it
with a and : and in another you index into it with a and pop_cols.
Similarly Pop is not a broadcast, reduction, or temporary variable.

You can do what you want by modifying the temporary Child variable
(replacing its last element with Inf) and then deleting the third line
inside the PARFOR. That should cause Pop to satisfy the four requirements
for a sliced variable.

parfor a = 1 : pop_size
Child = rand(1,pop_cols);
Child(end) = Inf;
Pop(a, :) = Child();
end

Note I haven't tested this, but I believe it should work.

--
Steve Lord
slord@mathworks.com
http://www.mathworks.com

```
 0
Reply slord (13686) 6/28/2012 1:19:24 PM

7 Replies
34 Views

Similar Articles

12/11/2013 5:27:57 AM
[PageSpeed]

Similar Artilces:

Framework help: Can HTML::Template do this? If not, what CPAN module can?
I'm trying not to reinvent the wheel, but I'm having difficulty determining if the wheel I'm needing has been invented. I've looked at HTML::Template POD, and I get the basic concept. In my ignorance I'm failing to see how I can apply it to my problem, and if there are other CPAN modules that are better suited to my task. I want to have a DWIMy page component system so that page controls can be called out and "Do The Right Thing". Example: I have a calendar input widget set that requires pieces of HTML, JavaScript, and CSS, which need to be exposed in the co...

Who can help me?
Hello, everyone! Now I have wrote an adaptive niche PSO (particle swarm optimization) code, which can be used in optimizing Shubert2D function and other multimodal fuction. I want other niche code (Such as sharing fitness GA etc.) for comparing the performance of them. Who can help me, give me the code or download address. The Matlab or C code is prefer to others. Thank you very much! Martin Zhang No one care for this group and my message! That's make me feel very sad. Martin Zhang wrote: > Hello, everyone! > Now I have wrote...

can't get special-display-regexps to work for gdb buffers, but can for help buffers
I am trying to get my debug/gdb window in its own frame. I have this set: (setq special-display-regexps '("^\*Help.*" "^\*gdb.*")) "Help" windows open in their own frames, but "gdb" ones do not. Is a "gdb" window special in some way? thanks again -sal >>>>> "pbb" == pookiebearbottom@yahoo.com pbb> Is a "gdb" window special in some way? Tongue-in-cheek: mine is named "*gud-a.out*" ^ universal debugger -- Marc Girod ...

can u help me?
can anyone help me with my homework? Here is some information about my homework. Revision Control in Multiuser Settings: --------------------------------------- We have seen some facilities of OpenOffice Writer for tracking changes. These features are useful when a document is circulated for contributions but control of merging changes is on one person. When multiple users work on same document simultaneously, a more comprehensive system is needed. We need to: * Track and record changes to documents * Go back to certain revisons when necessary * Prevent conflicting updates to ...

Can anyone help this out
I would like to test different values of pct.. but it seems macro doesn't recognize decimal.. I probably need to add %eval function?? tried many ways, but no luck %macro sensitivtiy (pct=0.05); Data aa; set bb; if min_pymt<=&pct*bal then output; run; ..... %mend; %sensitivity (pct=0.05); %sensitivity (pct=0.1); %sensitivity (pct=0.15); %sensitivity (pct=0.2); %sensitivity (pct=0.25); %sensitivity (pct=0.3); %sensitivity (pct=0.35); Thanks a lot for any tips Try adding () otherwise SAS isn't doing what you think it's doing: if min_pymt&...

can u help me?
can anyone help me with my homework? Here is some information about my homework. Revision Control in Multiuser Settings: --------------------------------------- We have seen some facilities of OpenOffice Writer for tracking changes. These features are useful when a document is circulated for contributions but control of merging changes is on one person. When multiple users work on same document simultaneously, a more comprehensive system is needed. We need to: * Track and record changes to documents * Go back to certain revisons when necessary * Prevent conflicting updates to ...

Can any Help me by explain it.
Dear Friends, I had written a program using delete operator in C++. The books wot I followed is stating that using new operator will allocate the memory for the object and delete operator will remove the memory allocated to the object which is reffered by an pointer object. But my program is still working when I deleted the objected. I had included the Program Code for your verification. Can any one help me how it is working. or any link address to learn more about the operators. Program code is :- #include<iostream.h> #include<conio.h> class demo { int a; public: demo...

Can someone help me..
Understand what I'll need to do to reach the internet in France via phone modem or wirelessly? Also, should I use Yahoo mail or .Mac? I find .Mac slow here at home and am wondering whether I should just set up a Yahoo account to download into my mail account on my iBook running 10.2.8. What settings will I need to change, etc. I'm really a blonde on this subject. I leave Wed. so I need info quick! Please write me at my cox account. Patdart@cox.net [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for det...

Newbie can you help
I am trying to generate a ramdom letter in an array between a and e not sure how to write this "www.ttdown.com" <james.ed@ntlworld.com> wrote in message news:o73aqv4mnh324k5gj50djdq5mhffj3d4mi@4ax.com... > I am trying to generate a ramdom letter in an array between a and e > not sure how to write this char aToE = ((char)('a'+(int)(Math.random()*5))); -- Mike W Still can't figure out what is going wrong here is my code import javax.swing.JOptionPane; public class Random1 { public static void main (String args[]){ int letter; String output; //...

can somebody help?
hesitating between Dell Inspiron 8600c with the Pentium� M Processor 735 ( 1.70 GHz) or the dell 9100 xps with the Pentium� 4 Processor (3.40 GHz) Is there a great difference in speed and general possibilities between these two models? would like to use the laptop as a desktop replacement and also to take it with us while travelling I know that the 9100 is heavier and has a shorter batterylife. Is the M processor as fast as the pentium 4? can somebody help? maxi <maxi@pandora.be> wrote: : hesitating between Dell Inspiron 8600c with the Pentium? M Processor 735 : ( 1....

Can nobody help me???
Hallo there, this is my code: image1 = imread('image1.bmp'); image1 = im2bw(image1); M = bwlabel(image1, 8); imwrite(M, 'myImage.bmp'); How can I save an image (bmp), so that in each pixel is the element of the matrice M? If I save the matrice M with the command "imwrite" in each pixel of the myImage.bmp is an rgb-value. But I don't want a rgb-value, I want the label (element) of the matrice M. How can I realize it? Please I need help!!! Best regards, Vicky Vicky <bonsai19@gmx.de> wrote in message <gfc8tj\$4mb\$1@aioe.org>... > Hallo there,...

should be simple..but eh Can you help
Hi... I have a text file that looks like this: title: fdsfdsfsd fdsfdsf number: 234234234234324243 animal: pig title: sf32erweff fwef wef we number: 456456456 animal: hen title: cvbvcxvcxvcvvc number: 340320324032403 animal: horse .... ... .. I want to 'grep' for a string whose line begins with title (^title) and if found automatically print out that line AND the following 2 lines. I don't want to use SED, but PERL. Anyone of you gurus able to assist on how to do this in PERL? thanks Bob Bob wrote: > I have a text file that looks like this: > [...] > I want to...

Problem
I have a problem, and i would appreciate some help. Here is the situation. 1. I have to model a 150x25 channel rolled to 2000id, toes out. The way i did this was to insert the appropriate sketch from the structural steel toolbox and then, with the help of a centre line, used the revolve boss command to complete. 2. Now i have put holes to put on the inside face. I cannot think of an easy way of doing this. Maybe I have drawn the channel wrong in the first instance. I would prefer to be able to flatten the channel, but using the revolved boss command has made this impossible. Any help would ...

anyone can help me on javascript?
I got a difficult problem about javascript. Can someone please help me? If I use the <form> tag, and I use the <input type ="text" name="input"> tag, I can get the value by using document.formname.input.value , but if I am using <input type="file" name="file"> to browse for files, how can I get its value? Anyone who are interested to answer my question please email to me at cyx.thunderfoot@gmai.com , thanks a lot. cyx.thunderfoot@gmail.com wrote: > I got a difficult problem about javascript. Can someone please help me? > If I...

EQULIB can someone help me on this
This a directory file, not a library, at least the one i downloaded from hpcalc.org. it is a string. i have searched back on threads but what i find doent make sense, i am fairly new at this. i am using a sd card for transfer but it did the same darn thing, turned it into a string. can someone guide me into what i am needing to do? Travis tjwood@bmailed.com (Travis) wrote in message news:<1f51036e.0312090742.4adab77@posting.google.com>... > This a directory file, not a library, at least the one i downloaded > from hpcalc.org. it is a string. i have searched back on threads ...

Can you help identify this font?
Hello I'm trying to identify the fonts used on this motorcycle helmet manufacturer's logo. I've tried some font identifier sites, but I just dont have enough letters to get anything meaningful. Can anyone help? Thanks ...

Can you help identify these fonts?
Hello I'm trying to identify the fonts used on this motorcycle helmet manufacturer's logo. I've tried some font identifier sites, but I just dont have enough letters to get anything meaningful. http://www.kristam.com/font/hjc_logo.jpg Can anyone help? Thanks Perhaps is "Letraset Compacta Black" -- email disabled Thanks so much 1218 !! This will get me real close - appreciate your help ...

Hi can smbody help out!!!!???
Hi guys!!! Can anybody tell me how to write a utility in which u give the filename as parameter and onrunning it , it will generate a report which gives the logical files of that particular physical file,library name of the logicals and the physical file. Just a brief description wud do...waiting for all ur cool ideas...keep writing... I think you'll have to look at the command DSPDBR DSPDBR FILE(MYFILE) OUTPUT(*PRINT) It will produce a spoolfile with the info you need Sander P ...

Labview Error
Possible reason(s): LabVIEW: Open VI Reference will no longer match VIs in memory by file name. A VIs full name now includes any owning libraries so a filename is no longer sufficient. You can use strip path to wire the filename as a string, but this will not work for VIs in libraries. VI Path: C:\Program Files\National Instruments \LabVIEW 8.0\examples\Sound and Vibration\Utility\Cosmetic\ SVXMPL_Third Octave Analysis for Multiprocessor (Simulated).vi I get the above error when I run a LabView example on 1/3rd octave analysis. Any ideas? Thanks N. naebad, &nbsp; Are you just ru...

Major problems...help if you can
Hi. I'm running Windows ME on an HP that's about 3 years old. Recently, (within the last few weeks) it has been freezing frequently on startup, shutdown, or while running windows. It also starts in safe mode a lot, or turns itself off randomly. I think it is deleting files also. My norton Antivirus nolonger works because it says it cannot locate the scan engine. It worked fine before. I used an online scanner to scan for viruses and found nothing. I replaced the RAM, and ran Scandisk. Now it is saying that a critical file needed to run windows cannot be found. It will rarely ...