Revision 1105, 1.1 kB
(checked in by zimamiro, 14 years ago)
|
|
Rev | Line | |
---|
[1105] | 1 | function candidates=generate_candidates(best_control, search_region, num_of_candidates,mode)
|
---|
| 2 | %OK
|
---|
| 3 | %vraci sloupec kandidatu na rizeni
|
---|
| 4 | switch 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
|
---|
| 17 | end
|
---|
| 18 |
|
---|
| 19 | pom1=(max(candidates)-min(candidates))/(2*num_of_candidates);
|
---|
| 20 | for i=1:num_of_candidates
|
---|
| 21 | if(candidates(i)<0)
|
---|
| 22 | candidates(i)=abs(abs(candidates(i))-pom1);
|
---|
| 23 | end
|
---|
| 24 | end
|
---|
| 25 |
|
---|
| 26 | end
|
---|