Commit 86253597 authored by Mohcine Chraibi's avatar Mohcine Chraibi

Add test 15

tests if code is getting slower.
parent e6c7f4ce
......@@ -67,7 +67,7 @@
<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" />
<tau mu="0.5" sigma="0.001" />
<atau mu="0.5" sigma="0.001" />
</agent_parameters>
</model>
......@@ -86,7 +86,7 @@
<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" />
<tau mu="0.5" sigma="0.001" />
<atau mu="0.2" sigma="0.001" />
</agent_parameters>
</model>
......
<?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,1000,1)</seed>
<numCPU>4</numCPU>
<max_sim_time unit="sec">2000</max_sim_time>
<!-- geometry file -->
<geometry>../geometry.xml</geometry>
<!-- traectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="8">
<file location="Traj_test_1.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="2">
<agents_distribution>
<group group_id="0" agent_parameter_id="0" room_id="0" subroom_id="0" number="3500" goal_id="-1" router_id="1"/>
</agents_distribution>
<!-- frequency in persons/minute -->
<agents_sources/>
</agents>
<operational_models >
<model operational_model_id="1" description="gcfm">
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exitCrossingStrategy>3</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.5" 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.5" 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
#=========================
testnr = int(argv[0].split("_")[1].split(".")[0])
#========================
must_time = 10 # 10 m corridor with 1m/s
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)
logsim = "inifiles/log.P0.dat"
if not path.exists(logsim):
logging.critical("logsim <%s> does not exist"%logsim)
exit(FAILURE)
logging.info("open <%s> "%logsim)
f = open(logsim, "r")
for line in f:
if line.startswith("Exec"):
exec_time = float( line.split()[-1])
if line.startswith("Evac"):
evac_time = float(line.split()[-1])
f.close()
if evac_time < exec_time:
logging.info("%s exits with FAILURE evac_time = %f, exec_time = %f)"%(argv[0], evac_time, exec_time))
exit(FAILURE)
else:
logging.info("evac_time = %f exec_time = %f)"%(evac_time, exec_time))
logging.info("%s exits with SUCCESS"%(argv[0]))
exit(SUCCESS)
......@@ -2,15 +2,15 @@
<JuPedSim project="JPS-Project" version="0.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/jps_ini_core.xsd">
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<max_sim_time>1</max_sim_time>
<max_sim_time>10000</max_sim_time>
<!-- geometry file -->
<geometry>geo.xml</geometry>
<!-- trajectories file and format -->
<trajectories format="plain" fps="8">
<trajectories format="xml-plain" fps="8">
<file location="trajectories.xml" />
<!--<socket hostname="127.0.0.1" port="8989"/> -->
</trajectories>
......@@ -40,7 +40,7 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<model operational_model_id="1" description="gcfm">
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<stepsize>0.001</stepsize>
<exitCrossingStrategy>4</exitCrossingStrategy>
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="0.3" dist_max="3" disteff_max="2" interpolation_width="0.1" />
......
......@@ -199,12 +199,12 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
bool isVisible = building->IsVisible(p1, p2, false);
if (!isVisible)
continue;
if(debugPed == ped->GetID())
{
fprintf(stderr, "%f %f %f %f %f %d %d %d\n", current, p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY(), isVisible, ped->GetID(), ped1->GetID());
printf("t=%.2f, ped:%d ped1:%d p1(%.2f, %.2f), p2(%.2f, %.2f) isVisibile = %d\n", current, ped->GetID(), ped1->GetID(), p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY(), isVisible);
// if(debugPed == ped->GetID())
// {
// fprintf(stderr, "%f %f %f %f %f %d %d %d\n", current, p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY(), isVisible, ped->GetID(), ped1->GetID());
// printf("t=%.2f, ped:%d ped1:%d p1(%.2f, %.2f), p2(%.2f, %.2f) isVisibile = %d\n", current, ped->GetID(), ped1->GetID(), p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY(), isVisible);
}
// }
if (ped->GetUniqueRoomID() == ped1->GetUniqueRoomID()) {
repPed = repPed + ForceRepPed(ped, ped1);
} else {
......@@ -229,7 +229,7 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
// = fd ; //+ ped->GetV0()*correction;
Point acc = (fd + repPed + repWall) / ped->GetMass();
// if(ped->GetID() == 2 ) {
// if(ped->GetID() == 976 ) {
// printf("Pos1 =[%f, %f]\n", ped->GetPos().GetX(), ped->GetPos().GetY());
// printf("acc= %f %f, fd= %f, %f, repPed = %f %f, repWall= %f, %f\n", acc.GetX(), acc.GetY(), fd.GetX(), fd.GetY(), repPed.GetX(), repPed.GetY(), repWall.GetX(), repWall.GetY());
// getc(stdin);
......@@ -244,35 +244,22 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
Point vToAdd = result_acc[p - start] * deltaT;
//----------------- update new pos and new vel -----------------
// printf("toadd [%f, %f] m=%f\n", vToAdd.GetX(), vToAdd.GetY(), ped->GetMass());
Point v_neu = ped->GetV() + vToAdd;
// if(ped->GetID() == 2 )
// v_neu = Point(0,0);
Point pos_neu = ped->GetPos() + v_neu * deltaT;
//---------------------------------------------------------------
// Point e0 = ped->GetV0();
// double isBackwards;
// isBackwards = v_neu.GetX()*e0.GetX() + v_neu.GetY()*e0.GetY();
// if (ped->GetV().Norm()>J_EPS_V) {
// isBackwards = isBackwards/(v_neu.Norm() * e0.Norm()); //normalize
// if(isBackwards <= J_EPS_V) { // Pedestrian is moving in the wrong direction
// v_neu = v_neu*0.01;
// pos_neu = ped->GetPos() + v_neu *h ;
// printf("wrong direction\n");
// }
// }
if(v_neu.Norm() > ped->GetV0Norm()+0.2 ) { // Stop pedestrians
//Log->Write("WARNING: ped %d is stopped because v=%f (v0=%f)\n", ped->GetID(), v_neu.Norm(), ped->GetV0Norm());
Log->Write("WARNING: ped %d is stopped because v=%f (v0=%f)\n", ped->GetID(), v_neu.Norm(), ped->GetV0Norm());
v_neu = v_neu*0.01;
pos_neu = ped->GetPos();
}
//--------------------------------------------------------------------------------------------------
//Jam is based on the current velocity
// //--------------------------------------------------------------------------------------------------
// //Jam is based on the current velocity
if ( v_neu.Norm() >= ped->GetV0Norm()*0.5) {
ped->ResetTimeInJam();
} else {
......@@ -284,6 +271,10 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
ped->SetPos(pos_neu);
ped->SetV(v_neu);
ped->SetPhiPed();
// if(ped->GetID() == 976 ) {
// printf("toadd [%f, %f] m=%f\n", vToAdd.GetX(), vToAdd.GetY(), ped->GetMass());
// printf("pos_neu= %f %f v_neu %f %f\n", pos_neu.GetX(), pos_neu.GetY(), v_neu.GetX(), v_neu.GetY());
// }
}
}//end parallel
}
......@@ -308,10 +299,8 @@ Point GompertzModel::ForceDriv(Pedestrian* ped, Room* room) const
}
F_driv = ((e0 * ped->GetV0Norm() - ped->GetV()) * ped->GetMass()) / ped->GetTau();
// 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());
// 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