Commit c3d1cdca authored by Erik Andresen's avatar Erik Andresen

Merge branch 'v0.7' of cst.version.fz-juelich.de:jupedsim/jpscore into v0.7

parents a0757617 7c39bec9
......@@ -5,7 +5,8 @@ All notable changes to this project will be documented in this file.
## v0.7.0 [Unreleased]
### Added
- Changelog file
- Rimea testcases
- Rimea testcases
- risk tolerance factor (value in [0 1]) for pedestrian. Pedestrians with high values are likely to take more risks.
### Changed
-
......
......@@ -146,6 +146,9 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
if(BUILD_TESTING OR BUILD_CPPUNIT_TEST)
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
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_py_files "${CMAKE_TEST_DIR}/*/runtest*.py")
endif(BUILD_TESTING OR BUILD_CPPUNIT_TEST)
......
......@@ -2,6 +2,7 @@
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "../geometry/Point.h"
#include <cmath>
BOOST_AUTO_TEST_SUITE(PointTest)
......@@ -42,11 +43,182 @@ BOOST_AUTO_TEST_CASE(Point_Norm_Tests)
BOOST_CHECK(p1.Norm() == 1);
p1.SetY(3);
BOOST_CHECK(p1.Norm() == 3);
p1.SetX(3);
p1.SetY(4);
BOOST_CHECK(p1.Norm() == 5);
BOOST_TEST_MESSAGE("Leaving norm test");
}
BOOST_AUTO_TEST_CASE(POINT_TO_STRING_Test)
{
BOOST_TEST_MESSAGE("starting string conv test");
std::string xpt[] = {"0.25", "1.25", "2.25", "3.25"};
std::string ypt[] = {"10.25", "11.25", "12.25", "13.25"};
Point p1;
for (double i = 0.25; i < 4; ++i)
{
p1.SetX(i);
p1.SetY(i+10);
BOOST_CHECK( p1.toString() == "( " + xpt[int(i)] +
" : " + ypt[int(i)] + " )" );
}
Point p2(-2,-0.5);
BOOST_CHECK( p2.toString() == "( -2 : -0.5 )" );
BOOST_TEST_MESSAGE("Leaving string conv test");
}
BOOST_AUTO_TEST_CASE(POINT_NORM_MOLIFIED_TEST)
{
BOOST_TEST_MESSAGE("starting NormMolified test");
Point p;
for (double i = 0, j = 0.5; i < 10; ++i, ++j)
{
p.SetX(i);
p.SetY(j);
BOOST_CHECK( p.NormMolified() == sqrt(pow(i,2) + pow(j,2) + 0.1) );
}
BOOST_TEST_MESSAGE("Leaving NormMolified test");
}
BOOST_AUTO_TEST_CASE(POINT_NORM_SQUARE_TEST)
{
BOOST_TEST_MESSAGE("starting NormSquare test");
Point p;
for (double i = -5, j = 0.6; i < 5; ++i, ++j)
{
p.SetX(i);
p.SetY(j);
BOOST_CHECK( p.NormSquare() == pow(i,2) + pow(j,2) );
}
BOOST_TEST_MESSAGE("Leaving NormMSquare test");
}
BOOST_AUTO_TEST_CASE(POINT_NORMALIZE_TEST)
{
BOOST_MESSAGE("starting Normalize test");
Point p1(0.0001,0.0001);
Point p2(10,10);
p2 = p1.Normalized();
BOOST_MESSAGE(" check for norm < J_EPS ");
BOOST_REQUIRE( p2.GetX() == 0.0 && p2.GetY() == 0.0 );
for (double i = 0, j = -10; i < 5; ++i, ++j)
{
p1.SetX(i);
p1.SetY(j);
p2 = p1.Normalized();
BOOST_MESSAGE(" check for norm > J_EPS ");
BOOST_REQUIRE( p2.GetX() == i / p1.Norm() &&
p2.GetY() == j / p1.Norm() );
p2 = p1.NormalizedMolified();
BOOST_MESSAGE(" check for norm > J_EPS_GOAL ");
BOOST_REQUIRE( p2.GetX() == i / p1.NormMolified() &&
p2.GetY() == j / p1.NormMolified() );
}
BOOST_MESSAGE("Leaving normalize test");
}
BOOST_AUTO_TEST_CASE(POINT_DET_TEST)
{
BOOST_MESSAGE("starting determinant test");
const double PI = 3.14159265358979323846;
Point p1(10,5);
Point p2;
for (int i = 1; i < 5; ++i)
{
p2.SetX( cos(PI / -i) );
p2.SetY( sin(PI / i) );
BOOST_CHECK( p1.Det(p2) == 10 * sin(PI/i) - 5 * cos(PI/i));
//BOOST_CHECK( p1.Det(p2) == p1.CrossP(p2));
}
BOOST_MESSAGE("Leaving determinant test");
}
BOOST_AUTO_TEST_CASE(POINT_SCALARPRODUCT_TEST)
{
BOOST_MESSAGE("starting scalar product test");
const double PI = 3.14159265358979323846;
Point p1(10,5);
Point p2;
for (int i = 1; i < 5; ++i)
{
p2.SetX( cos(PI / i) );
p2.SetY( sin(PI / -i) );
BOOST_CHECK( p1.ScalarP(p2) == 10 * p2.GetX() + 5 * p2.GetY() );
}
BOOST_MESSAGE("Leaving scalar product test");
}
BOOST_AUTO_TEST_CASE(POINT_OPEROVERLOADING_TEST)
{
BOOST_MESSAGE("starting operator overload test");
const double PI = 3.14159265358979323846;
for (int i = 1; i < 10; ++i)
{
Point p1(i, -i*10);
Point p2( cos(PI/i), sin(PI/i) );
Point sum = p1 + p2;
BOOST_REQUIRE( sum.GetX() == i + cos(PI/i) &&
sum.GetY() == -i*10 + sin(PI/i) );
Point sub = p1 - p2;
BOOST_REQUIRE( sub.GetX() == i - cos(PI/i) &&
sub.GetY() == -i*10 - sin(PI/i) );
Point mul = p2 * i;
BOOST_REQUIRE( mul.GetX() == i * cos(PI/i) &&
mul.GetY() == i * sin(PI/i) );
Point pluseq(i, i);
pluseq += p1;
BOOST_REQUIRE( pluseq.GetX() == i + i &&
pluseq.GetY() == -i*10 + i );
Point div = p2 / 1E-7;
BOOST_REQUIRE( div.GetX() == p2.GetX() &&
div.GetY() == p2.GetY() );
div = p2 / 2;
BOOST_REQUIRE( div.GetX() == p2.GetX() / 2 &&
div.GetY() == p2.GetY() / 2 );
BOOST_CHECK( p1 != p2 );
p1.SetX( p2.GetX() );
p1.SetY( p2.GetY() );
BOOST_CHECK( p1 == p2 );
}
BOOST_MESSAGE("Leaving operator overload test");
}
BOOST_AUTO_TEST_CASE(POINT_COORDTRANS_TO_ELLIPSE_TEST)
{
BOOST_MESSAGE("starting coord transform to ellipse");
const double PI = 3.14159265358979323846;
for (int i = 1; i < 5; ++i)
{
Point p1(i*10, i/10);
Point center(i, -i);
Point check = (p1 - center).Rotate( cos(PI/i), -sin(PI/i) );
Point transform = p1.CoordTransToEllipse( center, cos(PI/i), sin(PI/i) );
BOOST_CHECK( transform == check );
}
BOOST_MESSAGE("Leaving coord transform to ellipse");
}
BOOST_AUTO_TEST_CASE(POINT_COORDTRANS_TO_CART_TEST)
{
BOOST_MESSAGE("starting coord transform to cartesian");
const double PI = 3.14159265358979323846;
for (int i = 1; i < 5; ++i)
{
Point p1(i*10, i/10);
Point center(-i, i);
Point transform = p1.CoordTransToCart( center, cos(PI/i), sin(PI/i) );
Point check = p1.Rotate( cos(PI/i), sin(PI/i) );
BOOST_REQUIRE( transform.GetX() == check.GetX() - i &&
transform.GetY() == check.GetY() + i );
}
BOOST_MESSAGE("starting coord transform to cartesian");
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -136,7 +136,8 @@ enum AgentColorMode {
BY_VELOCITY=1,
BY_KNOWLEDGE,
BY_ROUTE,
BY_SPOTLIGHT
BY_SPOTLIGHT,
//BY_GROUP
};
//global functions for convenience
......
......@@ -12,7 +12,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8">
<file location="big_room_trrajectories.xml" />
<!--<socket hostname="127.0.0.1" port="8989"/> -->
<socket hostname="127.0.0.1" port="8989"/>
</trajectories>
<!-- where to store the logs -->
<!--<logfile>outputfiles/log.txt</logfile> -->
......@@ -70,7 +70,8 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!--persons information and distribution -->
<agents operational_model_id="2">
<agents_distribution>
<group group_id="0" room_id="0" subroom_id="0" number="500" router_id="1" agent_parameter_id="1" />
<group group_id="0" room_id="0" subroom_id="0" number="50" router_id="1" agent_parameter_id="1"
risk_tolerance_mean="0.8" risk_tolerance_sigma="0.01"/>
</agents_distribution>
</agents>
......
......@@ -12,7 +12,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8">
<file location="testSchulTrajectories.xml" />
<!-- <socket hostname="127.0.0.1" port="8989"/> -->
<socket hostname="127.0.0.1" port="8989"/>
</trajectories>
<!-- where to store the logs -->
<!--<logfile>outputfiles/log.txt</logfile> -->
......
<?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>
<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">
<!-- seed used for initialising random generator -->
<seed>1254</seed>
<max_sim_time>200</max_sim_time>
<!-- geometry file -->
<geometry>RiMEATest1_geo.xml</geometry>
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8">
<file location="RiMEATest1_traj.xml" />
<!--<socket hostname="127.0.0.1" port="8989"/> -->
</trajectories>
<!-- where to store the logs -->
<!--<logfile>log.txt</logfile> -->
<!-- traffic information: e.g closed doors -->
<traffic_constraints>
</traffic_constraints>
<routing>
</routing>
<!--persons information and distribution -->
<agents operational_model_id="1">
<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>
<model operational_model_id="1" description="gcfm">
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exit_crossing_strategy>4</exit_crossing_strategy>
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="0.3" 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="1">
<v0 mu="1.33" 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>
<agent_parameters agent_parameter_id="2">
<v0 mu="0.5" 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>
<exit_crossing_strategy>3</exit_crossing_strategy>
<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="1">
<v0 mu="1.33" sigma="0.05" />
<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>
<agent_parameters agent_parameter_id="2">
<v0 mu="0" 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>
</operational_models>
<route_choice_models>
<router router_id="1" description="global_shortest">
<parameters>
</parameters>
</router>
</route_choice_models>
</JuPedSim>
<?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="1.05" py="6.0" />
<vertex px="0.0" py="6.0" />
<vertex px="0.0" py="11.0" />
<vertex px="3.0" py="11.0" />
<vertex px="3.0" py="6.0" />
<vertex px="1.95" py="6.0" />
</polygon>
</subroom>
<subroom id="1" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="4.05" py="6.0" />
<vertex px="3.0" py="6.0" />
<vertex px="3.0" py="11.0" />
<vertex px="6.0" py="11.0" />
<vertex px="6.0" py="6.0" />
<vertex px="4.95" py="6.0" />
</polygon>
</subroom>
<subroom id="2" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="7.65" py="6.0" />
<vertex px="7.2" py="6.0" />
<vertex px="7.2" py="11.0" />
<vertex px="9.0" py="11.0" />
<vertex px="9.0" py="6.0" />
<vertex px="8.55" py="6.0" />
</polygon>
</subroom>
<subroom id="3" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="10.05" py="6.0" />
<vertex px="9.0" py="6.0" />
<vertex px="9.0" py="11.0" />
<vertex px="12.0" py="11.0" />
<vertex px="12.0" py="6.0" />
<vertex px="10.95" py="6.0" />
</polygon>
</subroom>
<subroom id="4" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="13.05" py="6.0" />
<vertex px="12.0" py="6.0" />
<vertex px="12.0" py="11.0" />
<vertex px="15.0" py="11.0" />
<vertex px="15.0" py="6.0" />
<vertex px="13.95" py="6.0" />
</polygon>
</subroom>
<subroom id="5" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="16.05" py="6.0" />
<vertex px="15.0" py="6.0" />
<vertex px="15.0" py="11.0" />
<vertex px="18.0" py="11.0" />
<vertex px="18.0" py="6.0" />
<vertex px="16.95" py="6.0" />
</polygon>
</subroom>
<subroom id="6" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="1.05" py="5.0" />
<vertex px="0.0" py="5.0" />
<vertex px="0.0" py="0.0" />
<vertex px="3.0" py="0.0" />
<vertex px="3.0" py="5.0" />
<vertex px="1.95" py="5.0" />
</polygon>
</subroom>
<subroom id="7" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="4.05" py="5.0" />
<vertex px="3.0" py="5.0" />
<vertex px="3.0" py="0.0" />
<vertex px="6.0" py="0.0" />
<vertex px="6.0" py="5.0" />
<vertex px="4.95" py="5.0" />
</polygon>
</subroom>
<subroom id="8" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="7.05" py="5.0" />
<vertex px="6.0" py="5.0" />
<vertex px="6.0" py="0.0" />
<vertex px="9.0" py="0.0" />
<vertex px="9.0" py="5.0" />
<vertex px="7.95" py="5.0" />
</polygon>
</subroom>
<subroom id="9" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="10.05" py="5.0" />
<vertex px="9.0" py="5.0" />
<vertex px="9.0" py="0.0" />
<vertex px="12.0" py="0.0" />
<vertex px="12.0" py="5.0" />
<vertex px="10.95" py="5.0" />
</polygon>
</subroom>
<subroom id="10" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="13.05" py="5.0" />
<vertex px="12.0" py="5.0" />
<vertex px="12.0" py="0.0" />
<vertex px="15.0" py="0.0" />
<vertex px="15.0" py="5.0" />
<vertex px="13.95" py="5.0" />
</polygon>
</subroom>
<subroom id="11" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="16.05" py="5.0" />
<vertex px="15.0" py="5.0" />
<vertex px="15.0" py="0.0" />
<vertex px="18.0" py="0.0" />
<vertex px="18.0" py="5.0" />
<vertex px="16.95" py="5.0" />
</polygon>
</subroom>
<subroom id="12" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="6.0" py="11.0" />
<vertex px="6.0" py="6.0" />
<vertex px="4.95" py="6.0" />
</polygon>
<polygon caption="wall">
<vertex px="4.05" py="6.0" />
<vertex px="1.95" py="6.0" />
</polygon>
<!-- <polygon caption="wall">
<vertex px="1.05" py="6.0" />
<vertex px="0.0" py="6.0" />
<vertex px="0.0" py="5.0" />
<vertex px="1.05" py="5.0" />
</polygon> -->
<polygon caption="wall">
<vertex px="18.0" py="6.0" />
<vertex px="16.95" py="6.0" />
</polygon>
<polygon caption="wall">
<vertex px="16.05" py="6.0" />
<vertex px="13.95" py="6.0" />
</polygon>
<polygon caption="wall">
<vertex px="13.05" py="6.0" />
<vertex px="10.95" py="6.0" />
</polygon>
<polygon caption="wall">
<vertex px="10.05" py="6.0" />
<vertex px="8.55" py="6.0" />
</polygon>
<polygon caption="wall">
<vertex px="7.65" py="6.0" />
<vertex px="7.2" py="6.0" />
<vertex px="7.2" py="11.0" />
</polygon>
<polygon caption="wall">
<vertex px="1.05" py="6.0" />
<vertex px="0.0" py="6.0" />
<vertex px="0.0" py="5.0" />
<vertex px="1.05" py="5.0" />
</polygon>
<polygon caption="wall">
<vertex px="1.95" py="5.0" />
<vertex px="4.05" py="5.0" />
</polygon>
<polygon caption="wall">
<vertex px="4.95" py="5.0" />
<vertex px="7.05" py="5.0" />
</polygon>
<polygon caption="wall">
<vertex px="7.95" py="5.0" />
<vertex px="10.05" py="5.0" />
</polygon>
<polygon caption="wall">
<vertex px="10.95" py="5.0" />
<vertex px="13.05" py="5.0" />
</polygon>
<polygon caption="wall">
<vertex px="13.95" py="5.0" />
<vertex px="16.05" py="5.0" />
</polygon>
<polygon caption="wall">
<vertex px="16.95" py="5.0" />
<vertex px="18.0" py="5.0" />
</polygon>
</subroom>
<crossings>
<crossing id="0" subroom1_id="0" subroom2_id="12">
<vertex px="1.05" py="6.0" />
<vertex px="1.95" py="6.0" />
</crossing>
<crossing id="1" subroom1_id="1" subroom2_id="12">
<vertex px="4.05" py="6.0" />
<vertex px="4.95" py="6.0" />
</crossing>
<crossing id="2" subroom1_id="2" subroom2_id="12">
<vertex px="7.65" py="6.0" />
<vertex px="8.55" py="6.0" />
</crossing>
<crossing id="3" subroom1_id="3" subroom2_id="12">
<vertex px="10.05" py="6.0" />