├── CCOA.m ├── GetChaoticNum.m ├── README.md ├── addChaos.m └── main.m /CCOA.m: -------------------------------------------------------------------------------- 1 | function [GlobalParams,GlobalMin,costs] =CCOA 2 | %% ------------------------------------------------------------------------ 3 | % coded by huawei Tong, 2021-04-21 4 | % Our paper : 5 | % Tong, H., Zhu, Y., Pierezan, J. et al. Chaotic Coyote Optimization Algorithm. J Ambient Intell Human Comput (2021). https://doi.org/10.1007/s12652-021-03234-5 6 | 7 | 8 | %% Optimization problem variables 9 | global lu nfevalMAX D FOBJ; 10 | VarMin = lu(1,:); 11 | VarMax = lu(2,:); 12 | global Np Nc ; 13 | n_packs = Np ; n_coy = Nc; 14 | global Initial_Value_1 Initial_Value_2 ; 15 | 16 | if n_coy < 3, error('At least 3 coyotes per pack!'); end 17 | % Probability of leaving a pack 18 | p_leave = 0.005*n_coy^2; 19 | Ps = 1/D; 20 | 21 | %% Packs initialization 22 | pop_total = n_packs*n_coy ; 23 | costs = zeros(pop_total,1); 24 | all_total = pop_total*D; 25 | chaotic_seq4 = addChaos(Initial_Value_1,all_total+1,1); 26 | chaotic_seq4 = chaotic_seq4(2:all_total+1); 27 | chaotic_seq4= reshape(chaotic_seq4,pop_total,D); 28 | 29 | coyotes = repmat(VarMin,pop_total,1) +chaotic_seq4.*(repmat(VarMax,pop_total,1) - repmat(VarMin,pop_total,1)); 30 | ages = zeros(pop_total,1); 31 | packs = reshape(randperm(pop_total),n_packs,[]); 32 | 33 | coypack = repmat(n_coy,n_packs,1); 34 | 35 | %% Evaluate coyotes adaptation 36 | for c=1:pop_total 37 | costs(c,1) = FOBJ(coyotes(c,:)); 38 | end 39 | nfeval = pop_total; 40 | %% Output variables 41 | [GlobalMin,ibest] = min(costs); 42 | GlobalParams = coyotes(ibest,:); 43 | 44 | %% Main loop 45 | NumLoop = 0; 46 | while nfeval < nfevalMAX 47 | % Stopping criteria 48 | %% Update the NumLoop 49 | NumLoop = NumLoop + 1; 50 | %% Execute the operations inside each pack 51 | for p=1:n_packs 52 | chaotic_seq2=zeros(2,n_coy+1); 53 | %Produce chaos seqences 54 | chaotic_seq2(1,:)= addChaos(Initial_Value_1,n_coy+1,1); 55 | chaotic_seq2(2,:)=addChaos(Initial_Value_2,n_coy+1,1); 56 | % Get the coyotes that belong to each pack 57 | coyotes_aux = coyotes(packs(p,:),:); 58 | costs_aux = costs(packs(p,:),:); 59 | ages_aux = ages(packs(p,:),1); 60 | n_coy_aux = coypack(p,1); 61 | 62 | % Detect alphas according to the costs 63 | [costs_aux,inds] = sort(costs_aux,'ascend'); 64 | coyotes_aux = coyotes_aux(inds,:); 65 | ages_aux = ages_aux(inds,:); 66 | c_alpha = coyotes_aux(1,:); 67 | 68 | % Compute the social tendency of the pack 69 | tendency = median(coyotes_aux,1); 70 | 71 | % Update coyotes' social condition 72 | new_coyotes = zeros(n_coy_aux,D); 73 | for c=1:n_coy_aux 74 | rc1 = randi(n_coy_aux); 75 | rc2 = randi(n_coy_aux); 76 | while rc2 == rc1 77 | rc2 = randi(n_coy_aux); 78 | end 79 | 80 | % Try to update the social condition 81 | % according to the alpha and the pack tendency 82 | new_c = coyotes_aux(c,:) + ... 83 | chaotic_seq2(1,c+1)*(c_alpha - coyotes_aux(rc1,:))+ ... 84 | chaotic_seq2(2,c+1)*(tendency - coyotes_aux(rc2,:)); 85 | % Keep the coyotes in the search space (optimization problem constraint) 86 | new_coyotes(c,:) = min(max(new_c,VarMin),VarMax); 87 | % Evaluate the new social condition 88 | new_cost = FOBJ(new_coyotes(c,:)); 89 | 90 | nfeval = nfeval+1; 91 | 92 | % Adaptation 93 | if new_cost < costs_aux(c,1) 94 | costs_aux(c,1) = new_cost; 95 | coyotes_aux(c,:) = new_coyotes(c,:); 96 | end 97 | end 98 | %% Birth of a new coyote from random parents 99 | parents = randperm(n_coy_aux,2); 100 | prob1 = (1-Ps)/2; 101 | prob2 = prob1; 102 | pdr = randperm(D); 103 | p1 = zeros(1,D); 104 | p2 = zeros(1,D); 105 | p1(pdr(1)) = 1; % Guarantee 1 charac. per individual 106 | p2(pdr(2)) = 1; % Guarantee 1 charac. per individual 107 | r = rand(1,D-2); 108 | p1(pdr(3:end)) = r < prob1; 109 | p2(pdr(3:end)) = r > 1-prob2; 110 | % Eventual noise 111 | n = ~(p1|p2); 112 | 113 | % Generate the pup considering intrinsic and extrinsic influence 114 | chaoticNum = GetChaoticNum(Initial_Value_1,n_coy,1); 115 | pup = p1.*coyotes_aux(parents(1),:) + ... 116 | p2.*coyotes_aux(parents(2),:) + ... 117 | n.*(VarMin + chaoticNum.*(VarMax-VarMin)); 118 | 119 | 120 | % Verify if the pup will survive 121 | pup_cost = FOBJ(pup); 122 | nfeval = nfeval + 1; 123 | worst = find(pup_cost < costs_aux == 1); 124 | if ~isempty(worst) 125 | [~,older] = sort(ages_aux(worst),'descend'); 126 | which = worst(older); 127 | coyotes_aux(which(1),:) = pup; 128 | costs_aux(which(1),1) = pup_cost; 129 | ages_aux(which(1),1) = 0; 130 | end 131 | 132 | %% Update the pack information 133 | coyotes(packs(p,:),:) = coyotes_aux; 134 | costs(packs(p,:),:) = costs_aux; 135 | ages(packs(p,:),1) = ages_aux; 136 | end 137 | %% A coyote can leave a pack and enter in another pack 138 | if n_packs > 1 139 | chaoticNum2 = GetChaoticNum(Initial_Value_1,n_coy,1); 140 | if chaoticNum2 < p_leave 141 | rp = randperm(n_packs,2); 142 | rc = randi(n_coy,1,2); 143 | aux = packs(rp(1),rc(1)); 144 | packs(rp(1),rc(1)) = packs(rp(2),rc(2)); 145 | packs(rp(2),rc(2)) = aux; 146 | end 147 | end 148 | 149 | %% Update coyotes ages 150 | ages = ages + 1; 151 | %% Output variables (best alpha coyote among all alphas) 152 | [GlobalMin,ibest] = min(costs); 153 | GlobalParams = coyotes(ibest,:); 154 | end 155 | 156 | end 157 | -------------------------------------------------------------------------------- /GetChaoticNum.m: -------------------------------------------------------------------------------- 1 | function [outputArg1] = GetChaoticNum(Initial_Value,row,column) 2 | Num = addChaos(Initial_Value,row,column); 3 | r=randi(row); 4 | while r == 1 5 | r=randi(row); 6 | end 7 | outputArg1=Num(1,r); 8 | end 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chaotic-Coyote-Optimization-Algorithm 2 | the Matlab code of CCOA which use Chebyshev Map 3 | 4 | Please run main.m 5 | 6 | Cite our paper by 7 | 8 | Tong, H., Zhu, Y., Pierezan, J. et al. Chaotic Coyote Optimization Algorithm. J Ambient Intell Human Comput (2021). https://doi.org/10.1007/s12652-021-03234-5 9 | -------------------------------------------------------------------------------- /addChaos.m: -------------------------------------------------------------------------------- 1 | function F=addChaos(Initial_Value,Max_iter,v) 2 | G = zeros(1,Max_iter); 3 | x(1)=Initial_Value; 4 | %Chebyshev map 5 | for i=1:Max_iter 6 | x(i+1)=cos(i*acos(x(i))); 7 | % G(i)=((x(i)+1)*100)/2; 8 | end 9 | %normalize it from [-1 1] to [0 1] 10 | a=-1; b=1; c=0; d=1; 11 | x=((x-a)*(d-c))/(b-a); 12 | G=x*v; 13 | G=G(1:Max_iter); 14 | 15 | F=G; 16 | end -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | function main 2 | % coded by huawei Tong, 2021-04-21 3 | clc ; close all;clear; 4 | global Initial_Value_1 Initial_Value_2 FOBJ; 5 | Initial_Value_1=0.8; 6 | Initial_Value_2=0.3; 7 | global nfevalMAX lu Np Nc D; 8 | D = 10; % Problem dimension 9 | lu = [-10*ones(1,D); 10 | 10*ones(1,D)]; % Seach space 11 | nfevalMAX = 20000; % Stopping criteria 12 | Np = 20; % Number of packs 13 | Nc = 5; % Number of coyotes 14 | % Optimization problem 15 | FOBJ = @(x) sum(x.^2); 16 | ExperTime=10; % setup experiments times 17 | for i = 1:ExperTime 18 | disp(['=====Experiments: ',num2str(i),'=====']) 19 | [GlobalParams,GlobalMin,costs] =CCOA; 20 | disp(['The cost is ',num2str(GlobalMin)]); 21 | end 22 | end 23 | 24 | --------------------------------------------------------------------------------