Commit 9820062e authored by Ulrich Kemloh's avatar Ulrich Kemloh

Merge branch 'v0.7' into protobuf_merge

parents cbb72b17 5b36d218
......@@ -74,3 +74,4 @@ vgcore.*
/veloModel2.org
/veloModel2.pdf
/veloModel2.tex
/.project
......@@ -127,21 +127,6 @@ endif(OPENMP_FOUND)
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
# find and add the CGAL library
#fixme: complete this section
# FIND_PACKAGE(CGAL QUIET)
# if(CGAL_FOUND)
# include (${CGAL_USE_FILE})
# INCLUDE_DIRECTORIES(${CGAL_CORE_INCLUDE_DIR})
# add_definitions(-D_CGAL=1)
# message (STATUS "${CGAL_FOUND}")
# message (STATUS "${CGAL_CORE_INCLUDE_DIR}")
# message (STATUS " Erreur: ${CGAL_FOUND}")
# message (STATUS " Erreur: ${CGAL_USE_FILE}")
# else(CGAL_FOUND)
# message( STATUS "CGAL not found." )
# endif(CGAL_FOUND)
# test all cpp-files in Utest
if(BUILD_TESTING OR BUILD_CPPUNIT_TEST)
......@@ -149,7 +134,7 @@ if(BUILD_TESTING OR BUILD_CPPUNIT_TEST)
IF(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage --coverage")
endif(CMAKE_COMPILER_IS_GNUCXX)
file(GLOB test_files "${CMAKE_TEST_DIR}/*.cpp")
file(GLOB test_files "${CMAKE_TEST_DIR}/test_geometry/*.cpp")
# file(GLOB test_py_files "${CMAKE_TEST_DIR}/*/runtest*.py")
endif(BUILD_TESTING OR BUILD_CPPUNIT_TEST)
......@@ -239,6 +224,7 @@ set ( source_files
routing/cognitive_map/fire_mesh/Knot.cpp
routing/cognitive_map/fire_mesh/FireMeshStorage.cpp
poly2tri/common/shapes.cpp
poly2tri/sweep/sweep_context.cpp
poly2tri/sweep/advancing_front.cpp
......@@ -281,6 +267,7 @@ set ( header_files
routing/cognitive_map/fire_mesh/Knot.h
routing/cognitive_map/fire_mesh/FireMeshStorage.h
pedestrian/Pedestrian.h
pedestrian/PedDistributor.h
pedestrian/Ellipse.h
......
# coding:utf-8
"""
Class for benchmarking of jpscore
See template_test/How_to_make_new_test.txt
"""
import fnmatch
import glob
import logging
......@@ -9,14 +15,19 @@ import sys
__author__ = 'Oliver Schmidts'
__email__ = 'dev@jupedsim.org'
__credits__ = ['Oliver Schmidts', 'Mohcine Chraibi']
__copyright__ = '<2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.'
__license__ = 'GNU Lesser General Public License'
__version__ = '0.1'
__status__ = 'Production'
class JPSRunTestDriver(object):
def __init__(self, testnumber, argv0, testdir):
self.SUCCESS = 0
self.FAILURE = 1
# check if testnumber is an int
# check if testnumber is digit
assert isinstance(testnumber, float) or isinstance(testnumber, int)
# only allow path and strings as path directory name
assert path.exists(argv0)
......@@ -27,8 +38,7 @@ class JPSRunTestDriver(object):
self.logfile = os.path.join(testdir, self.logfile)
# touch file if not already there
f = open(self.logfile, 'a')
f.close()
open(self.logfile, 'a').close()
logging.basicConfig(filename=self.logfile, level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s')
self.HOME = path.expanduser("~")
......@@ -47,11 +57,11 @@ class JPSRunTestDriver(object):
def __configure(self):
if self.CWD != self.DIR:
logging.info("working dir is %s. Change to %s" % (os.getcwd(), self.DIR))
logging.info("working dir is %s. Change to %s", os.getcwd(), self.DIR)
os.chdir(self.DIR)
logging.info("change directory to ..")
os.chdir("..")
logging.info("call makeini.py with -f %s" % self.FILE)
logging.info("call makeini.py with -f %s", self.FILE)
subprocess.call(["python", "makeini.py", "-f", "%s" % self.FILE])
os.chdir(self.DIR)
# -------- get directory of the code TRUNK
......@@ -60,17 +70,17 @@ class JPSRunTestDriver(object):
os.chdir(self.DIR)
lib_path = os.path.abspath(os.path.join(self.trunk, "Utest"))
sys.path.append(lib_path)
logging.info("change directory back to %s" % self.DIR)
logging.info("change directory back to %s", self.DIR)
# initialise the inputfiles for jpscore
self.geofile = os.path.join(self.DIR, "geometry.xml")
self.inifiles = glob.glob(os.path.join("inifiles", "*.xml"))
if not path.exists(self.geofile):
logging.critical("geofile <%s> does not exist" % self.geofile)
logging.critical("geofile <%s> does not exist", self.geofile)
exit(self.FAILURE)
for inifile in self.inifiles:
if not path.exists(inifile):
logging.critical("inifile <%s> does not exist" % inifile)
logging.critical("inifile <%s> does not exist", inifile)
exit(self.FAILURE)
return
......@@ -84,11 +94,12 @@ class JPSRunTestDriver(object):
for filename in fnmatch.filter(filenames, 'jpscore.exe'):
matches.append(os.path.join(root, filename))
if len(matches) == 0:
logging.critical("executable <%s> or jpscore.exe does not exist yet." % executable)
logging.critical("executable <%s> or jpscore.exe does not exist yet.", executable)
exit(self.FAILURE)
elif len(matches) > 1:
matches = ((os.stat(file_path), file_path) for file_path in matches)
matches = ((stat[ST_MTIME], file_path) for stat, file_path in matches if S_ISREG(stat[ST_MODE]))
matches = ((stat[ST_MTIME], file_path)
for stat, file_path in matches if S_ISREG(stat[ST_MODE]))
matches = sorted(matches)
executable = matches[0]
# end fix for windows
......@@ -97,13 +108,14 @@ class JPSRunTestDriver(object):
def __execute_test(self, executable, inifile, testfunction, *args):
cmd = "%s --inifile=%s"%(executable, inifile)
logging.info('start simulating with exe=<%s>' % cmd)
logging.info('start simulating with exe=<%s>', cmd)
subprocess.call([executable, "--inifile=%s" % inifile])
logging.info('end simulation ...\n--------------\n')
trajfile = os.path.join("trajectories", "traj" + inifile.split("ini")[2])
logging.info('trajfile = <%s>' % trajfile)
logging.info('trajfile = <%s>', trajfile)
if not path.exists(trajfile):
logging.critical("trajfile <%s> does not exist" % trajfile)
logging.critical("trajfile <%s> does not exist", trajfile)
exit(self.FAILURE)
testfunction(inifile, trajfile, *args)
return
\ No newline at end of file
return
Utest/test_13/flow.png

38 KB | W: | H:

Utest/test_13/flow.png

38.3 KB | W: | H:

Utest/test_13/flow.png
Utest/test_13/flow.png
Utest/test_13/flow.png
Utest/test_13/flow.png
  • 2-up
  • Swipe
  • Onion skin
/**
* \file testClassLine.cpp
* \date April 18, 2015
* \version v0.7
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
*
*
**/
#define BOOST_TEST_MODULE PointTest
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "../geometry/Point.h"
#include "../../geometry/Point.h"
#include <cmath>
BOOST_AUTO_TEST_SUITE(PointTest)
......
#define BOOST_TEST_MODULE LineTest
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "../../geometry/Line.h"
#include <cmath>
BOOST_AUTO_TEST_SUITE(LineTest)
BOOST_AUTO_TEST_CASE(LINE_CONSTRUCTOR_TEST)
{
BOOST_MESSAGE("starting Default constr test");
Line L1;
Point P1 = L1.GetPoint1();
Point P2 = L1.GetPoint2();
BOOST_REQUIRE(P1.GetX() == 0 && P1.GetY() == 0);
BOOST_REQUIRE(P2.GetX() == 0 && P2.GetY() == 0);
Line L2;
BOOST_REQUIRE(L1.GetUniqueID() == 0 && L2.GetUniqueID() == 1);
BOOST_MESSAGE("Leaving Default constr test");
BOOST_MESSAGE("starting constr test");
const double PI = 3.14159265358979323846;
for (int i = -5, j = 2; i < 5; ++i, ++j)
{
i = (i == 0)? 1 : i;
P1.SetX(cos(PI / i));
P1.SetY(sin(PI * i));
P2.SetX(i);
P2.SetY(i * i);
Line L3(P1, P2);
Line L4(L3);
Point P3 = L4.GetPoint1();
Point P4 = L4.GetPoint2();
BOOST_REQUIRE(P1.GetX() == P3.GetX() && P2.GetX() == P4.GetX());
BOOST_REQUIRE(P1.GetY() == P3.GetY() && P2.GetY() == P4.GetY());
BOOST_CHECK(j == L4.GetUniqueID());
}
BOOST_MESSAGE("Leaving constr test");
}
BOOST_AUTO_TEST_CASE(LINE_NORMAL_VEC_TEST)
{
BOOST_MESSAGE("starting normal vector test");
const double PI = 3.14159265358979323846;
for (int i = -5; i < 5; ++i)
{
i = (i == 0)? 1 : i;
Point P1 (PI / i, PI * i);
Point P2 (i, sin(PI / i));
Line L1 (P1, P2);
Point normal = L1.NormalVec();
Point diff = P2 - P1;
BOOST_CHECK_MESSAGE(normal.ScalarP(diff) < 1E-12,
"normal.ScalarP(diff) = " << normal.ScalarP(diff) );
}
BOOST_MESSAGE("Leaving normal vector test");
}
BOOST_AUTO_TEST_CASE(LINE_SHORTEST_POINT_TEST)
{
BOOST_MESSAGE("starting shortest point test");
const double PI = 3.14159265358979323846;
Point PA (-2, 4);
Point PB (14, 9);
Line L1 (PA, PB);
const Point& DPAB = PA - PB;
double lambda;
for (float i = -20; i < 20; ++i)
{
i = (i == 0)? 0.5 : i;
Point P1 (i, sin(PI / i));
Point P2 = L1.ShortestPoint(P1);
lambda = (P1 - PB).ScalarP(DPAB) / DPAB.ScalarP(DPAB);
if (lambda > 1)
BOOST_CHECK_MESSAGE(P2 == PA, " P2 = ( " << P2.GetX() << ", " << P2.GetY() << ")");
else if(lambda < 0)
BOOST_CHECK_MESSAGE(P2 == PB, " P2 = ( " << P2.GetX() << ", " << P2.GetY() << ")");
else
BOOST_CHECK_MESSAGE((P2 - P1).ScalarP(DPAB) < 1E-12,
" P2 = ( " << P2.GetX() << ", " << P2.GetY() << ")");
}
BOOST_MESSAGE("Leaving shortest point test");
}
BOOST_AUTO_TEST_CASE(LINE_ISINLINESEGMENT_TEST)
{
BOOST_MESSAGE("starting is_in_linesegment test");
Line L1(Point(1,0), Point(10,0));
for (int i = 1; i <= 10; ++i)
BOOST_CHECK(L1.IsInLineSegment(Point(i, 0)));
for (int i = 0; i < 20; ++i)
BOOST_CHECK(!L1.IsInLineSegment(Point(i, i)));
BOOST_MESSAGE("Leaving is_in_linesegment test");
}
BOOST_AUTO_TEST_CASE(LINE_DIST_TO_TEST)
{
BOOST_MESSAGE("starting dist to shortestPoint test");
Line L1(Point(-10, 2), Point(10, 2));
for (int i = -10; i < 11; ++i)
{
BOOST_CHECK_MESSAGE(L1.DistTo(Point(i, i)) == abs(i-2), L1.DistTo(Point(i, i)));
BOOST_CHECK_MESSAGE(L1.DistToSquare(Point(i, i)) == abs(i-2)^2, L1.DistToSquare(Point(i, i)));
}
BOOST_MESSAGE("Leaving dist to shortestPoint test");
}
BOOST_AUTO_TEST_CASE(LINE_OPERATOR_TEST)
{
BOOST_MESSAGE("starting operator overload test");
const double PI = 3.14159265358979323846;
for (int i = -5; i < 5; ++i)
{
i = (i == 0)? 1 : i;
Point P1 (PI / i, PI * i);
Point P2 (i, sin(PI / i));
Line L1 (P1, P2);
Line L2 (P1, P2);
BOOST_CHECK(L1 == L2);
Point P3 (i, i);
Line L3 (P2, P3);
BOOST_CHECK(L1 != L3);
}
BOOST_MESSAGE("Leaving operator overload test");
}
BOOST_AUTO_TEST_CASE(LINE_LENGTH_TEST)
{
BOOST_MESSAGE("starting line length test");
Point P1;
const double PI = 3.14159265358979323846;
for (int i = -5; i < 5; ++i)
{
i = (i == 0)? 1 : i;
Point P2 (i, sin(PI / i));
Line L1 (P1, P2);
double norm = P2.Norm();
BOOST_CHECK(L1.Length() == norm);
double normSq = P2.NormSquare();
BOOST_CHECK(L1.LengthSquare() == normSq);
}
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
/**
* \file testClassLine.cpp
* \date April 27, 2015
* \version v0.7
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
*
*
**/
#define BOOST_TEST_MODULE WallTest
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "../../geometry/Wall.h"
BOOST_AUTO_TEST_SUITE(WallTest)
BOOST_AUTO_TEST_CASE(Wall_Constr_Test)
{
BOOST_MESSAGE("starting wall constructor test");
Wall W1;
Point P1;
BOOST_CHECK(W1.GetPoint1() == P1 && W1.GetPoint2() == P1);
std::string type[] = {"internal", "external"};
for (int i = 0; i < 10; ++i)
{
Point P2(0, i*i);
Point P3(static_cast<float>(i)/1000000, i*i);
Line L1(P2, P3);
Wall W2(P2, P3, type[i%2]);
BOOST_CHECK_MESSAGE(W2 == L1, "");
// GetType test
BOOST_CHECK(W2.GetType() == type[i%2]);
}
BOOST_MESSAGE("Leaving wall constructor test");
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -46,7 +46,7 @@ using namespace std;
Obstacle::Obstacle()
{
_isClosed=0.0;
_isClosed=0;
_height=0.0;
_id=-1;
_caption="obstacle";
......@@ -72,12 +72,12 @@ void Obstacle::SetCaption(string caption)
_caption = caption;
}
double Obstacle::GetClosed() const
int Obstacle::GetClosed() const
{
return _isClosed;
}
void Obstacle::SetClosed(double closed)
void Obstacle::SetClosed(int closed)
{
_isClosed = closed;
}
......@@ -211,7 +211,7 @@ bool Obstacle::Contains(const Point& ped) const
bool Obstacle::ConvertLineToPoly()
{
if(_isClosed==0.0)
if(_isClosed==0)
{
char tmp[CLENGTH];
sprintf(tmp, "INFO: \tObstacle [%d] is not closed. Not converting to polyline.\n", _id);
......
......@@ -40,7 +40,7 @@ class Line;
class Obstacle {
private:
double _isClosed;
int _isClosed;
double _height;
int _id;
std::string _caption;
......@@ -64,12 +64,12 @@ public:
/**
* Set/Get the close state of the obstacle
*/
double GetClosed() const;
int GetClosed() const;
/**
* Set/Get the close state of the obstacle
*/
void SetClosed(double closed);
void SetClosed(int closed);
/**
* Set/Get the height of the obstacle.
......
......@@ -2,7 +2,7 @@
* \file Wall.cpp
* \date Nov 16, 2010
* \version v0.6
* \copyright <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
* This file is part of JuPedSim.
......
......@@ -2,7 +2,7 @@
* \file Wall.h
* \date Nov 16, 2010
* \version v0.6
* \copyright <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
* This file is part of JuPedSim.
......
......@@ -4,6 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<max_sim_time>10000</max_sim_time>
......
<?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="../../xsd/jps_geometry.xsd">
<rooms>
<room id="0" caption="hall">
<subroom id="0" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="40.0" py="2.0" />
<vertex px="-2.0" py="2.0" />
<vertex px="-2.0" py="0.0" />
<vertex px="40.0" py="0.0" />
</polygon>
</subroom>
</room>
</rooms>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xsd.jupedsim.org/jps_geometry.xsd">
<rooms>
<room id="0" caption="hall">
<subroom id="0" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="40.0" py="2.0" />
<vertex px="-2.0" py="2.0" />
<vertex px="-2.0" py="0.0" />
<vertex px="40.0" py="0.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="40.0" py="0.0" />
<vertex px="40.0" py="2.0" />
</transition>
</transitions>
<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="40.0" py="0.0" />
<vertex px="40.0" py="2.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="../../xsd/jps_ini_core.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xsd.jupedsim.org/jps_ini_core.xsd">
<!-- seed used for initialising random generator -->
<seed>1254</seed>
......@@ -15,7 +15,7 @@ xsi:noNamespaceSchemaLocation="../../xsd/jps_ini_core.xsd">
<!--<socket hostname="127.0.0.1" port="8989"/> -->
</trajectories>
<!-- where to store the logs -->
<!--<logfile>log.txt</logfile> -->
<logfile>RiMEATest1_log.txt</logfile>
<!-- traffic information: e.g closed doors -->
......@@ -26,15 +26,14 @@ xsi:noNamespaceSchemaLocation="../../xsd/jps_ini_core.xsd">
</routing>
<!--persons information and distribution -->
<agents operational_model_id="1">
<agents operational_model_id="2"> <!-- use Gompertz -->
<agents_distribution>
<group group_id="0" agent_parameter_id="1" room_id="0" subroom_id="0" number="1" goal_id="-1" router_id="1" start_x="0" start_y="1" />
</agents_distribution>
</agents>
<!-- These parameters may be overwritten -->
<!-- These parameters may be overwritten -->
<operational_models>
<operational_models>
<model operational_model_id="1" description="gcfm">
<model_parameters>
<solver>euler</solver>
......@@ -65,7 +64,7 @@ xsi:noNamespaceSchemaLocation="../../xsd/jps_ini_core.xsd">
<model operational_model_id="2" description="gompertz">
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<stepsize>0.001</stepsize>
<exit_crossing_strategy>3</exit_crossing_strategy>
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="3" b="0.25" c="3.0"/>
......
......@@ -62,10 +62,6 @@ CognitiveMapRouter::~CognitiveMapRouter()
}
int CognitiveMapRouter::FindExit(Pedestrian * p)
{
//check for former goal.
......@@ -83,8 +79,6 @@ int CognitiveMapRouter::FindExit(Pedestrian * p)
(*cm_storage)[p]->UpdateSubRoom();
return status;
}
//std::cout << p->GetGlobalTime() << std::endl;
......
......@@ -39,6 +39,8 @@
using namespace std;
/**
* Constructors & Destructors
*/
......@@ -47,6 +49,7 @@ CognitiveMap::CognitiveMap(const Building * building, const Pedestrian * pedestr
: building(building), pedestrian(pedestrian)
{
navigation_graph = new NavigationGraph(building);
}