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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_geoemtry.xsd">
<rooms>
<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" />
</polygon>
</subroom>
</room>
</rooms>
<transitions>
<!-- 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" />
</transition>
</transitions>
</geometry>
<?xml version="1.0" encoding="UTF-8" ?>
<JuPedSim project="JPS-Project" version="0.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ini.xsd">
<seed>linspace(1, 10000, 1000)</seed>
<numCPU>4</numCPU>
<max_sim_time unit="sec">1</max_sim_time>
<!-- geometry file -->
<geometry>../geometry.xml</geometry>
<!-- traectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="1">
<file location="Traj_test_14.xml" />
</trajectories>
<!-- where to store the logs -->
<!--logfile>log</logfile-->
<!-- traffic information: e.g closed doors or smoked rooms -->
<traffic_constraints>
<!-- room states are: good or smoked -->
<rooms>
<room room_id="0" state="good" />
</rooms>
<!-- doors states are: close or open -->
<doors>
</doors>
</traffic_constraints>
<routing>
<goals>
<goal id="0" final="true" caption="goal 0">
<polygon>
<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" />
</polygon>
</goal>
</goals>
</routing>
<!--persons information and distribution -->
<agents operational_model_id="1">
<agents_distribution>
<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"/>
</agents_distribution>
<!-- frequency in persons/minute -->
<agents_sources/>
</agents>
<operational_models >
<model operational_model_id="1" description="gcfm">
<model_parameters>
<solver>euler</solver>
<stepsize>1</stepsize>
<exitCrossingStrategy>1</exitCrossingStrategy>
<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" />
</model_parameters>
<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" />
</agent_parameters>
</model>
<model operational_model_id="2" description="gompertz">
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exitCrossingStrategy>3</exitCrossingStrategy>
<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"/>
</model_parameters>
<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" />
</agent_parameters>
</model>
</operational_models>
<route_choice_models>
<router router_id="1" description="local_shortest">
<parameters>
<!--<navigation_lines file="routing.xml" />-->
</parameters>
</router>
</route_choice_models>
</JuPedSim>
#! /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
#========================
SUCCESS = 0
FAILURE = 1
#--------------------------------------------------------
logfile="log_test_%d.txt"%testnr
f=open(logfile, "w")
f.close()
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:
logging.info("working dir is %s. Change to %s"%(os.getcwd(), DIR))
os.chdir(DIR)
logging.info("change directory to ..")
os.chdir("..")
logging.info("call makeini.py with -f %s/master_ini.xml"%DIR)
subprocess.call(["python", "makeini.py", "-f", "%s/master_ini.xml"%DIR])
os.chdir(DIR)
#-------- get directory of the code TRUNK
os.chdir("../..")
TRUNK = os.getcwd()
os.chdir(DIR)
lib_path = os.path.abspath("%s/Utest"%TRUNK)
sys.path.append(lib_path)
from utils import *
#----------------------------------------
logging.info("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)
exit(FAILURE)
executable = "%s/bin/jpscore"%TRUNK
if not path.exists(executable):
logging.critical("executable <%s> does not exist yet."%executable)
exit(FAILURE)
for inifile in inifiles:
if not path.exists(inifile):
logging.critical("inifile <%s> does not exist"%inifile)
exit(FAILURE)
#--------------------- SIMULATION ------------------------
#os.chdir(TRUNK) #cd to the simulation directory
cmd = "%s --inifile=%s"%(executable, inifile)
logging.info('start simulating with exe=<%s>'%(cmd))
#------------------------------------------------------
subprocess.call([executable, "--inifile=%s"%inifile])
#------------------------------------------------------
logging.info('end simulation ...\n--------------\n')
trajfile = "trajectories/traj" + inifile.split("ini")[2]
logging.info('trajfile = <%s>'%trajfile)
#--------------------- PARSING & FLOW-MEASUREMENT --------
if not path.exists(trajfile):
logging.critical("trajfile <%s> does not exist"%trajfile)
exit(FAILURE)
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:
logging.info("%s exits with FAILURE px = %f py = %f"%(argv[0], px, py))
exit(FAILURE)
else:
logging.info("px = %f py = %f"%(px, py))
logging.info("%s exits with SUCCESS"%(argv[0]))
exit(SUCCESS)
......@@ -8,7 +8,7 @@
<seed>12542</seed>
<max_sim_time >900</max_sim_time>
<!-- geometry file -->
<geometry>0.8_bottleneck.xml</geometry>
<geometry>2.0_bottleneck.xml</geometry>
<!-- 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">
<agents_distribution>
<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="" /> -->
</agents_distribution>
......
......@@ -6,11 +6,11 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<max_sim_time> 20</max_sim_time>
<max_sim_time>1</max_sim_time>
<!-- geometry file -->
<geometry>geo.xml</geometry>
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8">
<trajectories format="plain" fps="8">
<file location="trajectories.xml" />
<!--<socket hostname="127.0.0.1" port="8989"/> -->
</trajectories>
......@@ -30,7 +30,7 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<!--persons information and distribution -->
<agents operational_model_id="2">
<agents_distribution>
<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" />
</agents_distribution>
</agents>
......
......@@ -284,6 +284,7 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
} else {
ped->UpdateTimeInJam();
}
//--------------------------------------------------------------------------------------------------
//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());
ped->SetPos(pos_neu);
......@@ -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