clear all
%global X10
% --------8--------------------- 装甲兵工程学院 -------------------------------
% x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16];
% y = [1 1 1 5 4 24 6 14 33 1 30 22 13 22 77 7];
% g = ((x)+sqrt((x)-cos((x)+sin(x))))+cot((x)+sqrt(x))
% g = abs(((x)-sin((x)+sin((x)-sqrt(x))))+tan((((x)-sin(x)).*sin((x).^tan(x)))./tan(((x).^cos(x))-exp((x)./cot(x)))))
% ------------------------------ 装甲兵工程学院 ---leiji----------------------------
% x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16];
% w = [1 1 1 5 4 24 6 14 33 1 30 22 13 22 77 7];
% y = cumsum(w);
% ----------- 瓦斯预测 ------- 数据序列矩阵 -----------------
x=[1.121053,1.052632,1.000000,0.947368,0.905263,0.852632,0.800000,0.747368,0.705263,0.652632,0.600000,0.547368,0.526316,0.505263,0.484211,0.473684,0.463158,0.452632,0.442105,0.431579,0.421053,0.410526,0.400000,0.389474,0.378947,0.368421,0.357895,0.347368];
y=[0.484515,0.428333,0.41278,0.403545,0.400569,0.386055,0.386707,0.380415,0.375948,0.373822,0.374814,0.367592,0.366922,0.371899,0.376991,0.382937,0.378579,0.377283,0.374799,0.375938,0.382451,0.380307,0.381883,0.383498,0.378111,0.395578,0.411276,0.421358];
% ---------------- 累计含量 -------------------
% g = 0.1*((((x).*log(((x).^log((x)+sin(x)))./sqrt((x)-cos((x).^sin(x)))))+sin(((((x)+sin(x))-exp((x)+log(x))).*log(x))./sin((((x).^sqrt(x))./sqrt(x))+sin(x))))+sin(x))
% --------------------------------------------------
% y = [0.2500 0.1000 0.0110 0.6900 0.3100 0.0410 0.9030 0.7652 0.5190 0.3167];
% g = 1./30.*(x)./sqrt((5.264)./sqrt((((((12.4461).*tan(x))./sin(0.1642))./cot(x))+tan(x)).*log(x)))
% g = abs(abs(1./1.8236.*sin((x-4.5)+tan(((x)-log(x)).*sin(x)))-log(x))-1.5)
% --------- 电子器件寿命预测 ---------《基于灰色系统理论下卫生陶瓷设备电子器件寿命预测》
% x = [1 2 3 4 5 6 7 8 9 10];
% y = [2.01 4.35 6.92 9.61 12.20 15.49 18.74 22.31 26.06 30.03];
% g = ((x)+sqrt(x)).*log(x)
% g = (x).*sqrt(x)
% -------------------------- NTDS ------------------------------------------
% x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30];
% w = [9 12 11 4 7 2 5 8 5 7 1 6 1 9 4 1 3 3 6 1 11 33 7 91 2 1 87 47 12 9];
% y = cumsum(w);
% g = (x).^cos(((x).^tan(x))+cos(x))
% g = (x)-cot(((x).*sqrt(x)).*tan((x).^sqrt((x).*log(x))))
% g = (x)-tan((x)./sin((((x)./sqrt(x))-log(x))-sin(x)))
% g = 6.5.*abs(((x)+log(x)).*tan((x).^log(((((x)-log(x)).^cot(x)).^log(((x)./sqrt(x))./sqrt((x).^sin(x)))).^sqrt((((x).*sqrt(x))-tan(x))-exp(x)))))
% g = (((x)-cos(x)).*log((x)-sin(x))).*log(x)
% g = (x)+sqrt(((x)-sin((((x)-exp(x))./cot(x)).*tan(x))).^log(x))
% g = (((x).*log(x))+cot((x)+cot(x))).*log(x)
% g = ((x).^exp((x)./exp(x))).*sqrt((((x).*sqrt(x)).*cos(x))./cos(x))
% g = (x).^log(((x)+log(x))./sqrt(x))
% -------------------------- SYS1 -------------------------------
% x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136];
% w = [3 30 113 81 115 9 2 91 112 15 138 50 77 24 108 88 670 120 26 114 325 55 242 68 422 180 10 1146 600 15 36 4 0 8 227 65 176 58 457 300 97 263 452 255 197 193 6 79 816 1351 148 21 233 134 357 193 236 31 369 748 0 232 330 365 1222 543 10 16 529 379 44 129 810 290 300 529 281 160 828 1011 445 296 1755 1064 1783 860 983 707 33 868 724 2323 2930 1461 843 12 261 1800 865 1435 30 143 108 0 3110 1247 943 700 875 245 729 1897 447 386 446 122 990 948 1082 22 75 482 5509 100 10 1071 371 790 6150 3321 1045 648 5485 1160 1864 4116];
% y = cumsum(w); g = 3.8923.*abs((x).*log(((x)+log(x)).*exp(x)))
% g = abs((x)./cos((x).*exp(((x).*log(x))+cos(x))))
% -------------------------- SYS2 -------------------------------
% x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86];
% w = [479 266 277 554 1034 249 693 597 117 170 117 1274 469 1174 693 1908 135 277 596 757 437 2230 437 340 405 535 277 363 522 613 277 1300 821 213 1620 1601 298 874 618 2640 5 149 1034 2441 460 565 1119 437 927 4462 714 181 1485 757 3154 2115 884 2037 1481 559 490 593 1769 85 2836 213 1866 490 1487 4322 1418 1023 5490 1520 3281 2716 2175 3505 725 1963 3979 1090 245 1194 994 3902];
% y = cumsum(w);
% 累积失效数据序列 2006.5.16 g = 13.1874.*(x).*log((x).*exp(x))
% -------------------------- SYS3 -------------------------------
% x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207];
% r = [39 10 4 36 4 5 4 91 49 1 25 1 4 30 42 9 49 44 32 3 78 1 30 205 5 129 103 224 186 53 14 9 2 10 1 34 170 129 4 4 35 5 5 22 36 35 121 23 33 48 32 21 4 23 9 13 165 14 22 41 12 138 95 49 62 2 35 89 90 69 22 15 19 42 14 11 41 210 16 30 37 66 9 16 14 24 12 159 89 118 29 21 18 2 114 37 46 17 1 150 382 160 66 206 9 26 62 239 13 4 85 85 240 178 34 102 9 146 59 48 25 25 111 5 31 51 6 193 27 25 96 26 30 30 17 320 78 39 13 13 19 128 34 84 40 177 349 274 82 58 31 114 39 88 84 232 108 38 86 7 22 80 239 3 39 63 152 63 80 245 196 46 152 102 9 228 220 208 78 3 83 6 212 91 3 10 172 21 173 371 40 48 126 90 149 30 317 500 673 432 66 168 66 66 128 49 332];
% y = cumsum(r);
% g = (((x).*sqrt(x)).*log(x))+sin(x) 累积失效序列 2006.5.16
% 定义函数、终止符集合
%a=[-5:0.001:5];
a=[-5:0.00001:5];
%x1= a(floor(rand*(length(a))+1));
%x2= a(floor(rand*(length(a))+1));
%x3= a(floor(rand*(length(a))+1));
symbols{1} = {'log','sin','exp','cos','cot','tan','sqrt'};
%symbols{1} = {'+','-','.*','./'};
symbols{2} = {'x','x1','x2','x3'};
%symbols{2} = {'x'};
% 参数设定
popusize = 10000;
maxtreedepth = 7;
opt = [0.8 0.9 0.05 2 1 0.2 30 0.05 0 1];
% 初始化种群
popu = initpop(popusize,maxtreedepth,symbols);
for i = 1:popusize,
s{i} = tree_stringrc(popu.chrom{i}.tree,1,popu.symbols); % s中保留初始化生成的种群个体
%[x1(i),x2(i),x3(i),obj(i)] = objvalue2(popu,s{i},x,y);
obj(i) = objvalue(popu.chrom{i}.one,popu.chrom{i}.two,popu.chrom{i}.three,s{i},x,y);
XXX{1}(1,i)=popu.chrom{i}.one;
XXX{2}(1,i)=popu.chrom{i}.two;
XXX{3}(1,i)=popu.chrom{i}.three;
end
fitness = obj;
XXX{4}(1,:)=fitness;
A(1,:)=fitness;
B(1,:)=s;
best(1) = fitness(1);
for j = 1:popusize,
if (fitness(j) ~= 0) && (fitness(j)<best(1)),
best(1) = fitness(j); % best(1) 得到的是第一代个体中误差平方和最小值,即最优个体
best_solution{1} = s{j}; % best_solution{1} 第一代个体中最小误差值对应的个体
end
end
% --------------------------- 第二代开始 -------------------------------------------
ggap = opt(1);
pc = opt(2);
pm = opt(3);
tsels = opt(4);
rmode = opt(5);
% while best>=1000, % 终止条件
for ii = 2:1000,
selm = selection(popu,fitness,ggap,pc,pm,tsels); % 复制
% New generation 新个体的产生
%newix = [];
nn = 1;
for i=1:size(selm,1),
m = selm(i,3);
% 交叉 *** Crossover ***
if m==1,
p1 = selm(i,1
- 1
- 2
前往页