loosely-coupled-dss/results/analysis.R
2021-05-10 16:03:46 +02:00

55 lines
2.6 KiB
R

library("tidyverse")
library("knitr")
data=read_csv("results.csv")
finalEnergy=data%>%group_by(simkey,wireless,wakeupfor)%>%summarize(wireless=first(wireless),sd=sd(energy),wakeupfor=first(wakeupfor),energy=mean(energy))
finalStats=data%>%group_by(simkey,wireless,wakeupfor,seed)%>%
summarise(success=sum(nSend),totalUptime=mean(totalUptime))%>%
ungroup()%>%group_by(simkey,wireless,wakeupfor)%>%
summarise(sd=sd(success),success=mean(success),totalUptime=first(totalUptime))
# Add nSendFail to stats
sendFail=data%>%filter(node=="on0")%>%group_by(simkey,wireless,wakeupfor)%>%summarise(nSendFail=mean(nSendFail))
finalStats=finalStats%>%left_join(sendFail,by=c("simkey","wireless","wakeupfor"))
# Generate plots
ggplot(finalEnergy,aes(x=simkey,y=energy,fill=wireless))+
geom_bar(stat="identity",position=position_dodge())+
xlab("Scenarios")+ylab("Energy (J)")+
geom_errorbar(position=position_dodge(0.9),aes(ymin=energy-sd, ymax=energy+sd),width=0.5,size=1.5,) +
facet_wrap(~ wakeupfor) +
geom_text(aes(label = round(energy+sd), y= energy+sd),vjust=-0.4,position=position_dodge(0.9))+
geom_text(aes(label = round(energy-sd), y= energy-sd),vjust=+1.5,position=position_dodge(0.9))+
geom_text(aes(label = round(energy), y= energy/2),fontface="bold",colour="white",position=position_dodge(0.9))
ggsave("energy.png")
ggplot(finalStats,aes(x=simkey,y=success,fill=wireless))+
geom_bar(stat="identity",position=position_dodge())+
xlab("Scenarios")+ylab("Energy (J)")+
geom_errorbar(position=position_dodge(0.9),aes(ymin=success-sd, ymax=success+sd),width=0.5,size=1.5,) +
geom_text(aes(label = round(success+sd,digits=1), y= success+sd),vjust=-0.4,position=position_dodge(0.9))+
geom_text(aes(label = round(success-sd,digits=1), y= success-sd),vjust=+1.5,position=position_dodge(0.9))+
geom_text(aes(label = round(success,digits=1), y= success/2),fontface="bold",colour="white",position=position_dodge(0.9))+
facet_wrap(~ wakeupfor) +
ggsave("success.png")
tf="tables-energy.org"
write("",file=tf)
for(wake in unique(data$wakeupfor)){
write(kable(finalEnergy%>%filter(wireless=="lora",wakeupfor==wake)),file=tf,append=TRUE)
write("\n",file=tf,append=TRUE)
write(kable(finalEnergy%>%filter(wireless=="nbiot",wakeupfor==wake)),file=tf,append=TRUE)
write("\n",file=tf,append=TRUE)
}
tf="tables-stats.org"
write("",file=tf)
for(wake in unique(data$wakeupfor)){
write(kable(finalStats%>%filter(wireless=="lora",wakeupfor==wake)),file=tf,append=TRUE)
write("\n",file=tf,append=TRUE)
write(kable(finalStats%>%filter(wireless=="nbiot",wakeupfor==wake)),file=tf,append=TRUE)
write("\n",file=tf,append=TRUE)
}