Improve scenarios and analysis

This commit is contained in:
Loic Guegan 2021-05-10 10:33:11 +02:00
parent 51d0c256a3
commit bf8117d3aa
7 changed files with 2033 additions and 475 deletions

View file

@ -1,10 +1,17 @@
library("tidyverse") library("tidyverse")
library("knitr")
data=read_csv("results.csv") data=read_csv("results.csv")
final=data%>%group_by(simkey)%>%summarize(energy=mean(energy),sd=sd(energy)) final=data%>%group_by(simkey,wireless,wakeupfor)%>%summarize(energy=mean(energy),wireless=first(wireless),sd=sd(energy),wakeupfor=first(wakeupfor))
ggplot(final,aes(x=simkey,y=energy))+geom_bar(stat="identity")+ ggplot(final,aes(x=simkey,y=energy))+
xlab("Scenario")+ylab("Energy (J)")+ geom_bar(stat="identity",aes(fill=wireless),position=position_dodge())+
geom_errorbar(aes(ymin=energy-sd, ymax=energy+sd),width=.2,size=1.5) xlab("Scenarios")+ylab("Energy (J)")+
geom_errorbar(aes(ymin=energy-sd, ymax=energy+sd),width=.2,size=1.5) +
facet_wrap(~ wakeupfor)
for(wake in unique(data$wakeupfor)){
print(kable(final%>%filter(wireless=="lora",wakeupfor==wake)))
print(kable(final%>%filter(wireless!="lora",wakeupfor==wake)))
}

View file

