mirror of
https://gitlab.com/manzerbredes/loosely-coupled-dss-extended.git
synced 2025-04-05 19:16:26 +02:00
Minor changes
This commit is contained in:
parent
5b818e9c18
commit
66a1d58b9e
1 changed files with 99 additions and 0 deletions
99
results/pareto.R
Normal file
99
results/pareto.R
Normal file
|
@ -0,0 +1,99 @@
|
|||
library("tidyverse")
|
||||
library("gridExtra")
|
||||
library("patchwork")
|
||||
library("knitr")
|
||||
library(RColorBrewer)
|
||||
|
||||
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+Extended")
|
||||
return(key)
|
||||
}
|
||||
dformat=function(data){
|
||||
data%>%rowwise()%>%mutate(simkey=simkey_rename(simkey))%>%mutate(wireless=ifelse(wireless=="lora","LoRa","NbIoT"))
|
||||
}
|
||||
|
||||
build_stats=function(file){
|
||||
data=read_csv(file)
|
||||
|
||||
energy=data%>%group_by(simkey,wireless,seed,isSender,wakeupfor)%>%summarise(sd=sd(energy),energy=mean(energy))%>%mutate(type=ifelse(isSender,"Sender","Receiver"))
|
||||
|
||||
# Only sender knows success:
|
||||
success=data%>%filter(isSender==1)%>%group_by(simkey,wireless,seed,wakeupfor)%>%summarise(success_orig=mean(nSend),success=mean(nSend))
|
||||
|
||||
return(energy%>%ungroup()%>%left_join(success))
|
||||
|
||||
|
||||
energy60=data%>%filter(wakeupfor==60)
|
||||
energy60Snd=energy60%>%filter(isSender==1)%>%group_by(simkey,wireless,seed)%>%summarise(sd=sd(energy),energy=mean(energy),type="Sender")
|
||||
energy60Rcv=energy60%>%filter(isSender==0)%>%group_by(simkey,wireless,seed)%>%summarise(sd=sd(energy),energy=mean(energy),type="Receiver")
|
||||
energy60=energy60Snd%>%ungroup()%>%rbind(energy60Rcv)
|
||||
|
||||
print(energy60)
|
||||
stopifnot(1)
|
||||
|
||||
success60Snd=data%>%filter(wakeupfor==60)%>%filter(isSender!=0)%>%group_by(simkey,wireless,seed)%>%summarise(success_orig=mean(nSend),success=mean(nSend),type="Sender")
|
||||
success60Rcv=data%>%filter(wakeupfor==60)%>%filter(isSender!=0)%>%group_by(simkey,wireless,seed)%>%summarise(success_orig=mean(nSend),success=mean(nSend),type="Receiver")
|
||||
success60=rbind(success60Snd,success60Rcv)
|
||||
|
||||
total60=energy60%>%left_join(success60,by=c("simkey","wireless","type"))
|
||||
|
||||
energy180=data%>%filter(wakeupfor==180)
|
||||
energy180Snd=energy180%>%filter(isSender==1)%>%group_by(simkey,wireless,seed)%>%summarise(sd=sd(energy),energy=mean(energy),type="Sender")
|
||||
energy180Rcv=energy180%>%filter(isSender==0)%>%group_by(simkey,wireless,seed)%>%summarise(sd=sd(energy),energy=mean(energy),type="Receiver")
|
||||
energy180=energy180Snd%>%ungroup()%>%rbind(energy180Rcv)
|
||||
|
||||
success180Snd=data%>%filter(wakeupfor==180)%>%filter(isSender!=0)%>%group_by(simkey,wireless,seed)%>%summarise(success_orig=mean(nSend),success=mean(nSend),type="Sender")
|
||||
success180Rcv=data%>%filter(wakeupfor==180)%>%filter(isSender!=0)%>%group_by(simkey,wireless,seed)%>%summarise(success_orig=mean(nSend),success=mean(nSend),type="Receiver")
|
||||
success180=rbind(success180Snd,success180Rcv)
|
||||
|
||||
total180=energy180%>%left_join(success180,by=c("simkey","wireless","type"))
|
||||
|
||||
return(rbind(total60%>%mutate(wakeupfor=60),total180%>%mutate(wakeupfor=180)))
|
||||
}
|
||||
|
||||
# Load stats
|
||||
#stats_sor=build_stats("logs/sor_results/results.csv")%>%filter(type=="Sender")%>%mutate(strategy="sor")
|
||||
#stats_uor=build_stats("logs/uor_results/results.csv")%>%filter(type=="Sender")%>%mutate(strategy="uor")
|
||||
#stats_fh=build_stats("logs/farhint_results/results.csv")%>%filter(type=="Sender")%>%mutate(strategy="farhint")
|
||||
#stats=rbind(stats_sor,stats_uor,stats_fh)
|
||||
|
||||
|
||||
if(FALSE){
|
||||
pareto=tibble()
|
||||
stats%>%ungroup()%>%group_by(wakeupfor,wireless)%>%group_walk(function(data, t){
|
||||
for(i in 1:NROW(data)){
|
||||
pt=data[i,]
|
||||
e=pt$energy
|
||||
s=pt$success
|
||||
|
||||
domE=data$energy<e
|
||||
domS=data$success>s
|
||||
|
||||
if(!any(domE & domS)){
|
||||
pareto<<-rbind(pareto,cbind(pt,t))
|
||||
}
|
||||
}})
|
||||
#colnames(pareto) <- c("energy","success","type")
|
||||
pareto = pareto %>% mutate(energy = as.numeric(energy))
|
||||
pareto = pareto %>% mutate(success = as.numeric(success))
|
||||
pareto = pareto %>% arrange(energy,success)
|
||||
}
|
||||
ggplot(stats,aes(energy,success,color=simkey,shape=strategy))+
|
||||
geom_line(data=pareto,aes(energy,success),linetype="dashed", size=1,inherit.aes=FALSE)+
|
||||
geom_point(alpha=0.1,size=4)+
|
||||
geom_point(data=pareto,size=4)+scale_y_reverse()+
|
||||
facet_wrap(~wakeupfor+wireless,scale="free")+xlab("Sender energy consumption (J)")+ylab("#Delivery success")
|
Loading…
Add table
Reference in a new issue