root/applications/dual/SIDP/SIDPS/matlab/generate_candidates.m @ 1209

Revision 1181, 0.7 kB (checked in by zimamiro, 14 years ago)
Line 
1function candidates=generate_candidates(best_control, search_region, num_of_candidates)
2if (mod(num_of_candidates,2)==0)
3    pom=((-((num_of_candidates-2)/2)):((num_of_candidates-2)/2))/((num_of_candidates-2)/2);
4    candidates=best_control*ones(num_of_candidates-1,1)+pom'*search_region;
5    candidates(num_of_candidates)=best_control+(2*rand-1)*search_region;
6else
7    pom=((-((num_of_candidates-1)/2)):((num_of_candidates-1)/2))/((num_of_candidates-1)/2);
8    candidates=best_control*ones(num_of_candidates,1)+pom'*search_region;
9end         
10pom1=(max(candidates)-min(candidates))/(2*num_of_candidates);
11for i=1:num_of_candidates
12    if(candidates(i)<0)
13        candidates(i)=abs(abs(candidates(i))-pom1);
14    end
15end
16end
Note: See TracBrowser for help on using the browser.