-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.file
More file actions
61 lines (43 loc) · 2.53 KB
/
test.file
File metadata and controls
61 lines (43 loc) · 2.53 KB
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
--- goes before storebestResult
FunctionCallback function = &sphere; it declares that fucntion is a variable of type Functionclalback.
FunctionCallback is a type, which declares function pointer which has return value of double and array[D] as parameter.
This function is getting used for findting f[D]
This F[D] is used to find the fitness value for fitness[numbrOfFoods] usin function 'function'
--- goes after storebestResult
SendEmployedBees
#running foodNumber of times bcz foodnmbr=employeeBees
for all solutions i (FoodNumbers) Do,
select one solution among all the foodsources randomly
select one particular position(param2change) in the food source randomly
(Randomly selected solution must be different from the solution i)
then solution[param2change]=Foods[i][param2change]+(Foods[i][param2change]-Foods[neighbour][param2change])*(r-0.5)*2;
(where r is a random value)
Make solution1(descrete) array using SPV1 call out of the solution we made just now
find the fitness1 of the current solution
if current solution is better than old solution (Fitness1[i]):
Replace the current path in Foods1[i][] and update cost in fitness1[i]
else
put trial[i] = trial[i]+1 //Solution could not be improved for trial[i] times continuousuly
CalculateProbabilities
update the prob[FoodNumber] array with probability value for new fitness1[FoodNumber] array.
eqn for the same is (0.9*(fitness1[i]/maxfit))+0.1
maxfit is nothing but the minimum fitness value of the current fitness1[NF]
(i think it is the probability of getting the solution replaced)
SendOnlookerBees
t,i=0
while (t<foodNumber)
find a random number r
if r<prob[i]
randomly take a city and find a neighbor solution among all the foods available(Randomly selected solution must be different from the solution i)
t++
copy food[i][] to solution and make a random number
solution[param2change]=Foods[i][param2change]+(Foods[i][param2change]-Foods[neighbour][param2change])*(r-0.5)*2;
do SPV on solution such that it will update solution1 with descrete values
CalculateFitness1(solution1)
If current solution is better than old solution (Fitness1[i]):
Replace the current path in Foods1[i][] and update cost in fitness1[i]
else
put trial[i] = trial[i]+1 //Solution could not be improved for trial[i] times continuousuly
SendScoutBees
Find maximum trialled food source
Then do a init on that food source