summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--analysis/in-situ.R (renamed from analysis/days.R)15
-rw-r--r--analysis/offline.R (renamed from analysis/learning.R)0
-rw-r--r--simulations/.gitignore1
-rw-r--r--simulations/Makefile4
-rwxr-xr-xsimulations/libs/setup.sh6
6 files changed, 21 insertions, 12 deletions
diff --git a/README.md b/README.md
index 52a99f5..7e02742 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,13 @@
# loosely-policies-analytics
## Analysis folder
-- learning.R: contains two major functions:
+- offline.R: contains two major functions:
- build_models: To generate K-fold cross-validation results (note that hyper-parameters for decisions tree is fixed (no validation set))
- generate_inputs: generate the inputs for the simulations experiments + the decision tree plots
-- days.R: Implement the in-situ learning approach
+- in-situ.R: Implement the in-situ learning approach (Figure 4a 4b and 4c)
+ - For figure 4a and 4b we train the model with increasing amount of data from previous results as if we were using one policy per day (see section IV.A)
+ - For figure 4c, delta is generated by comparing using each policies in round-robin (one per days to perform the training)
+ to each previous paper results with single policy only (see paper section IV.A)
Todo: remove minbucket=1 (does not impact the results)
diff --git a/analysis/days.R b/analysis/in-situ.R
index 93d478e..2d57666 100644
--- a/analysis/days.R
+++ b/analysis/in-situ.R
@@ -27,6 +27,8 @@ library("latex2exp")
## energy [0,+inf)
## nDataRcv [0,+inf)
+## WARNING: Goto line 138 first and set the boolean to T (populate the R environment with accuracy results) afterwhich you can set it to FALSE (save time)
+
nseed=200
nwakeupfor=2
nwireless=2
@@ -75,7 +77,7 @@ generate_accuracy_for=function(ignore_hint=FALSE,seed_max=200,attempts_max=2,wrl
data_ml=data_ml%>%filter(simkey!="hint")
}
train_set=data_ml%>%filter(seed<=seed_max)%>%select(-seed) # train data on seed_max*3 days
- test_set=data_ml%>%select(-seed) # build test_sed
+ test_set=data_ml%>%select(-seed) # build test_set
#print(paste0("Test set ",NROW(test_set)))
#print(paste0("Train set ",NROW(train_set)))
## KNN training
@@ -86,7 +88,7 @@ generate_accuracy_for=function(ignore_hint=FALSE,seed_max=200,attempts_max=2,wrl
#print(knn_accuracy)
knn_prop_table=round(prop.table(knn_cont_table),digits=2)
knn_f1_score=F1_Score2(test_set$simkey,knn_predictions)
-
+
## Decision tree
tree=rpart(
simkey ~ wireless + wakeupfor + energy + coverage,
@@ -111,23 +113,24 @@ generate_accuracy_for=function(ignore_hint=FALSE,seed_max=200,attempts_max=2,wrl
}
+########## Train models from seed 0 to seed 160 (this code assumes that each day, a given policy is used)
generate_accuracy_energy = function(wireless,wakeupfor,steps=1, accuracy=10,ignore_hint=FALSE){
## Setup variables
npolicies=4
data_seed_for_energy=data_seed%>%ungroup()
if(ignore_hint){npolicies=npolicies-1;data_seed_for_energy=data_seed%>%filter(simkey!="hint")}
- data_seed_for_energy=data_seed_for_energy%>%filter(wireless==!!wireless,wakeupfor==!!wakeupfor)
+ data_seed_for_energy=data_seed_for_energy%>%filter(wireless==!!wireless,wakeupfor==!!wakeupfor) # Note !! do unquote, here we select the proper scenario
## Generate inputs
result=tibble()
result_energy=tibble()
- for(i in seq(1,160,by=steps)){ # We stop at 80% of the data (this way test set is at least 20%)
+ for(i in seq(1,160,by=steps)){ # We stop at 80% of the data (this way test set is at least 20%) here 160 over 200 seeds
print(paste("Step",i))
acc=generate_accuracy_for(ignore_hint=ignore_hint,seed=i,attempts_max=accuracy,wrl=wireless,wuf=wakeupfor)
- result_energy=rbind(result_energy,data_seed_for_energy%>%filter(seed<=i)%>%summarize(energy=sum(energy),seed_max=i,days=i*npolicies,setup=paste0(!!wireless," ",!!wakeupfor,"s"),wireless=!!wireless,wakeupfor=!!wakeupfor))
+ result_energy=rbind(result_energy,data_seed_for_energy%>%filter(seed<=i)%>%summarize(energy=sum(energy),seed_max=i,days=i*npolicies,setup=paste0(!!wireless," ",!!wakeupfor,"s"),wireless=!!wireless,wakeupfor=!!wakeupfor)) # days=i*npolicies since 1 policy only per day is used (see paper section IV.A)
result=rbind(result,acc)
}
- list(accuracy=result%>%mutate(days=seed_max*npolicies), # Since 3 policies (since ignore_hint=TRUE)
+ list(accuracy=result%>%mutate(days=seed_max*npolicies), # Since 1 policy per days see L130
energy=result_energy)
}
diff --git a/analysis/learning.R b/analysis/offline.R
index da444d8..da444d8 100644
--- a/analysis/learning.R
+++ b/analysis/offline.R
diff --git a/simulations/.gitignore b/simulations/.gitignore
index a5fd42a..89d1606 100644
--- a/simulations/.gitignore
+++ b/simulations/.gitignore
@@ -1,6 +1,7 @@
simulator
libs/simgrid
libs/rapidjson
+libs/*.tar*
compile_commands.json
platform.xml
scenarios
diff --git a/simulations/Makefile b/simulations/Makefile
index 3ed792d..8702e66 100644
--- a/simulations/Makefile
+++ b/simulations/Makefile
@@ -7,7 +7,7 @@ CC := g++ $(addprefix -L , $(LIBS)) $(addprefix -I , $(INCLUDES))
all: $(EXEC) $(basename $(notdir $(SCENARIOS)))
$(EXEC): $(filter-out $(SCENARIOS), $(wildcard src/*))
- $(CC) -lsimgrid $^ -o $@
+ $(CC) $^ -lsimgrid -o $@
$(basename $(notdir $(SCENARIOS))): $(SCENARIOS)
$(CC) $^ -o $@
@@ -16,4 +16,4 @@ run: $(EXEC)
export LD_LIBRARY_PATH=$(addprefix :, $(LIBS)) && ./$(EXEC) 10 --cfg=network/bandwidth-factor:1.05 --cfg=network/model:CM02 -–cfg=network/crosstraffic:0
clean:
- -rm $(EXEC) $(basename $(notdir $(SCENARIOS))) \ No newline at end of file
+ -rm $(EXEC) $(basename $(notdir $(SCENARIOS)))
diff --git a/simulations/libs/setup.sh b/simulations/libs/setup.sh
index 395a11e..14705f6 100755
--- a/simulations/libs/setup.sh
+++ b/simulations/libs/setup.sh
@@ -2,8 +2,10 @@
set -e
-[ ! -e "simgrid" ] && git clone https://framagit.org/simgrid/simgrid
-[ ! -e "rapidjson"] && git clone https://github.com/Tencent/rapidjson
+[ ! -e "simgrid-v3.35.tar.bz2" ] && wget "https://framagit.org/simgrid/simgrid/-/archive/v3.35/simgrid-v3.35.tar.bz2?ref_type=tags" -O "simgrid-v3.35.tar.bz2"
+[ ! -e "simgrid" ] && tar -xf "simgrid-v3.35.tar.bz2" && mv "simgrid-v3.35" simgrid
+
+[ ! -e "rapidjson" ] && git clone --depth 1 https://github.com/Tencent/rapidjson
cd simgrid
mkdir -p build