@ -8,68 +8,102 @@ inputs="${wai}/../inputs.json"
simulator="make -C ${wai}/../ run" simulator="make -C ${wai}/../ run"
parser="${wai}/../parser.awk" parser="${wai}/../parser.awk"
results="${wai}/results.csv" results="${wai}/results.csv"
nseed=20 aheaders="simkey,wireless,wakeupfor"
avalues="none,none,none"
run-simulation () { run-simulation () {
# Generate inputs # Generate inputs
$scenarios $seed $simtime $wakeupsd $wakeupevery $wakeupfor $n_nodes $extended $hint $poff $pon $prx $ptx $datasize $simkey > "$inputs" $scenarios $seed $simtime $wakeupevery $wakeupfor $n_nodes $extended $hint $poff $pon $prx $ptx $datasize $bitrate > "$inputs"
# Run simulations # Run simulations
[ -e "$results" ] && { $simulator 2>&1 | $parser | sed 1d >> "$results"; } || { $simulator 2>&1 | $parser > "$results"; } if [ -e "$results" ]
then
$simulator 2>&1 | $parser | sed 1d | sed "s/$/,${avalues}/" >> "$results"
else
$simulator 2>&1 | $parser | sed "1 s/$/,${aheaders}/g" | sed "2,\$s/$/,${avalues}/" > "$results"
fi
} }
# Default Parameters # Default Parameters
seed=0 seed=0
simtime=7200 simtime=86400 # One day
wakeupsd=180 wakeupevery=3600
wakeupevery=600
wakeupfor=180 wakeupfor=180
n_nodes=5 n_nodes=12
extended="false" extended="false"
hint="false" hint="false"
poff=0 poff=0
pon=0.4 pon=0.4
prx=0.16 prx=0.16
ptx=0.16 ptx=0.16
datasize=1000000 datasize=1000000 # MB
simkey=0 bitrate="100kbps"
# Baseline run-scenarios() {
echo "Baseline..." # Configure number of seed per scenarios
nseed=10
# Baseline
echo "Baseline..."
avalues="baseline,$wireless,$wakeupfor"
for seed in $(seq 1 $nseed)
do
run-simulation
done
# Hint
echo "Hint..."
hint="true"
avalues="hint,$wireless,$wakeupfor"
for seed in $(seq 1 $nseed)
do
run-simulation
done
hint="false"
# Extended
echo "Extended..."
extended="true"
avalues="extended,$wireless,$wakeupfor"
for seed in $(seq 1 $nseed)
do
run-simulation
done
extended="false"
# Hint+Extended
echo "Hint + Extended..."
extended="true"
hint="true"
avalues="hintandextended,$wireless,$wakeupfor"
for seed in $(seq 1 $nseed)
do
run-simulation
done
extended="false"
hint="false"
}
# Clean previous runs
[ -e "${results}" ] && rm "${results}" [ -e "${results}" ] && rm "${results}"
simkey="baseline"
for seed in $(seq 1 $nseed)
do
run-simulation
done
# Hint for wakeupfor in 60 180
echo "Hint..."
hint="true"
simkey="hint"
for seed in $(seq 1 $nseed)
do do
run-simulation
done
hint="false"
# Extended # Lora
echo "Extended..." echo "----- Run Lora ($wakeupfor) -----"
extended="true" wireless="lora"
simkey="extended" bitrate="50kbps"
for seed in $(seq 1 $nseed) pon=0.4
do prx=0.16
run-simulation ptx=0.16
done run-scenarios
extended="false"
# Hint+Extended # NbIot
echo "Hint + Extended..." echo "----- Run NbIoT ($wakeupfor) -----"
extended="true" wireless="nbiot"
hint="true" bitrate="200kbps"
simkey="hintandextended" pon=0.4
for seed in $(seq 1 $nseed) prx=0.65
do ptx=0.65
run-simulation run-scenarios
done done
extended="false"
hint="false"

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,6 @@ 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(); seed=d["seed"].GetInt();
n_nodes=d["nodes"].MemberCount(); n_nodes=d["nodes"].MemberCount();
@ -156,7 +155,7 @@ void Inputs::GeneratePlatform(std::string p){
pf << "<?xml version='1.0'?>\n"; pf << "<?xml version='1.0'?>\n";
pf << "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"; pf << "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n";
pf << "<platform version=\"4.1\">\n <AS id=\"AS0\" routing=\"Cluster\">\n"; pf << "<platform version=\"4.1\">\n <AS id=\"AS0\" routing=\"Cluster\">\n";
pf << " <link id=\"link\" bandwidth=\"1Mbps\" latency=\"0ms\" sharing_policy=\"SHARED\"></link>\n"; pf << " <link id=\"link\" bandwidth=\""<<d["bitrate"].GetString()<<"\" latency=\"0ms\" sharing_policy=\"SHARED\"></link>\n";
for (Value::ConstMemberIterator itr = d["nodes"].MemberBegin(); itr != d["nodes"].MemberEnd(); ++itr) for (Value::ConstMemberIterator itr = d["nodes"].MemberBegin(); itr != d["nodes"].MemberEnd(); ++itr)
{ {
std::string name=itr->name.GetString(); std::string name=itr->name.GetString();

View file

@ -79,6 +79,4 @@ public:
int data_size; int data_size;
int seed; int seed;
int n_nodes; int n_nodes;
std::string simkey;
}; };

View file

@ -17,10 +17,10 @@ using namespace rapidjson;
int main(int argc, char **argv){ int main(int argc, char **argv){
// Setup seed // Setup seed
if(argc!=15){ if(argc!=14){
cerr << "Usage: " << argv[0] << cerr << "Usage: " << argv[0] <<
" <seed> <simtime> <wakeupsd> <wakeupevery> <wakeupfor> <n_nodes>" << " <seed> <simtime> <wakeupevery> <wakeupfor> <n_nodes>" <<
" <extended> <hint> <poff> <pon> <prx> <ptx> <datasize> <simkey>" << " <extended> <hint> <poff> <pon> <prx> <ptx> <datasize> <bitrate>" <<
endl; endl;
exit(1); exit(1);
} }
@ -28,18 +28,18 @@ int main(int argc, char **argv){
// Init parameters // Init parameters
int seed=atoi(argv[1]); int seed=atoi(argv[1]);
double simtime=stod(argv[2]); double simtime=stod(argv[2]);
unsigned int wakeupsd=atoi(argv[3]); unsigned int wakeupevery=atoi(argv[3]);
unsigned int wakeupevery=atoi(argv[4]); double wakeupfor=stod(argv[4]);
double wakeupfor=stod(argv[5]); unsigned int n_nodes=atoi(argv[5]);
unsigned int n_nodes=atoi(argv[6]); bool extended=!strcmp("true",argv[6]);
bool extended=!strcmp("true",argv[7]); bool hint=!strcmp("true",argv[7]);
bool hint=!strcmp("true",argv[8]); double poff=stod(argv[8]);
double poff=stod(argv[9]); double pon=stod(argv[9]);
double pon=stod(argv[10]); double prx=stod(argv[10]);
double prx=stod(argv[11]); double ptx=stod(argv[11]);
double ptx=stod(argv[12]); unsigned int datasize=atoi(argv[12]);
unsigned int datasize=atoi(argv[13]); string bitrate(argv[13]);
string simkey(argv[14]);
// Setup seed // Setup seed
srand(seed); srand(seed);
@ -47,10 +47,10 @@ int main(int argc, char **argv){
// Create document // Create document
Document d; Document d;
d.SetObject(); d.SetObject();
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("seed",Value().SetInt(seed),d.GetAllocator());
Value simkeyValue;
simkeyValue.SetString(bitrate.c_str(),bitrate.size(),d.GetAllocator());
d.AddMember("bitrate",simkeyValue,d.GetAllocator());
d.AddMember("extended",extended,d.GetAllocator()); d.AddMember("extended",extended,d.GetAllocator());
// Create nodes // Create nodes
@ -69,8 +69,8 @@ int main(int argc, char **argv){
// Setup ts and durations // Setup ts and durations
Value ts(kArrayType); Value ts(kArrayType);
Value duration(kArrayType); Value duration(kArrayType);
for(unsigned int i=0;(i+wakeupfor)<simtime;i+=RAND(wakeupevery-wakeupsd,wakeupevery+wakeupsd)){ for(unsigned int i=0;i<simtime;i+=wakeupevery){
ts.PushBack(Value().SetDouble(i),d.GetAllocator()); ts.PushBack(Value().SetDouble(RAND(i,i+wakeupevery)),d.GetAllocator());
duration.PushBack(Value().SetDouble(wakeupfor),d.GetAllocator()); duration.PushBack(Value().SetDouble(wakeupfor),d.GetAllocator());
} }
node.AddMember("wake_ts",ts,d.GetAllocator()); node.AddMember("wake_ts",ts,d.GetAllocator());

View file

@ -183,5 +183,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|nSend:%d|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d|simkey:%s|seed:%d)",selfName.c_str(),selfName.c_str(),nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,i.simkey.c_str(),i.seed); XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nSend:%d|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d|seed:%d)",selfName.c_str(),selfName.c_str(),nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,i.seed);
} }