Skip to content
Permalink
Browse files

add a simple map for running experiments

  • Loading branch information...
volkhin committed Apr 25, 2015
1 parent c16b8ce commit a316ea915acc04841d6e9bbf2492ea4ca12234cb
Showing with 297 additions and 37 deletions.
  1. +2 −2 coffee/model/world.coffee
  2. +8 −6 coffee/runner.coffee
  3. +3 −3 dist/main.js
  4. +11 −11 experiments/3.data
  5. +258 −0 experiments/map.json
  6. +15 −15 experiments/report.ipynb
@@ -33,8 +33,8 @@ class World
delete data.cars
localStorage.world = JSON.stringify data

load: ->
data = localStorage.world
load: (data) ->
data = data or localStorage.world
data = data and JSON.parse data
return unless data?
@clear()
@@ -9,10 +9,12 @@ fs = require 'fs'

measureAverageSpeed = (setupCallback) ->
world = new World()
world.generateMap()
world.carsNumber = 200
if setupCallback?
setupCallback world
map = fs.readFileSync './experiments/map.json', {encoding: 'utf8'}
console.log map
# world.generateMap()
world.load map
world.carsNumber = 50
setupCallback?(world)
results = []
for i in [0..10000]
world.onTick 0.2
@@ -53,10 +55,10 @@ experiment3 = () ->
for it in [0..10]
result = measureAverageSpeed (world) ->
i.controlSignals.flipMultiplier = 1 for id, i of world.intersections.all()
i.controlSignals.phaseOffset = Math.random() * 100
i.controlSignals.phaseOffset = 0
getParams world
out.write(it + ' ' + result + '\n')

