loosely-coupled-dss-extended/results/analysis_datasize.R

69 lines
3.5 KiB
R
Raw Normal View History

2024-06-29 14:27:13 +02:00
library("tidyverse")
library("gridExtra")
library("patchwork")
library("knitr")
library(RColorBrewer)
library(latex2exp)
r_=function(x){round(x,digits=2)}
color=function(){scale_fill_brewer(palette = "Accent")}
color2=function(){scale_fill_brewer(palette = "Set2")}
nolegend=function(){theme(legend.position="none")}
simkeys=unique(read_csv("results.csv")$simkey)
nsimkeys=length(simkeys)
s_=function(x){if(x<0){return("")}else{return("+")}}
simkey_rename=function(key){
if(key=="hint")
return("Hints")
if(key=="baseline")
return("Baseline")
if(key=="extended")
return("Extended")
if(key=="hintandextended")
return("Hints+\nExtended")
return(key)
}
dformat=function(data){
data%>%rowwise()%>%mutate(simkey=simkey_rename(simkey))%>%
mutate(wireless=ifelse(wireless=="lora","LoRa","Nb-IoT"))%>%mutate(facet=paste0("With ",wakeupfor,"s uptime using ",wireless))
}
data=read_csv("results_datasize.csv")
data=data%>%filter(isSender!=0)%>%group_by(wakeupfor,simkey,datasize,wireless)%>%summarize(success_mean=mean(nSend),success_sd=sd(nSend))
data=data%>%mutate(datasize=ifelse(datasize==1000,"1KB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==10000,"10KB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==100000,"100KB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==500000,"500KB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==1000000,"1MB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==2000000,"2MB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==10000000,"10MB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==50000000,"50MB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==100000000,"100MB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==500000000,"500MB",as.character(datasize)))
data=data%>%mutate(datasize=ifelse(datasize==1000000000,"1GB",as.character(datasize)))
data$datasize=factor(data$datasize,levels=c("1KB","10KB","100KB","500KB","1MB","2MB","10MB","50MB","100MB","500MB","1GB"))
data=data%>%dformat()
data$facet=factor(data$facet,levels=c("With 60s uptime using LoRa","With 60s uptime using Nb-IoT","With 180s uptime using LoRa","With 180s uptime using Nb-IoT"))
#ggplot(data,aes(x=datasize,y=success, color=simkey))+geom_point()
ggplot(data,aes(x=datasize,y=success_mean,color=simkey,group=simkey))+
geom_point()+geom_line()+facet_wrap(~facet)+
xlab("Data size")+ylab(TeX(r'(#Succ$_p$)'))+scale_fill_brewer(palette = "Set1")+scale_color_brewer(palette = "Set1")+
labs(color="Policy:")+labs(fill="Standard deviation:")+
geom_ribbon(aes(ymin=success_mean-success_sd, ymax=success_mean+success_sd,fill=simkey),linetype=0,alpha=0.2)+
guides(color=guide_legend(override.aes=list(fill=NA)))+theme_bw()+ theme(legend.position="top")
ggsave("datasize.pdf",width=12,height=6)
ggplot(data%>%filter(wakeupfor==180,wireless=="LoRa"),aes(x=datasize,y=success_mean,color=simkey,group=simkey))+
geom_point()+geom_line()+facet_wrap(~facet)+
xlab("Data size")+ylab(TeX(r'(#Succ$_p$)'))+scale_fill_brewer(palette = "Set1")+scale_color_brewer(palette = "Set1")+
labs(color="Policy:")+labs(fill="Standard deviation:")+
geom_ribbon(aes(ymin=success_mean-success_sd, ymax=success_mean+success_sd,fill=simkey),linetype=0,alpha=0.2)+
guides(color=guide_legend(override.aes=list(fill=NA)))+theme_bw()+ theme(legend.position="top")
ggsave("datasize_lora180.pdf",width=9.5,height=4)