Thanks for your submission, it works wonderfully. And thank you for sticking to familiar syntax for those of us who have been using the optimization toolbox, this really helps with the learning curve.
I saw some comments about taking advantage of parallel processing, but it didn't look like anyone has done anything about it thus far. When I profiled pso using my objective function the big place that things got bogged down was obviously in the many objective function evaluations. As such I changed the code a little bit to evaluate all of the objective function calls in parallel. I changed the following lines from this:
for i = setdiff(1:n,find(state.OutOfBounds))
state.Score(i) = fitnessfcn(state.Population(i,:)) ;
end % for i
tempstatepop = state.Population;
itinerary = setdiff(1:n,find(state.OutOfBounds));
temp = zeros(length(itinerary),1);
parfor i = 1:length(itinerary)
temp(i) = fitnessfcn(tempstatepop(itinerary(i),:)) ;
end % for i
state.Score(itinerary) = temp;
This is probably a crude way of doing it, but even so I saw a speed up of just under 3 times. Perhaps something similar will be helpful in a future build. Thanks again.