Revision 1249, 1.1 kB
(checked in by zimamiro, 14 years ago)
|
|
Line | |
---|
1 | function candidates=generate_candidates(best_control, regulator_parameters)
|
---|
2 | num_of_candidates=regulator_parameters.num_of_candidates;
|
---|
3 | dim_u=size(best_control,1);
|
---|
4 | if (regulator_parameters.generate_candidates_mode=='rand')
|
---|
5 | candidates=best_control*ones(1,num_of_candidates)+regulator_parameters.search_region*[rand(dim_u,num_of_candidates-1).*(-1).^(randi(2,dim_u,num_of_candidates-1)-1) zeros(dim_u,1)];
|
---|
6 | else
|
---|
7 | if (mod(num_of_candidates,2)==0)
|
---|
8 | pom=((-((num_of_candidates-2)/2)):((num_of_candidates-2)/2))/((num_of_candidates-2)/2);
|
---|
9 | candidates=best_control*ones(num_of_candidates-1,1)+pom'*search_region;
|
---|
10 | candidates(num_of_candidates)=best_control+(2*rand-1)*search_region;
|
---|
11 | else
|
---|
12 | pom=((-((num_of_candidates-1)/2)):((num_of_candidates-1)/2))/((num_of_candidates-1)/2);
|
---|
13 | candidates=best_control*ones(num_of_candidates,1)+pom'*regulator_parameters.search_region;
|
---|
14 | end
|
---|
15 | pom1=(max(candidates)-min(candidates))/(2*num_of_candidates);
|
---|
16 | for i=1:num_of_candidates
|
---|
17 | if(candidates(i)<0)
|
---|
18 | candidates(i)=abs(abs(candidates(i))-pom1);
|
---|
19 | end
|
---|
20 | end
|
---|
21 | end
|
---|
22 | end
|
---|