[simulation] minor fix for plots
This commit is contained in:
parent
12139d07c4
commit
9596ce932b
@ -3,15 +3,15 @@
|
|||||||
REPOSITORY=$(pwd)
|
REPOSITORY=$(pwd)
|
||||||
CONTIKI=/home/giomba/workspace/uni/contiki/
|
CONTIKI=/home/giomba/workspace/uni/contiki/
|
||||||
SIMULATION=/home/giomba/workspace/uni/anaws-proj/cooja/simulation-prng.csc
|
SIMULATION=/home/giomba/workspace/uni/anaws-proj/cooja/simulation-prng.csc
|
||||||
REPEAT=10
|
REPEAT=20
|
||||||
|
|
||||||
# Setup environment
|
# Setup environment
|
||||||
mkdir -p "$REPOSITORY/simulation/results"
|
mkdir -p "$REPOSITORY/simulation/results"
|
||||||
|
|
||||||
# Setup simulation parameters
|
# Setup simulation parameters
|
||||||
for KAPPA in 10 7 5 3 2 1; do
|
for KAPPA in 5; do
|
||||||
for I_MIN in 12 14 16 18; do
|
for I_MIN in 20 18 16; do
|
||||||
I_MAX=$((20 - I_MIN)) # 20 =~ 17 minutes
|
I_MAX=$((22 - I_MIN)) # 22 =~ 70 minutes
|
||||||
|
|
||||||
for PROJECTCONF in "$REPOSITORY/oracle/project-conf.h" "$CONTIKI/examples/ipv6/rpl-border-router/project-conf.h"; do
|
for PROJECTCONF in "$REPOSITORY/oracle/project-conf.h" "$CONTIKI/examples/ipv6/rpl-border-router/project-conf.h"; do
|
||||||
sed -i "s/^\#define RPL_CONF_DIO_REDUNDANCY *[0-9]*$/\#define RPL_CONF_DIO_REDUNDANCY $KAPPA/g" "$PROJECTCONF"
|
sed -i "s/^\#define RPL_CONF_DIO_REDUNDANCY *[0-9]*$/\#define RPL_CONF_DIO_REDUNDANCY $KAPPA/g" "$PROJECTCONF"
|
||||||
|
@ -4,7 +4,7 @@ import numpy as numpy
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
def getcolor(n):
|
def getcolor(n):
|
||||||
return ['#aa0000', '#00aa00', '#0000aa', '#aaaa00'][int((i - 12) / 2)]
|
return ['#aa0000', '#00aa00', '#0000aa', '#aaaa00', '#aa00aa'][int((i - 12) / 2)]
|
||||||
|
|
||||||
df = pd.read_csv('pretty.csv', delimiter='\s', engine='python')
|
df = pd.read_csv('pretty.csv', delimiter='\s', engine='python')
|
||||||
|
|
||||||
|
@ -29,11 +29,12 @@ for filename in os.listdir(RESULTSDIR):
|
|||||||
|
|
||||||
kappa = int(df['KAPPA'].to_string().split()[1])
|
kappa = int(df['KAPPA'].to_string().split()[1])
|
||||||
i_min = int(df['I_MIN'].to_string().split()[1])
|
i_min = int(df['I_MIN'].to_string().split()[1])
|
||||||
i_max = int(df['I_MAX'].to_string().split()[1])
|
key = str(kappa) + ':' + str(i_min)
|
||||||
key = str(kappa) + ':' + str(i_min) + ':' + str(i_max)
|
|
||||||
|
|
||||||
if (not key in all_route_discovery):
|
if (not key in all_route_discovery):
|
||||||
all_route_discovery[key] = { 'samples': [], 'k': kappa, 'i_min': i_min }
|
all_route_discovery[key] = { 'samples': [], 'k': kappa, 'i_min': i_min, 'count': 0 }
|
||||||
|
|
||||||
|
all_route_discovery[key]['count'] += 1
|
||||||
|
|
||||||
with open(RESULTSDIR + '/' + filename) as file:
|
with open(RESULTSDIR + '/' + filename) as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
@ -45,94 +46,18 @@ for filename in os.listdir(RESULTSDIR):
|
|||||||
# now, for every k, i_min, i_max
|
# now, for every k, i_min, i_max
|
||||||
# all_route_discovery contains an array with all samples of the measured value
|
# all_route_discovery contains an array with all samples of the measured value
|
||||||
|
|
||||||
print('k i_min mean ci')
|
print('k i_min count mean ci')
|
||||||
for simulation in all_route_discovery:
|
for simulation in all_route_discovery:
|
||||||
all_route_discovery[simulation]['mean'] = np.mean(all_route_discovery[simulation]['samples'])
|
all_route_discovery[simulation]['mean'] = np.mean(all_route_discovery[simulation]['samples'])
|
||||||
all_route_discovery[simulation]['ci'] = compute_confidence_interval(all_route_discovery[simulation]['samples'])
|
all_route_discovery[simulation]['ci'] = compute_confidence_interval(all_route_discovery[simulation]['samples'])
|
||||||
|
|
||||||
print(
|
print(
|
||||||
#simulation,
|
|
||||||
all_route_discovery[simulation]['k'],
|
all_route_discovery[simulation]['k'],
|
||||||
all_route_discovery[simulation]['i_min'],
|
all_route_discovery[simulation]['i_min'],
|
||||||
|
all_route_discovery[simulation]['count'],
|
||||||
all_route_discovery[simulation]['mean'],
|
all_route_discovery[simulation]['mean'],
|
||||||
all_route_discovery[simulation]['ci']
|
all_route_discovery[simulation]['ci']
|
||||||
)
|
)
|
||||||
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
'''
|
|
||||||
d = []
|
|
||||||
f = []
|
|
||||||
|
|
||||||
# compute fd in our interval of interest
|
|
||||||
d = np.arange(0, (M * 2**0.5 / 2))
|
|
||||||
for i in d:
|
|
||||||
f.append(fd(i))
|
|
||||||
|
|
||||||
# compute integral of fd
|
|
||||||
integral = []
|
|
||||||
last = 0
|
|
||||||
for i in range(0, len(f)):
|
|
||||||
part = f[i]
|
|
||||||
last = last + part
|
|
||||||
integral.append(last)
|
|
||||||
|
|
||||||
print("normalization fd: ", np.trapz(f))
|
|
||||||
|
|
||||||
# make plots
|
|
||||||
fig, ax1 = plt.subplots()
|
|
||||||
|
|
||||||
color = 'tab:red'
|
|
||||||
ax1.set_xlabel('d [m]')
|
|
||||||
ax1.set_ylabel('fD(d)')
|
|
||||||
ax1.plot(d, f, 'c,', label='fD')
|
|
||||||
|
|
||||||
ax2 = ax1.twinx()
|
|
||||||
|
|
||||||
color = 'tab:blue'
|
|
||||||
ax2.set_ylabel('FD(d)')
|
|
||||||
ax2.plot(d, integral, 'b,', label="FD")
|
|
||||||
|
|
||||||
plt.legend()
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
def fs(s):
|
|
||||||
if s >= 0 and s <= (T * M**2 ) / 4:
|
|
||||||
return np.pi / ( T * M**2 )
|
|
||||||
elif s >= (T * M**2 ) / 4 and s <= (T * M**2) / 2:
|
|
||||||
return (np.pi / (T * M**2)) - (4 / (T * M**2)) * np.arccos(M/2 * ((T / s)**0.5))
|
|
||||||
else:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
### Distribution of Service Time
|
|
||||||
s = T * d**2
|
|
||||||
f = []
|
|
||||||
for i in s:
|
|
||||||
f.append(fs(i))
|
|
||||||
|
|
||||||
print("normalization fs: ", np.trapz(f, s))
|
|
||||||
|
|
||||||
# compute integral of fs
|
|
||||||
integral = [ 0 ]
|
|
||||||
last = 0
|
|
||||||
for i in range(1, len(f)):
|
|
||||||
part = f[i] * (s[i] - s[i - 1])
|
|
||||||
last = last + part
|
|
||||||
integral.append(last)
|
|
||||||
|
|
||||||
# make plots
|
|
||||||
fig, ax1 = plt.subplots()
|
|
||||||
color = 'tab:red'
|
|
||||||
ax1.set_xlabel('s [s]')
|
|
||||||
ax1.set_ylabel('fS(s)')
|
|
||||||
ax1.plot(s, f, 'c,', label='fS')
|
|
||||||
|
|
||||||
ax2 = ax1.twinx()
|
|
||||||
|
|
||||||
color = 'tab:blue'
|
|
||||||
ax2.set_ylabel('FD(d)')
|
|
||||||
ax2.plot(s, integral, 'b,', label='FS')
|
|
||||||
|
|
||||||
plt.legend()
|
|
||||||
plt.show()
|
|
||||||
'''
|
|
Loading…
Reference in New Issue
Block a user