mirror of
https://gitlab.com/manzerbredes/loosely-coupled-dss.git
synced 2025-04-06 11:36:25 +02:00
Setup experimentations
This commit is contained in:
parent
8b7b9c9e0a
commit
f9ce6e80c6
8 changed files with 171 additions and 33 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ libs/rapidjson
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
platform.xml
|
platform.xml
|
||||||
scenarios
|
scenarios
|
||||||
|
inputs.json
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
{"extended":false,"nodes":{"on0":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":true,"data_size":50,"wake_ts":[8.0,18.0,28.0,38.0,48.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0]},"on1":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[5.0,15.0,25.0,35.0,45.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0]},"on2":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on3":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[1.0,11.0,21.0,31.0,41.0,51.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on4":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[2.0,12.0,22.0,32.0,42.0,52.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on5":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[4.0,14.0,24.0,34.0,44.0,54.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on6":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on7":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on8":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[3.0,13.0,23.0,33.0,43.0,53.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on9":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[4.0,14.0,24.0,34.0,44.0,54.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]}}}
|
|
75
results/paper.sh
Executable file
75
results/paper.sh
Executable file
|
@ -0,0 +1,75 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
wai=$(dirname $(readlink -f "$0"))
|
||||||
|
scenarios="${wai}/../scenarios"
|
||||||
|
inputs="${wai}/../inputs.json"
|
||||||
|
simulator="make -C ${wai}/../ run"
|
||||||
|
parser="${wai}/../parser.awk"
|
||||||
|
results="${wai}/results.csv"
|
||||||
|
nseed=10
|
||||||
|
|
||||||
|
run-simulation () {
|
||||||
|
# Generate inputs
|
||||||
|
$scenarios $seed $simtime $maxstartupdelay $wakeupevery $wakeupfor $n_nodes $extended $hint $poff $pon $prx $ptx $datasize $simkey > "$inputs"
|
||||||
|
# Run simulations
|
||||||
|
[ -e "$results" ] && { $simulator 2>&1 | $parser | sed 1d >> "$results"; } || { $simulator 2>&1 | $parser > "$results"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default Parameters
|
||||||
|
seed=0
|
||||||
|
simtime=100
|
||||||
|
maxstartupdelay=1
|
||||||
|
wakeupevery=10
|
||||||
|
wakeupfor=10
|
||||||
|
n_nodes=1
|
||||||
|
extended="false"
|
||||||
|
hint="false"
|
||||||
|
poff=0
|
||||||
|
pon=1
|
||||||
|
prx=1
|
||||||
|
ptx=5
|
||||||
|
datasize=1
|
||||||
|
simkey=0
|
||||||
|
|
||||||
|
# Baseline
|
||||||
|
echo "Baseline..."
|
||||||
|
[ -e "${results}" ] && rm "${results}"
|
||||||
|
simkey="baseline"
|
||||||
|
for seed in $(seq 1 $nseed)
|
||||||
|
do
|
||||||
|
run-simulation
|
||||||
|
done
|
||||||
|
|
||||||
|
# Hint
|
||||||
|
echo "Hint..."
|
||||||
|
hint="true"
|
||||||
|
simkey="hint"
|
||||||
|
for seed in $(seq 1 $nseed)
|
||||||
|
do
|
||||||
|
run-simulation
|
||||||
|
done
|
||||||
|
hint="false"
|
||||||
|
|
||||||
|
# Extended
|
||||||
|
echo "Extended..."
|
||||||
|
extended="true"
|
||||||
|
simkey="extended"
|
||||||
|
for seed in $(seq 1 $nseed)
|
||||||
|
do
|
||||||
|
run-simulation
|
||||||
|
done
|
||||||
|
extended="false"
|
||||||
|
|
||||||
|
# Hint+Extended
|
||||||
|
echo "Hint + Extended..."
|
||||||
|
extended="true"
|
||||||
|
hint="true"
|
||||||
|
simkey="hintandextended"
|
||||||
|
for seed in $(seq 1 $nseed)
|
||||||
|
do
|
||||||
|
run-simulation
|
||||||
|
done
|
||||||
|
extended="false"
|
||||||
|
hint="false"
|
41
results/results.csv
Normal file
41
results/results.csv
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
node,nWakeUp,nDataRcv,nSendFail,nRcvFail,simkey,seed,energy
|
||||||
|
on0,1,0,1,0,baseline,1,450.000000
|
||||||
|
on0,1,0,1,0,baseline,2,450.000000
|
||||||
|
on0,1,0,1,0,baseline,3,450.000000
|
||||||
|
on0,1,0,1,0,baseline,4,450.000000
|
||||||
|
on0,1,0,1,0,baseline,5,450.000000
|
||||||
|
on0,1,0,1,0,baseline,6,450.000000
|
||||||
|
on0,1,0,1,0,baseline,7,450.000000
|
||||||
|
on0,1,0,1,0,baseline,8,450.000000
|
||||||
|
on0,1,0,1,0,baseline,9,450.000000
|
||||||
|
on0,1,0,1,0,baseline,10,450.000000
|
||||||
|
on0,1,0,1,0,hint,1,450.000000
|
||||||
|
on0,1,0,1,0,hint,2,450.000000
|
||||||
|
on0,1,0,1,0,hint,3,450.000000
|
||||||
|
on0,1,0,1,0,hint,4,450.000000
|
||||||
|
on0,1,0,1,0,hint,5,450.000000
|
||||||
|
on0,1,0,1,0,hint,6,450.000000
|
||||||
|
on0,1,0,1,0,hint,7,450.000000
|
||||||
|
on0,1,0,1,0,hint,8,450.000000
|
||||||
|
on0,1,0,1,0,hint,9,450.000000
|
||||||
|
on0,1,0,1,0,hint,10,450.000000
|
||||||
|
on0,1,0,1,0,extended,1,90.000000
|
||||||
|
on0,1,0,1,0,extended,2,90.000000
|
||||||
|
on0,1,0,1,0,extended,3,90.000000
|
||||||
|
on0,1,0,1,0,extended,4,90.000000
|
||||||
|
on0,1,0,1,0,extended,5,90.000000
|
||||||
|
on0,1,0,1,0,extended,6,90.000000
|
||||||
|
on0,1,0,1,0,extended,7,90.000000
|
||||||
|
on0,1,0,1,0,extended,8,90.000000
|
||||||
|
on0,1,0,1,0,extended,9,90.000000
|
||||||
|
on0,1,0,1,0,extended,10,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,1,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,2,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,3,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,4,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,5,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,6,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,7,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,8,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,9,90.000000
|
||||||
|
on0,1,0,1,0,hintandextended,10,90.000000
|
|
|
@ -17,7 +17,9 @@ Inputs::Inputs(std::string node_name){
|
||||||
use_hint=d["nodes"][node_name.c_str()]["use_hint"].GetBool();
|
use_hint=d["nodes"][node_name.c_str()]["use_hint"].GetBool();
|
||||||
data_size=d["nodes"][node_name.c_str()]["data_size"].GetInt();
|
data_size=d["nodes"][node_name.c_str()]["data_size"].GetInt();
|
||||||
extended=d["extended"].GetBool();
|
extended=d["extended"].GetBool();
|
||||||
|
simkey=d["simkey"].GetString();
|
||||||
|
seed=d["seed"].GetInt();
|
||||||
|
|
||||||
// Instantiate wake_ts
|
// Instantiate wake_ts
|
||||||
for(auto& v:d["nodes"][node_name.c_str()]["wake_ts"].GetArray()){
|
for(auto& v:d["nodes"][node_name.c_str()]["wake_ts"].GetArray()){
|
||||||
wake_ts.push_back(v.GetDouble());
|
wake_ts.push_back(v.GetDouble());
|
||||||
|
@ -29,6 +31,10 @@ Inputs::Inputs(std::string node_name){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identity check
|
// Identity check
|
||||||
|
if(wake_ts.size()<1){
|
||||||
|
std::cerr << "Invalid node configuration: wake_ts.size() == 0" <<std::endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
if(wake_ts.size()!=wake_duration.size()){
|
if(wake_ts.size()!=wake_duration.size()){
|
||||||
std::cerr << "Invalid node configuration: wake_ts.size() != wake_duration.size()" <<std::endl;
|
std::cerr << "Invalid node configuration: wake_ts.size() != wake_duration.size()" <<std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -77,5 +77,7 @@ public:
|
||||||
bool use_hint;
|
bool use_hint;
|
||||||
bool extended;
|
bool extended;
|
||||||
int data_size;
|
int data_size;
|
||||||
|
int seed;
|
||||||
|
std::string simkey;
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,6 +1,8 @@
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <rapidjson/filewritestream.h>
|
#include <rapidjson/filewritestream.h>
|
||||||
#include <rapidjson/writer.h>
|
#include <rapidjson/prettywriter.h>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -8,56 +10,68 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
#define RAND(min,max) (rand()%(max-min)+min)
|
#define RAND(min,max) (rand()%(max-min+1)+min)
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
|
||||||
#define N_NODE 10
|
|
||||||
#define EXTENDED false
|
|
||||||
#define SIMULATION_DURATION 60
|
|
||||||
#define POWER_OFF 0
|
|
||||||
#define POWER_ON 10
|
|
||||||
#define POWER_RX 11
|
|
||||||
#define POWER_TX 12
|
|
||||||
#define DATA_SIZE 50
|
|
||||||
#define USE_HINT false
|
|
||||||
#define WAKE_UP_EVERY 10
|
|
||||||
#define WAKE_UP_FOR 5
|
|
||||||
#define MAX_STARTUP_DELAY 10
|
|
||||||
|
|
||||||
unsigned int seed = 0;
|
|
||||||
|
|
||||||
int main(int argc, char **argv){
|
int main(int argc, char **argv){
|
||||||
// Setup seed
|
// Setup seed
|
||||||
if(argc>1){
|
if(argc!=15){
|
||||||
srand( atoi(argv[1]) );
|
cerr << "Usage: " << argv[0] <<
|
||||||
|
" <seed> <simtime> <maxstartupdelay> <wakeupevery> <wakeupfor> <n_nodes>" <<
|
||||||
|
" <extended> <hint> <poff> <pon> <prx> <ptx> <datasize> <simkey>" <<
|
||||||
|
endl;
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init parameters
|
||||||
|
int seed=atoi(argv[1]);
|
||||||
|
double simtime=stod(argv[2]);
|
||||||
|
unsigned int maxstartupdelay=atoi(argv[3]);
|
||||||
|
double wakeupevery=stod(argv[4]);
|
||||||
|
double wakeupfor=stod(argv[5]);
|
||||||
|
unsigned int n_nodes=atoi(argv[6]);
|
||||||
|
bool extended=!strcmp("true",argv[7]);
|
||||||
|
bool hint=!strcmp("true",argv[8]);
|
||||||
|
double poff=stod(argv[9]);
|
||||||
|
double pon=stod(argv[10]);
|
||||||
|
double prx=stod(argv[11]);
|
||||||
|
double ptx=stod(argv[12]);
|
||||||
|
unsigned int datasize=atoi(argv[13]);
|
||||||
|
string simkey(argv[14]);
|
||||||
|
|
||||||
|
// Setup seed
|
||||||
|
srand(seed);
|
||||||
|
|
||||||
// Create document
|
// Create document
|
||||||
Document d;
|
Document d;
|
||||||
d.SetObject();
|
d.SetObject();
|
||||||
d.AddMember("extended",EXTENDED,d.GetAllocator());
|
Value simkeyValue;
|
||||||
|
simkeyValue.SetString(simkey.c_str(),simkey.size(),d.GetAllocator());
|
||||||
|
d.AddMember("simkey",simkeyValue,d.GetAllocator());
|
||||||
|
d.AddMember("seed",Value().SetInt(seed),d.GetAllocator());
|
||||||
|
d.AddMember("extended",extended,d.GetAllocator());
|
||||||
|
|
||||||
// Create nodes
|
// Create nodes
|
||||||
Value nodes(kObjectType);
|
Value nodes(kObjectType);
|
||||||
for(int i=0;i<N_NODE;i++){
|
for(int i=0;i<n_nodes;i++){
|
||||||
Value node(kObjectType);
|
Value node(kObjectType);
|
||||||
node.SetObject();
|
node.SetObject();
|
||||||
node.AddMember("use_hint",USE_HINT,d.GetAllocator());
|
node.AddMember("use_hint",hint,d.GetAllocator());
|
||||||
node.AddMember("power_off",POWER_OFF,d.GetAllocator());
|
node.AddMember("power_off",poff,d.GetAllocator());
|
||||||
node.AddMember("power_on",POWER_ON,d.GetAllocator());
|
node.AddMember("power_on",pon,d.GetAllocator());
|
||||||
node.AddMember("power_rx",POWER_RX,d.GetAllocator());
|
node.AddMember("power_rx",prx,d.GetAllocator());
|
||||||
node.AddMember("power_tx",POWER_TX,d.GetAllocator());
|
node.AddMember("power_tx",ptx,d.GetAllocator());
|
||||||
node.AddMember("is_sender",i==0,d.GetAllocator());
|
node.AddMember("is_sender",i==0,d.GetAllocator());
|
||||||
node.AddMember("data_size",DATA_SIZE,d.GetAllocator());
|
node.AddMember("data_size",datasize,d.GetAllocator());
|
||||||
|
|
||||||
// Setup ts and durations
|
// Setup ts and durations
|
||||||
Value ts(kArrayType);
|
Value ts(kArrayType);
|
||||||
Value duration(kArrayType);
|
Value duration(kArrayType);
|
||||||
for(unsigned int i=(RAND(0,MAX_STARTUP_DELAY));(i+WAKE_UP_FOR)<SIMULATION_DURATION;i+=WAKE_UP_EVERY){
|
for(unsigned int i=maxstartupdelay;(i+wakeupfor)<simtime;i+=wakeupevery){
|
||||||
ts.PushBack(Value().SetDouble(i),d.GetAllocator());
|
ts.PushBack(Value().SetDouble(i),d.GetAllocator());
|
||||||
duration.PushBack(Value().SetDouble(WAKE_UP_FOR),d.GetAllocator());
|
duration.PushBack(Value().SetDouble(wakeupfor),d.GetAllocator());
|
||||||
}
|
}
|
||||||
node.AddMember("wake_ts",ts,d.GetAllocator());
|
node.AddMember("wake_ts",ts,d.GetAllocator());
|
||||||
node.AddMember("wake_duration",duration,d.GetAllocator());
|
node.AddMember("wake_duration",duration,d.GetAllocator());
|
||||||
|
@ -74,7 +88,7 @@ int main(int argc, char **argv){
|
||||||
|
|
||||||
// Write to stdout
|
// Write to stdout
|
||||||
StringBuffer buffer;
|
StringBuffer buffer;
|
||||||
Writer<StringBuffer> writer(buffer);
|
PrettyWriter<StringBuffer> writer(buffer);
|
||||||
d.Accept(writer);
|
d.Accept(writer);
|
||||||
cout << buffer.GetString();
|
cout << buffer.GetString();
|
||||||
|
|
||||||
|
|
|
@ -174,5 +174,5 @@ static void obs_node(std::vector<std::string> args) {
|
||||||
}
|
}
|
||||||
// Done
|
// Done
|
||||||
MODE_OFF()
|
MODE_OFF()
|
||||||
XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d)",selfName.c_str(),selfName.c_str(),nWakeUp,nDataRcv,nSendFail,nRcvFail);
|
XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d|simkey:%s|seed:%d)",selfName.c_str(),selfName.c_str(),nWakeUp,nDataRcv,nSendFail,nRcvFail,i.simkey.c_str(),i.seed);
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue