Path: news.mathworks.com!not-for-mail
From: "Jonny O'Connell" <jonnydotoconnelldotx@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Vectorization Help...I think
Date: Sat, 17 Jul 2010 18:06:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 20
Message-ID: <i1sreb$6fs$1@fred.mathworks.com>
Reply-To: "Jonny O'Connell" <jonnydotoconnelldotx@gmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1279389963 6652 172.30.248.37 (17 Jul 2010 18:06:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 17 Jul 2010 18:06:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2413904
Xref: news.mathworks.com comp.soft-sys.matlab:653919

Hi,

I'm really new to MALTAB, I only sat the module this semester, but somehow I've managed to get myself a summer project writing a parallel evolutionary algorithm in it! 

Anyway I've done some basic profiling on my code and found that one line is accounting for about ~45% of my run time. It's a find function, but it's pretty much a copy and paste from the help documentation (obviously adapted for my needs), but I'm not sure if I can improve it any further.

From the literature I've read on MATLAB, vectorization is king, and should be used anywhere it can be for better performance. I've had some success on various parts of the program, but I'm not sure if what I have is a candidate for vectorization and I was hoping someone could cast an experienced eye over it.

% Perform swapping until cycle is complete
    while cycleIndex ~= seedNumber;
        cycleIndex = find(firstParent == secondParent(currentNumber));
        offspring(cycleIndex) = firstParent(cycleIndex);
        currentNumber = cycleIndex;
    end

The culprit is the 'find' line, the first line in the loop. 

Any pointers would be good! 

Cheers