#! /bin/bash

#########################################################################################
# Author: Shuai Li
# Date: 2013-12-24
# Description: 
#   WCDOPS+ vs WCDOPS+_NIMP simulation
#########################################################################################

. ./config.bash

file_name="nim_prob_and_cpu_variation_resim.csv"

for ((nim_prob = $MIN_NIM_PROB ; nim_prob <= $MAX_NIM_PROB ; nim_prob += $NIM_PROB_STEP)) do
  for ((cpu_utilization = $MIN_CPU ; cpu_utilization <= $MAX_CPU ; cpu_utilization += $CPU_STEP)) do
    touch $file_name
    for ((i=0; i<5; i=i+1)) do
      retry=0
      ./wcdops_plus_nimp_sim -t 10 -g 10 -c 0.$cpu_utilization -n 0.$nim_prob -p 0.25 -o $file_name -v
      
      while [ $? -ne 0 ] && [ $retry -lt 10 ] ; do
        (( retry++ ))
        ./wcdops_plus_nimp_sim -t 10 -g 10 -c 0.$cpu_utilization -n 0.$nim_prob -p 0.25 -o $file_name -v
      done
    done
  done
done

exit;

file_name="prio_prob_and_cpu_variation_resim.csv"

for ((prio_prob = $MIN_PRIO_PROB ; prio_prob <= $MAX_PRIO_PROB ; prio_prob += $PRIO_PROB_STEP)) do
  for ((cpu_utilization = $MIN_CPU ; cpu_utilization <= $MAX_CPU ; cpu_utilization += $CPU_STEP)) do
    touch $file_name
    for ((i=0; i<5; i=i+1)) do
      retry=0
      ./wcdops_plus_nimp_sim -t 10 -g 10 -c 0.$cpu_utilization -n 0.25 -p 0.$prio_prob -o $file_name -v
      
      while [ $? -ne 0 ] && [ $retry -lt 10 ] ; do
        (( retry++ ))
        ./wcdops_plus_nimp_sim -t 10 -g 10 -c 0.$cpu_utilization -n 0.25 -p 0.$prio_prob -o $file_name -v
      done
    done
  done
done
