Revision 1249, 1.1 kB
(checked in by zimamiro, 14 years ago)
|
|
Rev | Line | |
---|
[1249] | 1 | function candidates=generate_candidates(best_control, regulator_parameters) |
---|
| 2 | num_of_candidates=regulator_parameters.num_of_candidates; |
---|
| 3 | candidates=zeros(size(best_control),num_of_candidates); |
---|
| 4 | if (regulator_parameters.generate_candidates_mode=='rand') |
---|
| 5 | for i=1:num_of_candidates |
---|
| 6 | candidates=[best_control*ones(1,)+rand(size(best_control),num_of_candidates-1).*(-1).^round(rand(2,num_of_candidates-1)) best_control]; |
---|
| 7 | end |
---|
| 8 | else |
---|
| 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 | pom1=(max(candidates)-min(candidates))/(2*num_of_candidates); |
---|
| 18 | for i=1:num_of_candidates |
---|
| 19 | if(candidates(i)<0) |
---|
| 20 | candidates(i)=abs(abs(candidates(i))-pom1); |
---|
| 21 | end |
---|
| 22 | end |
---|
| 23 | end |
---|
| 24 | end |
---|