Fix Link Traffic Levels observation encoding

This commit is contained in:
Marek Wolan
2023-06-02 13:15:38 +01:00
parent 2330a30021
commit 25ec0d93a9
3 changed files with 8 additions and 7 deletions

View File

@@ -281,7 +281,7 @@ class LinkTrafficLevels(AbstractObservationComponent):
traffic_level = self._quantisation_levels - 1
else:
traffic_level = (load / bandwidth) // (
1 / (self._quantisation_levels - 1)
1 / (self._quantisation_levels - 2)
) + 1
obs.append(int(traffic_level))

View File

@@ -85,7 +85,7 @@
id: '5'
startStep: 0
endStep: 5
load: 20
load: 999
protocol: TCP
port: '80'
source: '1'

View File

@@ -210,8 +210,8 @@ class TestLinkTrafficLevels:
* two services
* three nodes
* two links
* an IER trying to send 20 bits of data over both links the whole time (via the first service)
* link bandwidth of 1000, therefore the utilisation is 2%
* an IER trying to send 999 bits of data over both links the whole time (via the first service)
* link bandwidth of 1000, therefore the utilisation is 99.9%
"""
act = np.asarray([0, 0, 0, 0])
obs, reward, done, info = env.step(act)
@@ -219,6 +219,7 @@ class TestLinkTrafficLevels:
# the observation space has combine_service_traffic set to False, so the space has this format:
# [link1_service1, link1_service2, link2_service1, link2_service2]
# we send 20 bits of data via link1 and link2 on service 1.
# therefore the first and third elements should be 1 and all others 0
assert np.array_equal(obs, [1, 0, 1, 0])
# we send 999 bits of data via link1 and link2 on service 1.
# therefore the first and third elements should be 6 and all others 0
# (`7` corresponds to 100% utiilsation and `6` corresponds to 87.5%-100%)
assert np.array_equal(obs, [6, 0, 6, 0])