Commit 137807ba authored by Mohcine Chraibi's avatar Mohcine Chraibi

Add test 14

test if Pedestrian Generator is uniform by using Chi-Square test.
Apparently the random position are not uniform with respect to x-axis, although with respect to y-axis they are uniform.
That is: p-value for x value is two small (not uniform) and p-value for y value is high enough (reasonably uniform)
parent 385956a8
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<geometry version="0.5" caption="second life" unit="m"
<room id="0" caption="hall">
<subroom id="0" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="100.0" py="0.0" />
<vertex px="0.0" py="0.0" />
<vertex px="0.0" py="100.0" />
<vertex px="100.0" py="100.0" />
<!-- exits like crossings but between rooms or to outside (room with index
= -1) -->
<transition id="0" caption="main exit" type="emergency"
room1_id="0" subroom1_id="0" room2_id="-1" subroom2_id="-1">
<vertex px="100.0" py="0.0" />
<vertex px="100.0" py="100.0" />
<?xml version="1.0" encoding="UTF-8" ?>
<JuPedSim project="JPS-Project" version="0.5" xmlns:xsi="" xsi:noNamespaceSchemaLocation="ini.xsd">
<seed>linspace(1, 10000, 1000)</seed>
<max_sim_time unit="sec">1</max_sim_time>
<!-- geometry file -->
<!-- traectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="1">
<file location="Traj_test_14.xml" />
<!-- where to store the logs -->
<!-- traffic information: e.g closed doors or smoked rooms -->
<!-- room states are: good or smoked -->
<room room_id="0" state="good" />
<!-- doors states are: close or open -->
<goal id="0" final="true" caption="goal 0">
<vertex px="11.0" py="2.0" />
<vertex px="11.0" py="3.0" />
<vertex px="12.0" py="3.0" />
<vertex px="12.0" py="2.0" />
<vertex px="11.0" py="2.0" />
<!--persons information and distribution -->
<agents operational_model_id="1">
<group group_id="0" agent_parameter_id="0" room_id="0" subroom_id="0" number="2000" goal_id="-1" router_id="1" start_x="2" start_y="2"/>
<!-- frequency in persons/minute -->
<operational_models >
<model operational_model_id="1" description="gcfm">
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="0.2" dist_max="3" disteff_max="2" interpolation_width="0.1" />
<force_wall nu="0.2" dist_max="3" disteff_max="2" interpolation_width="0.1" />
<agent_parameters agent_parameter_id="0">
<v0 mu="1" sigma="0.0" />
<bmax mu="0.25" sigma="0.001" />
<bmin mu="0.20" sigma="0.001" />
<amin mu="0.18" sigma="0.001" />
<tau mu="0.01" sigma="0.001" />
<atau mu="0.5" sigma="0.001" />
<model operational_model_id="2" description="gompertz">
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="3" b="0.25" c="3.0"/>
<force_wall nu="10" b="0.70" c="3.0"/>
<agent_parameters agent_parameter_id="0">
<v0 mu="1.0" sigma="0.0" />
<bmax mu="0.25" sigma="0.001" />
<bmin mu="0.40" sigma="0.001" />
<amin mu="0.18" sigma="0.001" />
<tau mu="0.01" sigma="0.001" />
<atau mu="0.2" sigma="0.001" />
<router router_id="1" description="local_shortest">
<!--<navigation_lines file="routing.xml" />-->
#! /usr/bin/env python
import numpy as np
import os, argparse, logging, time, sys
from os import path, system
from sys import argv ,exit
import subprocess, glob
import multiprocessing
import matplotlib.pyplot as plt
import re
import scipy
import scipy.stats
testnr = 14
f=open(logfile, "w")
logging.basicConfig(filename=logfile, level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
#-------------------- DIRS ------------------------------
HOME = path.expanduser("~")
DIR= os.path.dirname(os.path.realpath(argv[0]))
CWD = os.getcwd()
if __name__ == "__main__":
if CWD != DIR:"working dir is %s. Change to %s"%(os.getcwd(), DIR))
os.chdir(DIR)"change directory to ..")
os.chdir("..")"call with -f %s/master_ini.xml"%DIR)["python", "", "-f", "%s/master_ini.xml"%DIR])
#-------- get directory of the code TRUNK
TRUNK = os.getcwd()
lib_path = os.path.abspath("%s/Utest"%TRUNK)
from utils import *
#----------------------------------------"change directory back to %s"%DIR)
geofile = "%s/geometry.xml"%DIR
inifiles = glob.glob("inifiles/*.xml")
if not path.exists(geofile):
logging.critical("geofile <%s> does not exist"%geofile)
executable = "%s/bin/jpscore"%TRUNK
if not path.exists(executable):
logging.critical("executable <%s> does not exist yet."%executable)
for inifile in inifiles:
if not path.exists(inifile):
logging.critical("inifile <%s> does not exist"%inifile)
#--------------------- SIMULATION ------------------------
#os.chdir(TRUNK) #cd to the simulation directory
cmd = "%s --inifile=%s"%(executable, inifile)'start simulating with exe=<%s>'%(cmd))
#------------------------------------------------------[executable, "--inifile=%s"%inifile])
#------------------------------------------------------'end simulation ...\n--------------\n')
trajfile = "trajectories/traj" + inifile.split("ini")[2]'trajfile = <%s>'%trajfile)
#--------------------- PARSING & FLOW-MEASUREMENT --------
if not path.exists(trajfile):
logging.critical("trajfile <%s> does not exist"%trajfile)
maxtime = get_maxtime(inifile)
fps, N, data = parse_file(trajfile)
data = data[ data[:,1] == 0 ]
x = data[:,2]
y = data[:,3]
nx = plt.hist(x, bins=10)[0]
ny = plt.hist(y, bins=10)[0]
px = scipy.stats.chisquare(nx)[1]
py = scipy.stats.chisquare(ny)[1]
if px < 0.1 or py < 0.1:"%s exits with FAILURE px = %f py = %f"%(argv[0], px, py))
else:"px = %f py = %f"%(px, py))"%s exits with SUCCESS"%(argv[0]))
......@@ -8,7 +8,7 @@
<max_sim_time >900</max_sim_time>
<!-- geometry file -->
<!-- traectories file and format -->
<trajectories format="xml-plain" fps="8">
<file location="trajectorien_bottleneck.xml" />
......@@ -47,7 +47,7 @@
<!--persons information and distribution -->
<agents operational_model_id="2">
<group group_id="2" agent_parameter_id="1" room_id="1" subroom_id="0" number="50" goal_id="0" router_id="1" />
<group group_id="2" agent_parameter_id="1" room_id="1" subroom_id="0" number="10" goal_id="0" router_id="1" />
<!-- <group group_id="0" room_id="0" subroom_id="2" number="4" goal_id="0" router_id="1" route_id="" /> -->
<!-- <group group_id="1" room_id="1" number="10" goal_id="0" router_id="1" route_id="" /> -->
......@@ -6,11 +6,11 @@ xsi:noNamespaceSchemaLocation="">
<!-- seed used for initialising random generator -->
<max_sim_time> 20</max_sim_time>
<!-- geometry file -->
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8">
<trajectories format="plain" fps="8">
<file location="trajectories.xml" />
<!--<socket hostname="" port="8989"/> -->
......@@ -30,7 +30,7 @@ xsi:noNamespaceSchemaLocation="">
<!--persons information and distribution -->
<agents operational_model_id="2">
<group group_id="0" agent_parameter_id="1" room_id="0" subroom_id="0" number="10" goal_id="-1" router_id="1" />
<group group_id="0" agent_parameter_id="1" room_id="0" subroom_id="0" number="2000" goal_id="-1" router_id="1" />
......@@ -284,6 +284,7 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
} else {
//fprintf(stderr, "\n----\n%f %f %f %f %f %f\n----\n",ped->GetV().GetX(), ped->GetV().GetY(), ped->GetV0().GetX(),ped->GetV0().GetY(), ped->GetPos().GetX(), ped->GetPos().GetY());
......@@ -316,6 +317,7 @@ Point GompertzModel::ForceDriv(Pedestrian* ped, Room* room) const
// if (ped->GetID() == 2)
// printf("v0=%f, e0=[%f, %f], norm e0= %f. v=[%f, %f], v=%f F=[%f, %f]\n", ped->GetV0Norm(), e0.GetX(), e0.GetY(), e0.Norm(), ped->GetV().GetX(), ped->GetV().GetY(), ped->GetV().Norm(), F_driv.GetX(), F_driv.GetY());
// getc(stdin);
fprintf(stderr, "%d %f %f %f %f %f %f\n", ped->GetID(), ped->GetPos().GetX(), ped->GetPos().GetY(), ped->GetV().GetX(), ped->GetV().GetY(), target.GetX(), target.GetY());
return F_driv;
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