Verified Commit 2e8d07bf authored by Mohcine Chraibi's avatar Mohcine Chraibi

Merge branch 'develop' into 300-tracks-for-trains

parents a490d828 02706b98
......@@ -13,8 +13,9 @@ stages:
- configure
- compile
- unit_test
- dev_test
# - juelich_tests
# - rimea_tests
# - rimea_tests
#=====================================
#============== configure ============
......@@ -69,6 +70,17 @@ test:
- ctest -R clean
tags:
- linux
#============== dev_test ============
dev:
dependencies:
- make-linux
stage: dev_test
script:
- cd build
- ctest -R dev
tags:
- linux
#============== juelich ============
# verification:
# dependencies:
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<geometry version="0.8" caption="corner" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/jps_geometry.xsd" unit="m">
<rooms>
<room id="0" caption="floor">
<subroom id="1" caption="Room 1" class="Corridor" A_x="0" B_y="0" C_z="0">
<polygon caption="wall">
<vertex px="15" py="10"/>
<vertex px="15" py="5.5"/>
</polygon>
<polygon caption="wall">
<vertex px="0" py="5.5"/>
<vertex px="0" py="10"/>
</polygon>
<polygon caption="wall">
<vertex px="0" py="4.5"/>
<vertex px="0" py="0"/>
</polygon>
<polygon caption="wall">
<vertex px="0" py="0"/>
<vertex px="15" py="0"/>
</polygon>
<polygon caption="wall">
<vertex px="15" py="0"/>
<vertex px="15" py="4.5"/>
</polygon>
<polygon caption="wall">
<vertex px="0" py="10"/>
<vertex px="15" py="10"/>
</polygon>
</subroom>
<crossings/>
</room>
</rooms>
<transitions>
<transition id="0" caption="NaN" type="NaN" room1_id="0" subroom1_id="1" room2_id="-1" subroom2_id="-1">
<vertex px="15" py="5.5"/>
<vertex px="15" py="4.5"/>
</transition>
<transition id="1" caption="NaN" type="NaN" room1_id="0" subroom1_id="1" room2_id="-1" subroom2_id="-1">
<vertex px="0" py="5.5"/>
<vertex px="0" py="4.5"/>
</transition>
</transitions>
</geometry>
<?xml version="1.0" encoding="UTF-8" ?>
<JuPedSim project="Subway-Project" version="0.7"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../xsd/jps_ini_core.xsd">
<!-- seed used for initialising random generator -->
<seed>1254</seed>
<max_sim_time>600</max_sim_time>
<!-- geometry file -->
<geometry>../geometry.xml</geometry>
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="64">
<file location="traj-door_capacity.xml" />
</trajectories>
<!-- where to store the logs -->
<logfile>log.txt</logfile>
<show_statistics>true</show_statistics>
<traffic_constraints>
<doors> <!-- doors states are: close or open -->
<door trans_id="0" caption="NaN" state="open" dn="2" outflow="0.5" max_agents="200"/>
<door trans_id="1" caption="NaN" state="open" dn="2" outflow="2" max_agents="200"/>
</doors>
</traffic_constraints>
<!--events_file>events_list.xml</events_file-->
<routing>
</routing>
<!--persons information and distribution -->
<agents operational_model_id="3">
<agents_distribution>
<group group_id="1" agent_parameter_id="1" room_id="0" subroom_id="1" number="50" goal_id="-1" router_id="1" />
</agents_distribution>
</agents>
<operational_models>
<model operational_model_id="3" description="Tordeux2015">
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exit_crossing_strategy>8</exit_crossing_strategy>
<linkedcells enabled="true" cell_size="2.2" />
<force_ped a="8" D="0.1" />
<force_wall a="5" D="0.02" />
</model_parameters>
<agent_parameters agent_parameter_id="1">
<v0 mu="1.0" sigma="0.001" />
<bmax mu="0.15" sigma="0.0" /> <!-- this is l, assuming peds are circles with constant radius -->
<bmin mu="0.25" sigma="0.0" />
<amin mu="0.25" sigma="0.0" />
<tau mu="0.5" sigma="0.001" />
<atau mu="0.0" sigma="0.0" />
<T mu="1" sigma="0.001" />
</agent_parameters>
</model>
</operational_models>
<route_choice_models>
<router router_id="1" description="ff_global_shortest">
<!--write_VTK_files>true</write_VTK_files-->
</router>
</route_choice_models>
</JuPedSim>
#!/usr/bin/env python3
import os
import sys
import matplotlib.pyplot as plt
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
from JPSRunTest import JPSRunTestDriver
from utils import *
def runtest(inifile, trajfile):
tolerance = 0.1
failure = 0
ids, outflow = get_outflow(inifile)
for (i, o) in zip(ids, outflow):
filename = "flow_exit_id_%d_rate_%.2f.txt"%(i, o)
if not os.path.exists(filename):
logging.info("ERROR: can not find statistics file %s"%filename)
exit(FAILURE)
data = np.loadtxt(filename)
N = data[:, 1]
T = data[:, 0]
J = N[-1]/T[-1]
plt.plot(T, N)
plt.plot(T, N, lw=2)
plt.plot(T, o*T, "-k", lw=2)
logging.info("outflow (file %s) | inifile: %.2f | state-file: %.2f (+-%.2f)"%(filename, o, J, abs(J-o)))
if abs(J-o) > tolerance:
failure = 1
plt.savefig("flow.png")
if failure:
logging.info("flow from statistics files does not much expected flow from inifile")
exit(FAILURE)
if __name__ == "__main__":
test = JPSRunTestDriver(1, argv0=argv[0], testdir=sys.path[0], utestdir=utestdir)
test.run_test(testfunction=runtest)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
......@@ -7,7 +7,7 @@ import os
import sys
import time
import itertools
from numpy import *
import numpy as np
from shutil import copy2, rmtree, move
try:
......@@ -70,7 +70,7 @@ attributes_tags = ['group-pre_movement_mean',
'source-agents_max',
]
import numpy as np
# cor_tags = np.unique([att.split("_")[0] for att in attributes_tags]).astype(str)a
cor_tags = [att.split("-")[0] for att in attributes_tags]
attributes = [att.split(tag+"-")[1] for (att, tag) in zip(attributes_tags, cor_tags)]
......@@ -124,7 +124,7 @@ def get_attribute(node):
value = eval(text)
else:
value = 0
if isinstance(value, list) or isinstance(value, ndarray):
if isinstance(value, list) or isinstance(value, np.ndarray):
if len(value) > 1:
values.append([value, str(node.tag)+"-"+str(node_attrib), node_attrib])
......@@ -148,7 +148,7 @@ def get_product(root):
tag = node.tag
if tag in tags: # ignore tags that are not of interest
d = get_tag(node)
if isinstance(d, list) or isinstance(d, ndarray) or isinstance(d, range):
if isinstance(d, list) or isinstance(d, np.ndarray):
# in case some tags have multiple values
if tag not in input_tags and len(d) > 1:
# ignore lists with one element (equiv to scalars)
......
......@@ -105,11 +105,11 @@ def PassedLineX(p, exit):
x = exit[0]
y1 = exit[1]
y2 = exit[2]
X = p[:, 2]
Y = p[:, 3]
return (np.logical_and(np.logical_and(X >= x-eps, X <= x+eps), np.logical_and(Y >= y1, Y <= y2) ) ).any()
return (np.logical_and(np.logical_and(X >= x-eps, X <= x+eps), np.logical_and(Y >= y1, Y <= y2) ) ).any()
def PassedLineY(p, exit):
......@@ -124,7 +124,7 @@ def PassedLineY(p, exit):
X = p[:, 2]
Y = p[:, 3]
return (np.logical_and(np.logical_and(Y >= y-eps, Y <= y+eps), np.logical_and(X >= x1, X <= x2) ) ).any()
return (np.logical_and(np.logical_and(Y >= y-eps, Y <= y+eps), np.logical_and(X >= x1, X <= x2) ) ).any()
def get_num_threads(filename):
"""
......@@ -138,7 +138,7 @@ def get_num_threads(filename):
exit(FAILURE)
num_threads = float(xmldoc.getElementsByTagName('num_threads')[0].firstChild.nodeValue)
return num_threads
def get_maxtime(filename):
"""
get max sim time
......@@ -152,6 +152,23 @@ def get_maxtime(filename):
maxtime = float(xmldoc.getElementsByTagName('max_sim_time')[0].firstChild.nodeValue)
return maxtime
def get_outflow(filename):
"""
get outflow of doors
"""
tree = ET.parse(filename)
root = tree.getroot()
ids = []
outflow = []
for node in root.iter():
tag = node.tag
if tag == "traffic_constraints":
for doors in node.getchildren(): # doors
for door in doors.getchildren(): # door
ids.append(int(door.attrib['trans_id']))
outflow.append(float(door.attrib['outflow']))
return ids, outflow
def parse_file(filename):
"""
parse trajectories in Travisto-format and output results
......@@ -198,7 +215,7 @@ def parse_file(filename):
data = np.vstack((data, list(map(float, [ID, frame, x, y, z]) ) ) )
# data += [ID, frame, x, y, z]
# data += [ID, frame, x, y, z]
# data = np.array(data, dtype=float).reshape((-1, 5))
return fps, N, data
......@@ -277,9 +294,9 @@ def rolling_flow(fps, N, data, x0, name):
flow = fps*(windows-1)/(serie.rolling(windows, min_periods=minp).max() - serie.rolling(windows, min_periods=minp).min() )
flow = flow[~np.isnan(flow)] # remove NaN
wmean = flow.rolling(windows, min_periods=minp).mean()
np.savetxt(name, np.array(times))
logging.info("min(times)=%f max(times)=%f"%(min(times), max(times)))
return np.mean(wmean) #fps * float(N-1) / (max(times) - min(times))
......@@ -314,19 +331,19 @@ def flow(fps, N, data, x0):
if len(times) < 2:
logging.warning("Number of pedestrians passing the line is small. return 0")
return 0
logging.info("min(times)=%f max(times)=%f"%(min(times), max(times)))
return fps * float(N-1) / (max(times) - min(times))
def CalcBiVarCDF(x,y,xGrid,yGrid):
"""
Calculate the bivariate CDF of two given input signals on predefined grids.
input:
Calculate the bivariate CDF of two given input signals on predefined grids.
input:
- x: array of size n1
- y: array of size n2
- xGrid: array of size m1
- yGrid: array of size m2
output:
output:
- CDF2D: matrix
"""
nPoints = np.size(x);
......@@ -345,13 +362,13 @@ def CalcBiVarCDF(x,y,xGrid,yGrid):
def CDFDistance(x1, y1, x2, y2):
"""
For two input 2D signals calculate the distance between their CDFs.
input:
For two input 2D signals calculate the distance between their CDFs.
input:
- x1: array of size n
- y2: array of size n
- x2: array of size m
- y2: array of size m
output:
output:
- KSD: not negative number
"""
xPoints = 100;
......@@ -365,7 +382,3 @@ def CDFDistance(x1, y1, x2, y2):
# KSD = np.linalg.norm(CDF1-CDF2)/(np.linalg.norm(CDF1)+np.linalg.norm(CDF1); # Frobenius norm (p=2)
KSD = np.max(np.abs(CDF1-CDF2)); # Kolmogorov-Smirnov distance (p=inf)
return KSD
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment