Commit 5e655c00 authored by Ulrich Kemloh's avatar Ulrich Kemloh

Refactoring

force Models split in different classes
parent 91adf237
......@@ -146,6 +146,8 @@ set ( source_files
math/ForceModel.cpp
math/Mathematics.cpp
math/ODESolver.cpp
math/GCFMModel.cpp
math/GompertzModel.cpp
mpi/LCGrid.cpp
......@@ -190,6 +192,7 @@ set ( source_files
poly2tri/sweep/cdt.cpp
events/EventManager.cpp
)
set ( header_files
routing/NavMesh.h
routing/DirectionStrategy.h
......@@ -255,6 +258,8 @@ set ( header_files
math/Distribution.h
math/Mathematics.h
math/ODESolver.h
math/GCFMModel.h
math/GompertzModel.h
poly2tri/poly2tri.h
poly2tri/common/shapes.h
......
......@@ -29,6 +29,7 @@
#include "../pedestrian/Pedestrian.h"
#include "../routing/NavMesh.h"
#include "../geometry/SubRoom.h"
#define _USE_MATH_DEFINES
#include <math.h>
......
......@@ -29,6 +29,9 @@
#include "Simulation.h"
#include "math/GCFMModel.h"
#include "math/GompertzModel.h"
using namespace std;
......@@ -47,6 +50,7 @@ Simulation::Simulation()
_iod = new IODispatcher();
_fps=1;
_em=NULL;
//_argsParser=NULL;
}
Simulation::~Simulation()
......@@ -243,15 +247,16 @@ void Simulation::InitArgs(ArgumentParser* args)
s.append(tmp);
switch (solver) {
case 1:
_solver = new EulerSolverLC(_model);
break;
case 2:
_solver = new VelocityVerletSolver(_model);
break;
case 3:
_solver = new LeapfrogSolver(_model);
_solver = new EulerSolver(_model);
break;
//case 2:
// _solver = new VelocityVerletSolver(_model);
// break;
//case 3:
// _solver = new LeapfrogSolver(_model);
// break;
}
_tmax = args->GetTmax();
sprintf(tmp, "\tt_max: %f\n", _tmax);
s.append(tmp);
......
......@@ -233,7 +233,7 @@ void EventManager::getTheEvent(char* c)
string id = "";
string state = "";
for(int i=0; i<20; i++) {
if(c[i]==NULL) {
if( ! c[i]) {
break;
} else if(c[i]==' ') {
split++;
......
......@@ -26,6 +26,8 @@
*/
#include "Building.h"
#include "../geometry/SubRoom.h"
#include "../geometry/Room.h"
#include "../tinyxml/tinyxml.h"
#ifdef _SIMULATOR
......
......@@ -26,9 +26,9 @@
*
*/
#include "Point.h"
#include "Goal.h"
#include "Wall.h"
#include "Point.h"
using namespace std;
......
......@@ -31,9 +31,12 @@
#include <string>
#include <vector>
#include "Point.h"
//forward declarations
class Wall;
class Point;
class Goal {
......
......@@ -27,6 +27,7 @@
#include "Hline.h"
#include "SubRoom.h"
using namespace std;
......
......@@ -28,6 +28,7 @@
//#include "SubRoom.h"
#include "../general/Macros.h"
#include "Line.h"
#include "../IO/OutputHandler.h"
......
......@@ -29,11 +29,13 @@
#define _LINE_H
#include "Point.h"
//#include "SubRoom.h"
#include "../IO/OutputHandler.h"
#include <string>
//forward declarations
class OutputHandler;
// external variables
extern OutputHandler* Log;
......
......@@ -32,9 +32,10 @@
#include <string>
#include <vector>
#include "Point.h"
#include "Wall.h"
//forward declarations
class Point;
class Wall;
class Line;
class Obstacle {
......
......@@ -26,6 +26,9 @@
#include "Room.h"
#include "SubRoom.h"
#include "../IO/OutputHandler.h"
#include <sstream>
using namespace std;
......
......@@ -28,9 +28,15 @@
#include <string>
#include <algorithm>
#include "../general/Macros.h"
#include "../geometry/SubRoom.h"
//class SubRoom;
//forward declarations
class OutputHandler;
class SubRoom;
// external variables
extern OutputHandler* Log;
class Room {
private:
......
......@@ -26,11 +26,15 @@
*
*/
#include "Point.h"
#include "Line.h"
#include "Wall.h"
#include "Obstacle.h"
#include "SubRoom.h"
#include "Transition.h"
#include "Hline.h"
#include "Wall.h"
#ifdef _SIMULATOR
#include "../pedestrian/Pedestrian.h"
......
......@@ -29,16 +29,21 @@
#define _SUBROOM_H
#include "Line.h"
//#include "Line.h"
#include "Wall.h"
//#include "Point.h"
#include <vector>
#include <string>
//forward declarations
class Transition;
class Hline;
class Obstacle;
class Crossing;
class Line;
class Point;
class Wall;
#ifdef _SIMULATOR
class Pedestrian;
......
......@@ -28,6 +28,7 @@
#include "Transition.h"
#include "Room.h"
#include "SubRoom.h"
#include "../IO/OutputHandler.h"
using namespace std;
......
......@@ -70,7 +70,7 @@
<group group_id="5" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" motivation=""/>
<group group_id="0" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" />
<group group_id="1" room_id="0" subroom_id="1" number="0" goal_id="" router_id="2" route_id="" patience="5"/>
<group group_id="2" room_id="0" number="200" goal_id="-1" router_id="2" patience="5"/>
<group group_id="2" room_id="0" number="1" goal_id="-1" router_id="2" patience="5"/>
<group group_id="3" room_id="0" subroom_id="0" number="0" goal_id="-1" router_id="2" patience="5"/>
</agents_distribution>
</agents>
......
......@@ -2,122 +2,114 @@
<JuPedSim project="JPS-Project" version="0.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ini.xsd">
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<!-- maximal simulation time -->
<max_sim_time unit="sec">900</max_sim_time>
<!-- geometry file -->
<geometry>bateau.xml</geometry>
<!-- trajectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="8">
<!-- <file location="trajectories.xml" /> -->
<socket hostname="127.0.0.1" port="8989"/>
</trajectories>
<!-- where to store the logs -->
<logfile>log.txt</logfile>
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<!-- maximal simulation time -->
<max_sim_time unit="sec">900</max_sim_time>
<!-- geometry file -->
<geometry>bateau_obst.xml</geometry>
<!-- trajectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="8">
<!-- <file location="trajectories.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 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>
<!-- 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>
<door trans_id="3" caption="" state="open" />
<door trans_id="4" caption="" state="open" />
<door trans_id="6" caption="" state="open" />
</doors>
</traffic_constraints>
<door trans_id="4" caption="" state="open" />
<door trans_id="6" caption="" state="open" />
</doors>
</traffic_constraints>
<routing>
<goals_>
<goal id="0" final="false" caption="goal 1">
<polygon>
<vertex px="-5.0" py="-5.0" />
<vertex px="-5.0" py="-2.0" />
<vertex px="-3.0" py="-2.0" />
<vertex px="-3.0" py="-5.0" />
<vertex px="-5.0" py="-5.0" />
</polygon>
</goal>
<goal id="1" final="false" caption="goal 2">
<polygon>
<vertex px="15.0" py="-5.0" />
<vertex px="17.0" py="-5.0" />
<vertex px="17.0" py="-7.0" />
<vertex px="15.0" py="-7.0" />
<vertex px="15.0" py="-5.0" />
</polygon>
</goal>
<goal id="2" final="true" caption="goal 3">
<polygon>
<vertex px="20.0" py="17.0" />
<vertex px="22.0" py="17.0" />
<vertex px="22.0" py="15.0" />
<vertex px="20.0" py="15.0" />
<vertex px="20.0" py="17.0" />
</polygon>
</goal>
</goals_>
<routing>
<goals_>
<goal id="0" final="false" caption="goal 1">
<polygon>
<vertex px="-5.0" py="-5.0" />
<vertex px="-5.0" py="-2.0" />
<vertex px="-3.0" py="-2.0" />
<vertex px="-3.0" py="-5.0" />
<vertex px="-5.0" py="-5.0" />
</polygon>
</goal>
<goal id="1" final="false" caption="goal 2">
<polygon>
<vertex px="15.0" py="-5.0" />
<vertex px="17.0" py="-5.0" />
<vertex px="17.0" py="-7.0" />
<vertex px="15.0" py="-7.0" />
<vertex px="15.0" py="-5.0" />
</polygon>
</goal>
<goal id="2" final="true" caption="goal 3">
<polygon>
<vertex px="20.0" py="17.0" />
<vertex px="22.0" py="17.0" />
<vertex px="22.0" py="15.0" />
<vertex px="20.0" py="15.0" />
<vertex px="20.0" py="17.0" />
</polygon>
</goal>
</goals_>
</routing>
</routing>
<!--persons information and distribution -->
<agents>
<agents_distribution>
<group group_id="5" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" motivation=""/>
<group group_id="0" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" />
<group group_id="1" room_id="0" subroom_id="1" number="0" goal_id="" router_id="2" route_id="" patience="5"/>
<group group_id="2" room_id="0" number="1" goal_id="-1" router_id="2" patience="40"/>
<group group_id="3" room_id="1" subroom_id="1" number="10" goal_id="-1" router_id="2" patience="20"/>
</agents_distribution>
</agents>
<!--persons information and distribution -->
<agents>
<agents_distribution>
<group group_id="5" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" motivation=""/>
<group group_id="0" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" />
<group group_id="1" room_id="0" subroom_id="1" number="0" goal_id="" router_id="2" route_id="" patience="5"/>
<group group_id="2" room_id="0" number="2" goal_id="-1" router_id="2" patience="40"/>
<group group_id="3" room_id="1" subroom_id="1" number="0" goal_id="-1" router_id="2" patience="20"/>
</agents_distribution>
</agents>
<!-- These parameters may be overwritten -->
<operational_models>
<model id="2" description="gompertz">
<parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exitCrossingStrategy>3</exitCrossingStrategy>
<linkedcells enabled="true" cell_size="2.2" />
<v0 mu="1.2" sigma="0.0" />
<bmax mu="0.25" sigma="0.01" />
<bmin mu="0.20" sigma="0.01" />
<amin mu="0.22" sigma="0.02" />
<tau mu="0.5" sigma="0.00" />
<atau mu="0.1" sigma="0.01" />
<force_ped nu="3" />
<force_wall nu="7" />
</parameters>
</model>
<!-- These parameters may be overwritten -->
<operational_models>
<model id="2" description="gompertz">
<parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exitCrossingStrategy>3</exitCrossingStrategy>
<linkedcells enabled="true" cell_size="2.2" />
<v0 mu="1.2" sigma="0.0" />
<bmax mu="0.25" sigma="0.01" />
<bmin mu="0.20" sigma="0.01" />
<amin mu="0.22" sigma="0.02" />
<tau mu="0.5" sigma="0.00" />
<atau mu="0.1" sigma="0.01" />
<force_ped nu="3" />
<force_wall nu="7" />
</parameters>
</model>
</operational_models>
</operational_models>
<route_choice_models>
<router router_id="2" description="quickest">
<parameters>
<!-- extra routing information -->
<navigation_lines file="routing.xml" />
</parameters>
</router>
<route_choice_models>
<router router_id="2" description="quickest">
<parameters>
<!-- extra routing information -->
<navigation_lines file="routing_obst.xml" />
</parameters>
</router>
<!--
<router router_id="1" description="global_shortest">
<parameters>
<navigation_lines file="routing.xml" />
</parameters>
</router>
<!--
<router router_id="3" description="nav_mesh">
<parameters>
<decomposition method="triangulation" />
<mesh_file file="bla.nav"/>
</parameters>
</router>
<router router_id="1" description="global_shortest">
<parameters>
<navigation_lines file="routing.xml" />
</parameters>
</router>
-->
</route_choice_models>
</route_choice_models>
</JuPedSim>
This diff is collapsed.
......@@ -28,18 +28,15 @@
* @date Tue Apr 15 19:19:04 2014
*/
//
#ifndef _FORCEMODEL_H
#define _FORCEMODEL_H
#include <vector>
#include "../geometry/Building.h"
#include <string>
class Pedestrian;
class DirectionStrategy;
//forward declaration
class Building;
/**
......@@ -48,25 +45,21 @@ class DirectionStrategy;
* @brief The operative model. Definition of several force-based models
* for ped pedestrians dynamics
*
*
*/
class ForceModel {
public:
// Konstruktoren
// constructor/destructor
ForceModel();
virtual ~ForceModel();
//FIXME: remove
virtual void CalculateForce(double time, std::vector< Point >& result_acc, Building* building, int roomID, int SubRoomID) const = 0;
/**
* Solve the differential equations and update the positions and veloities
* @param t the actual time
* @param tp the next timestep
* @param building the geometry object
*/
virtual void CalculateForceLC(double t, double tp, Building* building) const = 0;
virtual void CalculateForce(double t, double tp, Building* building) const = 0;
/**
* @return all model parameters in a nicely formatted string
......@@ -74,242 +67,5 @@ public:
virtual std::string writeParameter() const = 0;
};
/************************************************************
GCFM ForceModel
************************************************************/
/**
* @date Fri Apr 18 16:39:13 2014
*
* @brief The Generalized Centrifugal Force Model
*
*
*/
class GCFMModel : public ForceModel {
private:
/// define the strategy for crossing a door (used for calculating the driving force)
DirectionStrategy* _direction;
// Modellparameter
double _nuPed; /**< strength of the pedestrian repulsive force */
double _nuWall; /**< strength of the wall repulsive force */
double _intp_widthPed; /**< Interpolation cutoff radius (in cm) */
double _intp_widthWall; /**< Interpolation cutoff radius (in cm) */
double _maxfPed;
double _maxfWall;
double _distEffMaxPed; // maximal effective distance
double _distEffMaxWall; // maximal effective distance
// Private Funktionen
/**
* Driving force \f$ F_i =\frac{\mathbf{v_0}-\mathbf{v_i}}{\tau}\f$
*
* @param ped Pointer to Pedestrians
* @param room Pointer to Room
*
* @return Point
*/
Point ForceDriv(Pedestrian* ped, Room* room) const;
/**
* Repulsive force between two pedestrians ped1 and ped2 according to
* the Generalized Centrifugal Force Model (chraibi2010a)
*
* @param ped1 Pointer to Pedestrian: First pedestrian
* @param ped2 Pointer to Pedestrian: Second pedestrian
*
* @return Point
*/
Point ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const;
/**
* Repulsive force acting on pedestrian <ped> from the walls in
* <subroom>. The sum of all repulsive forces of the walls in <subroom> is calculated
* @see ForceRepWall
* @param ped Pointer to Pedestrian
* @param subroom Pointer to SubRoom
*
* @return
*/
Point ForceRepRoom(Pedestrian* ped, SubRoom* subroom) const;
Point ForceRepWall(Pedestrian* ped, const Wall& l) const;
Point ForceRepStatPoint(Pedestrian* ped, const Point& p, double l, double vn) const;
Point ForceInterpolation(double v0, double K_ij, const Point& e, double v, double d, double r, double l) const;
public:
GCFMModel(DirectionStrategy* dir, double nuped, double nuwall, double dist_effPed, double dist_effWall,
double intp_widthped, double intp_widthwall, double maxfped, double maxfwall);
virtual ~GCFMModel(void);
// Getter
DirectionStrategy* GetDirection() const;
double GetNuPed() const;
double GetNuWall() const;
double GetDistEffMax() const;
double GetIntpWidthPed() const;
double GetIntpWidthWall() const;
double GetMaxFPed() const;
double GetMaxFWall() const;
double GetDistEffMaxPed() const;
double GetDistEffMaxWall() const;
//void UpdateCellularModel(Building* building) const;
// virtuelle Funktionen
virtual void CalculateForce(double time, std::vector< Point >& result_acc, Building* building,
int roomID, int SubRoomID) const;
virtual void CalculateForceLC(double t, double tp, Building* building) const;
virtual std::string writeParameter() const;
};
/************************************************************
GOMPERTZ ForceModel
************************************************************/
/**
* Class defining the Gompertz model
*
*
* @brief The Gompertz model. Not yet published.
*/
class GompertzModel : public ForceModel {
private:
/// define the strategy for crossing a door (used for calculating the driving force)
DirectionStrategy* _direction;
/// Modellparameter
double _nuPed;
double _aPed;
double _bPed;
double _cPed;
double _nuWall;
double _aWall;
double _bWall;