
Source-code of ABC algorithm in C++ 23
2.4 Source-code of ABC algorithm in C++
1 #i nclude <io st re am >
2 using namespace s td ;
3 #i nclude < s t d i o . h>
4 #i nclude < s t d l i b . h>
5 #i nclude <math . h>
6 #i nclude <c o ni o . h>
7 #i nclude <time . h>
8 /∗ C o ntro l Parameters o f ABC a l g o r i t hm ∗/
9 #defin e FoodNumber 20
10 #defin e l i m i t 100
11 #defin e maxCycle 3000
12 /∗ Problem s p e c i f i c v a r i a b l e s ∗/
13 #defin e D 50
14 #defin e l b −5.12
15 #defin e ub 5 . 1 2
16 double Foods [ FoodNumber ] [ D ] ;
17 double f [ FoodNumber ] ;
18 double f i t n e s s [ FoodNumber ] ;
19 double t r i a l [ FoodNumber ] ;
20 double pro