Im trying to optimized PI parameters using PSO, codes im using are below, please help. I would like to know why im getting negative values of kp and ki, i need positive values. of 0.945-15 range.    function F = tracklsq(pid)         syms x;         limit_1 = 0;         limit_2 = 10;         Area = int(x,limit_1, limit_2);         Kp = pid(1);         Ki = pid(2);         if((Kp>15)&&(Kp<0.5)) %setting limits             Kp=1.5;         end             if  ((Ki>15)&&(Ki<0.5))                 Ki=15;             end         z=Kp*0.1+Ki*0.1*Area; %objective function         sys_overshoot=z-1; % compute the overshoot         alpha=10;beta=10;         F=0.1*2*beta+sys_overshoot*alpha;     end    another M-file using PSO, its below:clearclcn = 30;           % Size of the swarm  no of birds bird_setp  =30;   % Maximum number of birds stepsdim = 2;          % Dimension of the problemc2 =2;          % PSO parameter C1 c1 = 2;        % PSO parameter C2 w =0.9;           % pso momentum or inertia  fitness=0*ones(n,bird_setp);                                       %-----------------------------%                                       %    initialize the parameter %                                       %-----------------------------%R1 = rand(dim, n);R2 = rand(dim, n);current_fitness =0*ones(n,1); %setting limits                                 %------------------------------------------------%                                 % Initializing swarm and velocities and position %                                 %------------------------------------------------%current_position = 10*(rand(dim, n)-.5); %setting limitsvelocity = .3*randn(dim, n) ;local_best_position  = current_position ;Im trying to optimized PI parameters using PSO, codes im using are below, please help. I would like to know why im getting negative values of kp and ki, i need positive values. of 0.945-15 range.for i = 1:n    current_fitness(i) = tracklsq(current_position(:,i));    endlocal_best_fitness  = current_fitness ;[global_best_fitness,g] = min(local_best_fitness) ;for i=1:n    globl_best_position(:,i) = local_best_position(:,g) ;end                                               %-------------------%                                               %  VELOCITY UPDATE  %                                               %-------------------%velocity = w *velocity + c1*(R1.*(local_best_position-current_position)) + c2*(R2.*(globl_best_position-current_position));                                               %------------------%                                               %   SWARMUPDATE    %                                               %------------------%current_position = current_position + velocity ;                                               %------------------------%                                               %  evaluate anew swarm   %                                               %------------------------%%% Main Loopiter = 0 ;        % Iterationscounterwhile  ( iter < bird_setp )iter = iter + 1;for i = 1:n,current_fitness(i) = tracklsq(current_position(:,i)) ;    endfor i = 1 : n        if current_fitness(i) < local_best_fitness(i)           local_best_fitness(i)  = current_fitness(i);             local_best_position(:,i) = current_position(:,i)   ;        end    end [current_global_best_fitness,g] = min(local_best_fitness);if current_global_best_fitness < global_best_fitness   global_best_fitness = current_global_best_fitness;    for i=1:n        globl_best_position(:,i) = local_best_position(:,g);    endend velocity = w *velocity + c1*(R1.*(local_best_position-current_position)) + c2*(R2.*(globl_best_position-current_position)); current_position = current_position + velocity;  sprintf('The value of interation iter %3.0f ', iter );end % end of while loop its mean the end of all step that the birds move it             xx=fitness(:,30);            [Y,I] = min(xx);            current_position(:,I)Im trying to optimized PI parameters using PSO, codes im using are below, please help. I would like to know why im getting negative values of kp and ki, i need positive values. of 0.945-15 range.
Tuning of PI controller using Particle swarm optimization
performance;matlab