-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateData
More file actions
executable file
·72 lines (58 loc) · 1.91 KB
/
createData
File metadata and controls
executable file
·72 lines (58 loc) · 1.91 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
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
noParams=2
noIterations=200
noSwarms=5
noParticlesPerSwarm=50
# generate the data
awk 'BEGIN{for (i=0; i<10; i+=0.2) {print i}}' > PosData.txt
awk '{print (5 + sin($1 + 2) + ((rand() - 0.5) * 0.2 ))}' PosData.txt > RefData.txt
echo -e "0.0,10.0\n0.0,10.0" > ParamData.txt
# make a side by side version to be able to plot the data
paste PosData.txt RefData.txt | expand --tabs=10 > xyData.txt
# make an image
gnuplot plotRefData
# run PSO
./PSO.py -s $noSwarms \
-sp $noParticlesPerSwarm \
-i $noIterations \
-p $noParams
# make image of fit for each swarm
awk '{outData[$1][$2] = $3}
END{
for (it in outData)
{
printf "%i ", it ;
for (sw in outData[it])
{
printf "%-12.8f ", sqrt(outData[it][sw])
};
printf "\n"
}
}' Output.txt > SwarmFitPerIteration.txt
# make an image of the swarms sqrt(fit) over time
gnuplot plotSwarmFit
# make image of fit for each swarm
awk '{outData[$1][$2][$3] = $4}
END{
for (it in outData)
{
for (sw in outData[it])
{
for (par in outData[it][sw])
{
printf "%4i %-12.8f\n", it, outData[it][sw][par]
}
};
}
}' OutputPar.txt > ParticleHistory.txt
# make an image of the swarms param over time
sed 's/##/'$noParams'/' plotParHistoryTemplate > plotParHistory
for i in `seq 1 $noParams`
do
col=`echo "$i + 3" | bc`
echo "" >> plotParHistory
echo "set title \"Param $i\"" >> plotParHistory
echo "unset key" >> plotParHistory
echo "plot \"OutputPar.txt\" using 1:$col with points lc \"red\" ps 1.5 lw 1.5" >> plotParHistory
done
gnuplot plotParHistory