root/applications/dual/SIDP/Kopie (2) - finalni implementace/generate_candidates.m @ 1340

Revision 1113, 1.1 kB (checked in by zimamiro, 14 years ago)
Line 
1function candidates=generate_candidates(best_control, search_region, num_of_candidates,mode)
2%OK
3%vraci sloupec kandidatu na rizeni
4switch mode
5    case (0)    %nahodne rozlozeni kandidatu
6        candidates=best_control*ones(num_of_candidates-1,1)+(2*rand(num_of_candidates-1,1)-ones(num_of_candidates-1,1))*search_region;
7        candidates(num_of_candidates)=best_control;
8    case (1)    %linearni rozlozeni kandidatu
9        if (mod(num_of_candidates,2)==0)
10            pom=((-((num_of_candidates-2)/2)):((num_of_candidates-2)/2))/((num_of_candidates-2)/2);
11            candidates=best_control*ones(num_of_candidates-1,1)+pom'*search_region;
12            candidates(num_of_candidates)=best_control+(2*rand-1)*search_region;
13        else
14            pom=((-((num_of_candidates-1)/2)):((num_of_candidates-1)/2))/((num_of_candidates-1)/2);
15            candidates=best_control*ones(num_of_candidates,1)+pom'*search_region;
16        end         
17end
18
19pom1=(max(candidates)-min(candidates))/(2*num_of_candidates);
20for i=1:num_of_candidates
21    if(candidates(i)<0)
22        candidates(i)=abs(abs(candidates(i))-pom1);
23    end
24end
25
26end
Note: See TracBrowser for help on using the browser.