# experiment1()
# experiment2()
experiment3()
# experiment3()
@@ -1430,9 +1430,9 @@ World = (function() {
return localStorage.world = JSON.stringify(data);
};

World.prototype.load = function() {
var data, id, intersection, road, _ref, _ref1, _results;
data = localStorage.world;
World.prototype.load = function(data) {
var id, intersection, road, _ref, _ref1, _results;
data = data || localStorage.world;
data = data && JSON.parse(data);
if (data == null) {
return;
@@ -1,12 +1,12 @@
it avg_speed
0 0.9164891329680831
1 0.5635651043590848
2 1.1879970042351429
3 0.8976193620668499
4 1.2069025672543854
5 1.1004536410021297
6 0.9663181017955793
7 1.1276475247049398
8 1.0986892788297717
9 0.9169673023182563
10 1.126014295127344
0 2.980306077099876
1 3.032102176877889
2 2.904853492126717
3 2.7504206867081167
4 3.1153435899149273
5 3.097252916027324
6 3.0260915353579376
7 2.765088005242487
8 2.7944063146100353
9 2.626899919923089
10 3.201576586751489
@@ -0,0 +1,258 @@
{
"carsNumber": 51,
"intersections": {
"intersection205": {
"controlSignals": {
"flipMultiplier": 0.3586561616975814,
"phaseOffset": 56.17325536441058
},
"id": "intersection205",
"rect": {
"_height": 14,
"_width": 14,
"x": -140,
"y": -140
}
},
"intersection206": {
"controlSignals": {
"flipMultiplier": 0.9427517151925713,
"phaseOffset": 91.94333299528807
},
"id": "intersection206",
"rect": {
"_height": 14,
"_width": 14,
"x": -140,
"y": 28
}
},
"intersection207": {
"controlSignals": {
"flipMultiplier": 0.37194781098514795,
"phaseOffset": 20.4648393439129
},
"id": "intersection207",
"rect": {
"_height": 14,
"_width": 14,
"x": 98,
"y": 28
}
},
"intersection208": {
"controlSignals": {
"flipMultiplier": 0.6825677102897316,
"phaseOffset": 54.371747095137835
},
"id": "intersection208",
"rect": {
"_height": 14,
"_width": 14,
"x": 98,
"y": -140
}
},
"intersection225": {
"controlSignals": {
"flipMultiplier": 0.39503228454850614,
"phaseOffset": 35.17415614333004
},
"id": "intersection225",
"rect": {
"_height": 14,
"_width": 14,
"x": 280,
"y": -140
}
},
"intersection226": {
"controlSignals": {
"flipMultiplier": 0.8068325931672007,
"phaseOffset": 12.863103952258825
},
"id": "intersection226",
"rect": {
"_height": 14,
"_width": 14,
"x": 280,
"y": 28
}
},
"intersection235": {
"controlSignals": {
"flipMultiplier": 0.17445796635001898,
"phaseOffset": 43.62397517543286
},
"id": "intersection235",
"rect": {
"_height": 14,
"_width": 14,
"x": 280,
"y": -238
}
},
"intersection240": {
"controlSignals": {
"flipMultiplier": 0.3383670481853187,
"phaseOffset": 81.65818282868713
},
"id": "intersection240",
"rect": {
"_height": 14,
"_width": 14,
"x": -140,
"y": 154
}
},
"intersection243": {
"controlSignals": {
"flipMultiplier": 0.9240458155982196,
"phaseOffset": 69.73594785667956
},
"id": "intersection243",
"rect": {
"_height": 14,
"_width": 14,
"x": 98,
"y": 140
}
},
"intersection250": {
"controlSignals": {
"flipMultiplier": 0.604135254630819,
"phaseOffset": 58.322132169269025
},
"id": "intersection250",
"rect": {
"_height": 14,
"_width": 14,
"x": 266,
"y": 140
}
}
},
"roads": {
"road213": {
"id": "road213",
"source": "intersection205",
"target": "intersection208"
},
"road214": {
"id": "road214",
"source": "intersection208",
"target": "intersection205"
},
"road217": {
"id": "road217",
"source": "intersection207",
"target": "intersection208"
},
"road218": {
"id": "road218",
"source": "intersection208",
"target": "intersection207"
},
"road221": {
"id": "road221",
"source": "intersection206",
"target": "intersection207"
},
"road222": {
"id": "road222",
"source": "intersection207",
"target": "intersection206"
},
"road223": {
"id": "road223",
"source": "intersection206",
"target": "intersection205"
},
"road224": {
"id": "road224",
"source": "intersection205",
"target": "intersection206"
},
"road227": {
"id": "road227",
"source": "intersection207",
"target": "intersection226"
},
"road228": {
"id": "road228",
"source": "intersection226",
"target": "intersection207"
},
"road229": {
"id": "road229",
"source": "intersection226",
"target": "intersection225"
},
"road230": {
"id": "road230",
"source": "intersection225",
"target": "intersection226"
},
"road233": {
"id": "road233",
"source": "intersection225",
"target": "intersection208"
},
"road234": {
"id": "road234",
"source": "intersection208",
"target": "intersection225"
},
"road238": {
"id": "road238",
"source": "intersection225",
"target": "intersection235"
},
"road239": {
"id": "road239",
"source": "intersection235",
"target": "intersection225"
},
"road241": {
"id": "road241",
"source": "intersection240",
"target": "intersection206"
},
"road242": {
"id": "road242",
"source": "intersection206",
"target": "intersection240"
},
"road244": {
"id": "road244",
"source": "intersection240",
"target": "intersection243"
},
"road245": {
"id": "road245",
"source": "intersection243",
"target": "intersection240"
},
"road248": {
"id": "road248",
"source": "intersection243",
"target": "intersection207"
},
"road249": {
"id": "road249",
"source": "intersection207",
"target": "intersection243"
},
"road251": {
"id": "road251",
"source": "intersection243",
"target": "intersection250"
},
"road252": {
"id": "road252",
"source": "intersection250",
"target": "intersection243"
}
},
"time": 412.85618499998236
}

0 comments on commit a316ea9

Please sign in to comment.
You can’t perform that action at this time.