mirror of
https://gitlab.com/manzerbredes/loosely-coupled-dss-extended.git
synced 2025-04-06 11:36:26 +02:00
73 lines
3.6 KiB
R
73 lines
3.6 KiB
R
library("tidyverse")
|
|
library("knitr")
|
|
|
|
data=read_csv("results.csv")
|
|
|
|
r_=function(x){round(x,digits=2)}
|
|
|
|
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))%>%
|
|
# ungroup()%>%group_by(simkey,wireless,wakeupfor)%>%
|
|
# summarise(sd_success=sd(success),success=mean(success))
|
|
|
|
# Success
|
|
finalStats=data%>%filter(isSender!=0)%>%group_by(simkey,wireless,wakeupfor)%>%summarise(sd_success=sd(nSend),success=mean(nSend))
|
|
|
|
# Sender energy
|
|
senderEnergy=data%>%filter(isSender!=0)%>%group_by(simkey,wireless,wakeupfor)%>%summarise(senderEnergy=mean(energy))
|
|
receiverEnergy=data%>%filter(isSender==0)%>%group_by(simkey,wireless,wakeupfor)%>%summarise(receiverEnergy=mean(energy))
|
|
finalStats=finalStats%>%left_join(senderEnergy,by=c("simkey","wireless","wakeupfor"))
|
|
finalStats=finalStats%>%left_join(receiverEnergy,by=c("simkey","wireless","wakeupfor"))
|
|
|
|
# Uptime
|
|
senderUptime=data%>%filter(isSender!=0)%>%group_by(simkey,wireless,wakeupfor)%>%summarise(senderUptime=mean(totalUptime))
|
|
receiverUptime=data%>%filter(isSender==0)%>%group_by(simkey,wireless,wakeupfor)%>%summarise(receiverUptime=mean(totalUptime))
|
|
finalStats=finalStats%>%left_join(senderUptime,by=c("simkey","wireless","wakeupfor"))
|
|
finalStats=finalStats%>%left_join(receiverUptime,by=c("simkey","wireless","wakeupfor"))
|
|
|
|
|
|
# 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 = r_(energy+sd), y= energy+sd),vjust=-0.4,position=position_dodge(0.9))+
|
|
geom_text(aes(label = r_(energy-sd), y= energy-sd),vjust=+1.5,position=position_dodge(0.9))+
|
|
geom_text(aes(label = r_(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_success, ymax=success+sd_success),width=0.5,size=1.5,) +
|
|
geom_text(aes(label = r_(success+sd_success), y= success+sd_success),vjust=-0.4,position=position_dodge(0.9))+
|
|
geom_text(aes(label = r_(success-sd_success), y= success-sd_success),vjust=+1.5,position=position_dodge(0.9))+
|
|
geom_text(aes(label = r_(success), 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)
|
|
}
|
|
|