Skip to content

Commit 445956a

Browse files
committed
Allow Docker init overwrite / renaming variables
1 parent 5fe79d5 commit 445956a

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ RUN python /app/setup.py install
2020
# Add sources
2121
ADD ./ /app/
2222
WORKDIR /app
23-
ENTRYPOINT ["python","/app/forever.py"]
23+
CMD ["python","/app/forever.py"]

app/routing/CustomRouter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class CustomRouter(object):
1414
edgeMap = None
1515
graph = None
1616

17-
# the percentage of smart cars that should be victimized
18-
victimsPercentage = 0.0
17+
# the percentage of smart cars that should be used for exploration
18+
explorationPercentage = 0.0
1919
# randomizes the routes
2020
routeRandomSigma = 0.3
2121
# how much speed influences the routing
@@ -38,7 +38,6 @@ def init(self):
3838
{'length': edge.length, 'maxSpeed': edge.maxSpeed,
3939
'lanes': len(edge.lanes), 'edgeID': edge.id})
4040

41-
4241
@classmethod
4342
def minimalRoute(cls, fr, to, tick, car):
4443
"""creates a minimal route based on length / speed """
@@ -68,7 +67,7 @@ def route(cls, fr, to, tick, car):
6867
# else:
6968
# 3) Advanced cost function that combines duration with averaging
7069
# isVictim = ??? random x percent (how many % routes have been victomized before)
71-
isVictim = cls.victimsPercentage > random()
70+
isVictim = cls.explorationPercentage > random()
7271
if isVictim:
7372
victimizationChoice = 1
7473
else:
@@ -87,7 +86,7 @@ def route(cls, fr, to, tick, car):
8786
cls.freshnessUpdateFactor * \
8887
victimizationChoice
8988

90-
# generate route
89+
# generate route
9190
route = find_path(cls.graph, fr, to, cost_func=cost_func)
9291
# wrap the route in a result object
9392
return RouterResult(route, isVictim)

app/simulation/Simulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def applyFileConfig(cls):
2323
""" reads configs from a json and applies it at realtime to the simulation """
2424
try:
2525
config = json.load(open('./knobs.json'))
26-
CustomRouter.victimsPercentage = config['victimsPercentage']
26+
CustomRouter.explorationPercentage = config['explorationPercentage']
2727
CustomRouter.averageEdgeDurationFactor = config['averageEdgeDurationFactor']
2828
CustomRouter.maxSpeedAndLengthFactor = config['maxSpeedAndLengthFactor']
2929
CustomRouter.freshnessUpdateFactor = config['freshnessUpdateFactor']
@@ -76,9 +76,9 @@ def loop(cls):
7676
# kafka mode
7777
newConf = KafkaConnector.checkForNewConfiguration()
7878
if newConf is not None:
79-
if "victim_percentage" in newConf:
80-
CustomRouter.victimsPercentage = newConf["victim_percentage"]
81-
print("setting victimsPercentage: " + str(newConf["victim_percentage"]))
79+
if "exploration_percentage" in newConf:
80+
CustomRouter.explorationPercentage = newConf["exploration_percentage"]
81+
print("setting victimsPercentage: " + str(newConf["exploration_percentage"]))
8282
if "route_random_sigma" in newConf:
8383
CustomRouter.routeRandomSigma = newConf["route_random_sigma"]
8484
print("setting routeRandomSigma: " + str(newConf["route_random_sigma"]))

knobs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"victimsPercentageDescription": "the percentage of routes we want to victimize",
3-
"victimsPercentage": 0.0,
2+
"explorationPercentageDescription": "the percentage of routes we want to use for exploration",
3+
"explorationPercentage": 0.0,
44
"routeRandomSigmaDescription": "the randomization sigma of edge weigths",
55
"routeRandomSigma": 0.0,
66
"maxSpeedAndLengthFactorDescription": "how much the length/speed influences the routing",

0 commit comments

Comments
 (0)