Commit 2e4fbc58 authored by qiancheng xu's avatar qiancheng xu

1.Add <GCVM using="1" /> in inifile when using GCVMModel, to control using GCVM or CVM

2.Add a new model AGCVMModel (Anticipation generalized collision-free velocity model) (Will be implemented)
parent f3f3c871
......@@ -320,7 +320,7 @@ math/VelocityModel.cpp
math/OperationalModel.cpp
math/GCVMModel.cpp
math/SimplestModel.cpp
math/AGCVMModel.cpp
mpi/LCGrid.cpp
pedestrian/Ellipse.cpp
......@@ -550,7 +550,7 @@ math/VelocityModel.h
math/OperationalModel.h
math/GCVMModel.h
math/SimplestModel.h
math/AGCVMModel.h
events/EventManager.h
events/Event.h
......
......@@ -41,6 +41,7 @@
#include "../math/VelocityModel.h"
#include "../math/GCVMModel.h"
#include "../math/SimplestModel.h"
#include "../math/AGCVMModel.h"
#include "../routing/global_shortest/GlobalRouter.h"
#include "../routing/quickest/QuickestPathRouter.h"
#include "../routing/smoke_router/SmokeRouter.h"
......@@ -557,10 +558,21 @@ bool IniFileParser::Parse(std::string iniFile)
//only parsing one model
break;
}
if ((_model == MODEL_AGCVM) && (model_id == MODEL_AGCVM)) {
if (modelName != "agcvm") {
Log->Write("ERROR: \t mismatch model ID and description. Did you mean agcvm?");
return false;
}
if (!ParseGCVMModel(xModel, xMainNode))
return false;
parsingModelSuccessful = true;
//only parsing one model
break;
}
}
if (!parsingModelSuccessful) {
Log->Write("ERROR: \tWrong model id [%d]. Choose 1 (GCFM), 2 (Gompertz), 3 (Tordeux2015), 5 (Krausz), 6 (GCVM) or 7 (Simplest)", _model);
Log->Write("ERROR: \tWrong model id [%d]. Choose 1 (GCFM), 2 (Gompertz), 3 (Tordeux2015), 5 (Krausz), 6 (GCVM), 7 (Simplest), 8 (AGCVM)", _model);
Log->Write("ERROR: \tPlease make sure that all models are specified in the operational_models section");
Log->Write("ERROR: \tand make sure to use the same ID in the agent section");
return false;
......@@ -1290,6 +1302,12 @@ void IniFileParser::ParseAgentParameters(TiXmlElement* operativModel, TiXmlNode*
_config->SetDistEffMaxPed(max_Eb + _config->GetTs()*agentParameters->GetV0());
_config->SetDistEffMaxWall(_config->GetDistEffMaxPed());
}
if (_model == 8) { // AGCVM
double max_Eb = 2 * agentParameters->GetBmax();
_config->SetDistEffMaxPed(max_Eb + _config->GetTs()*agentParameters->GetV0());
_config->SetDistEffMaxWall(_config->GetDistEffMaxPed());
}
}
}
}
......@@ -2000,7 +2018,7 @@ bool IniFileParser::ParseGCVMModel(TiXmlElement* xGCVM, TiXmlElement* xMainNode)
if (xModelPara->FirstChild("GCVM")) {
if (!xModelPara->FirstChildElement("GCVM")->Attribute("using"))
_config->SetGCVMUsing(0);
_config->SetGCVMUsing(1);
else {
string GCVMUsing = xModelPara->FirstChildElement("GCVM")->Attribute("using");
_config->SetGCVMUsing(atoi(GCVMUsing.c_str()));
......@@ -2177,13 +2195,145 @@ bool IniFileParser::ParseSimplestModel(TiXmlElement* xSimplest, TiXmlElement* xM
Log->Write("INFO: \twaiting_time Tw=%0.2f",_config->GetWaitingTime());
}
if (xModelPara->FirstChild("clogging_area")) {
if (!xModelPara->FirstChildElement("clogging_area")->Attribute("size"))
_config->SetAreaSize(1); // default value
else {
string AreaSize = xModelPara->FirstChildElement("clogging_area")->Attribute("size");
_config->SetAreaSize(atof(AreaSize.c_str()));
}
Log->Write("INFO: \tclogging_area size=%0.2f", _config->GetAreaSize());
}
//Parsing the agent parameters
TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
ParseAgentParameters(xSimplest, xAgentDistri);
_config->SetModel(std::shared_ptr<OperationalModel>(new SimplestModel(_exit_strategy, _config->GetaPed(),
_config->GetDPed(), _config->GetaWall(),
_config->GetDWall(), _config->GetTs(), _config->GetTd(), _config->GetUpdate(), _config->GetWaitingTime(), _config->GetSubmodelDirection(), _config->GetSubmodelSpeed(), _config->GetGCVMUsing())));
_config->GetDWall(), _config->GetTs(), _config->GetTd(), _config->GetUpdate(), _config->GetWaitingTime(), _config->GetAreaSize(), _config->GetSubmodelDirection(), _config->GetSubmodelSpeed(), _config->GetGCVMUsing())));
return true;
}
bool IniFileParser::ParseAGCVMModel(TiXmlElement* xGCVM, TiXmlElement* xMainNode)
{
//parsing the model parameters
Log->Write("\nINFO:\tUsing AGCVM model");
Log->Write("INFO:\tParsing the model parameters");
TiXmlNode* xModelPara = xGCVM->FirstChild("model_parameters");
if (!xModelPara) {
Log->Write("ERROR: \t !!!! Changes in the operational model section !!!");
Log->Write("ERROR: \t !!!! The new version is in inputfiles/ship_msw/ini_ship3.xml !!!");
return false;
}
// For convenience. This moved to the header as it is not model specific
if (xModelPara->FirstChild("tmax")) {
Log->Write("ERROR: \tthe maximal simulation time section moved to the header!!!");
Log->Write("ERROR: \t\t <max_sim_time> </max_sim_time>\n");
return false;
}
//solver
if (!ParseNodeToSolver(*xModelPara))
return false;
//stepsize
if (!ParseStepSize(*xModelPara))
return false;
//exit crossing strategy
if (!ParseStrategyNodeToObject(*xModelPara))
return false;
//linked-cells
if (!ParseLinkedCells(*xModelPara))
return false;
//periodic
if (!ParsePeriodic(*xModelPara))
return false;
//force_ped
if (xModelPara->FirstChild("force_ped")) {
if (!xModelPara->FirstChildElement("force_ped")->Attribute("a"))
_config->SetaPed(3.0); // default value
else {
string a = xModelPara->FirstChildElement("force_ped")->Attribute("a");
_config->SetaPed(atof(a.c_str()));
}
if (!xModelPara->FirstChildElement("force_ped")->Attribute("D"))
_config->SetDPed(0.1); // default value in [m]
else {
string D = xModelPara->FirstChildElement("force_ped")->Attribute("D");
_config->SetDPed(atof(D.c_str()));
}
Log->Write("INFO: \tfrep_ped a=%0.2f, D=%0.2f", _config->GetaPed(), _config->GetDPed());
}
//force_wall
if (xModelPara->FirstChild("force_wall")) {
if (!xModelPara->FirstChildElement("force_wall")->Attribute("a"))
_config->SetaWall(6.0); // default value
else {
string a = xModelPara->FirstChildElement("force_wall")->Attribute("a");
_config->SetaWall(atof(a.c_str()));
}
if (!xModelPara->FirstChildElement("force_wall")->Attribute("D"))
_config->SetDWall(0.05); // default value in [m]
else {
string D = xModelPara->FirstChildElement("force_wall")->Attribute("D");
_config->SetDWall(atof(D.c_str()));
}
Log->Write("INFO: \tfrep_wall a=%0.2f, D=%0.2f", _config->GetaWall(), _config->GetDWall());
}
//time parameters
if (xModelPara->FirstChild("time_parameters")) {
if (!xModelPara->FirstChildElement("time_parameters")->Attribute("Ts"))
_config->SetTs(0.5); // default value
else {
string Ts = xModelPara->FirstChildElement("time_parameters")->Attribute("Ts");
_config->SetTs(atof(Ts.c_str()));
}
if (!xModelPara->FirstChildElement("time_parameters")->Attribute("Td"))
_config->SetTd(0.3); // default value in [m]
else {
string Td = xModelPara->FirstChildElement("time_parameters")->Attribute("Td");
_config->SetTd(atof(Td.c_str()));
}
Log->Write("INFO: \ttime_parameters Ts=%0.2f, Td=%0.2f", _config->GetTs(), _config->GetTd());
if (xModelPara->FirstChild("GCVM")) {
if (!xModelPara->FirstChildElement("GCVM")->Attribute("using"))
_config->SetGCVMUsing(1);
else {
string GCVMUsing = xModelPara->FirstChildElement("GCVM")->Attribute("using");
_config->SetGCVMUsing(atoi(GCVMUsing.c_str()));
}
_config->GetGCVMUsing() == 1 ?
Log->Write("INFO:\tUsing GCVM model") :
Log->Write("INFO:\tUsing CVM model");
}
}
//Parsing the agent parameters
TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
ParseAgentParameters(xGCVM, xAgentDistri);
_config->SetModel(std::shared_ptr<OperationalModel>(new GCVMModel(_exit_strategy, _config->GetaPed(),
_config->GetDPed(), _config->GetaWall(),
_config->GetDWall(), _config->GetTs(), _config->GetTd(), _config->GetGCVMUsing())));
return true;
}
\ No newline at end of file
......@@ -65,6 +65,8 @@ private:
bool ParseGCVMModel(TiXmlElement* xGCVM, TiXmlElement* xMain);
bool ParseSimplestModel(TiXmlElement* xSimplest, TiXmlElement* xMain);
bool ParseAGCVMModel(TiXmlElement* xGCVM, TiXmlElement* xMain);
#ifdef AIROUTER
bool ParseAIOpts(TiXmlNode* routingNode);
#endif
......
......@@ -36,6 +36,7 @@
#include "math/GradientModel.h"
#include "math/GCVMModel.h"
#include "math/SimplestModel.h"
#include "math/AGCVMModel.h"
#include "pedestrian/AgentsQueue.h"
#include "pedestrian/AgentsSourcesManager.h"
#include "geometry/WaitingArea.h"
......
......@@ -104,6 +104,7 @@ public:
_SubmodelDirection = 0;
_SubmodelSpeed = 0;
_GCVMUsing = 0;
_AreaSize = 1;
// ----------------
_hostname = "localhost";
......@@ -381,7 +382,11 @@ public:
void SetGCVMUsing(int gu) { _GCVMUsing=gu; };
int GetGCVMUsing() const { return _GCVMUsing; }
int GetGCVMUsing() const { return _GCVMUsing; };
void SetAreaSize(double as) { _AreaSize = as; };
double GetAreaSize() const { return _AreaSize; };
#ifdef _JPS_AS_A_SERVICE
......@@ -456,6 +461,7 @@ private:
int _SubmodelDirection;
int _SubmodelSpeed;
int _GCVMUsing;
double _AreaSize;
//ff router quickest
double _recalc_interval;
......
......@@ -144,7 +144,8 @@ enum OperativModels {
MODEL_GRADIENT,
MODEL_KRAUSZ,
MODEL_GCVM,
MODEL_SIMPLEST
MODEL_SIMPLEST,
MODEL_AGCVM
// MODEL_ORCA,
// MODEL_CFM,
// MODEL_GNM
......
This diff is collapsed.
/**
* \file AGCVM.h
* \date Jun 26, 2019
* \version v0.8
* \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
* Implementation of first-order model
* Anticipation generalized collision-free velocity model: Qiancheng (8)
*
*
**/
#ifndef AGCVMMODEL_H_
#define AGCVMMODEL_H_
#include <vector>
#include "../geometry/Building.h"
#include "OperationalModel.h"
typedef std::pair<double, double> my_pair;
// sort with respect to first element (ascending).
// In case of equality sort with respect to second element (descending)
struct sort_pred_agcvm
{
bool operator () (const my_pair& left, const my_pair& right)
{
return (left.first == right.first) ?
(left.second > right.second) :
(left.first < right.first);
}
};
//forward declaration
class Pedestrian;
class DirectionStrategy;
class AGCVMModel : public OperationalModel {
private:
/// Modellparameter
double _aPed;
double _DPed;
double _aWall;
double _DWall;
double _Ts;
double _Td;
int _GCVMUsing=1;// Keep it for incase
double OptimalSpeed(Pedestrian* ped, double spacing) const;
/**
* The desired direction of pedestrian
*
* @param ped: Pointer to Pedestrians
* @param room: Pointer to room
*
* @return Point
*/
Point e0(Pedestrian *ped, Room* room) const;
/**
* Get the spacing between ped1 and ped2
*
* @param ped1 Pointer to Pedestrian: First pedestrian
* @param ped2 Pointer to Pedestrian: Second pedestrian
* @param ei the direction of pedestrian.
*
* @return Point
*/
my_pair GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei, int periodic) const;
/**
* Repulsive force between two pedestrians ped1 and ped2
* @param ped1 Pointer to Pedestrian: First pedestrian
* @param ped2 Pointer to Pedestrian: Second pedestrian
*
* @return Point
*/
Point ForceRepPed(Pedestrian* ped1, Pedestrian* ped2, Point e0, int periodic) 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
*/
Point ForceRepRoom(Pedestrian* ped, SubRoom* subroom, Point e0) const;
/**
* Repulsive force between pedestrian <ped> and wall <l>
*
* @param ped Pointer to Pedestrian
* @param l reference to Wall
*
* @return Point
*/
Point ForceRepWall(Pedestrian* ped, const Line& l, const Point& centroid, bool inside, Point e0) const;
double GetSpacingRoom(Pedestrian* ped, SubRoom* subroom, Point ei) const;
double GetSpacingWall(Pedestrian* ped, const Line& l, Point ei) const;
public:
AGCVMModel(std::shared_ptr<DirectionStrategy> dir, double aped, double Dped,
double awall, double Dwall, double Ts, double Td, int GCVM);
virtual ~AGCVMModel(void);
std::shared_ptr<DirectionStrategy> GetDirection() const;
/**
* ToDO: What is this parameter doing?
*
* @return double
*
*/
double GetaPed() const;
/**
* ToDO: What is this parameter doing?
*
* @return double
*/
double GetDPed() const;
/**
* ToDO: What is this parameter doing?
*
* @return double
*/
double GetaWall() const;
/**
* ToDO: What is this parameter doing?
*
* @return double
*/
double GetDWall() const;
/**
* @return all model parameters in a nicely formatted string
*/
virtual std::string GetDescription();
/**
* initialize the phi angle
* @param building
*/
virtual bool Init(Building* building);
/**
* Compute the next simulation step
* Solve the differential equations and update the positions and velocities
* @param current the actual time
* @param deltaT the next timestep
* @param building the geometry object
* @param periodic: used in some utests for periodic scenarios (very specific)
*/
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic);
int GetGCVMU() const;
};
#endif
......@@ -61,7 +61,7 @@ using std::vector;
using std::string;
SimplestModel::SimplestModel(std::shared_ptr<DirectionStrategy> dir, double aped, double Dped,
double awall, double Dwall, double Ts, double Td, int Parallel, double waitingTime, int sDirection, int sSpeed, int GCVMU)
double awall, double Dwall, double Ts, double Td, int Parallel, double waitingTime, double areasize, int sDirection, int sSpeed, int GCVMU)
{
_direction = dir;
// Force_rep_PED Parameter
......@@ -77,6 +77,7 @@ SimplestModel::SimplestModel(std::shared_ptr<DirectionStrategy> dir, double aped
_SubmodelDirection = sDirection;
_SubmodelSpeed = sSpeed;
_GCVMUsing = GCVMU;
_AreaSize = areasize;
}
......@@ -326,7 +327,7 @@ void SimplestModel::ComputeNextTimeStep(double current, double deltaT, Building*
my_pair relation = my_pair(ped->GetID(), first_ID);
const Point& pos = ped->GetPos();
double distGoal = ped->GetExitLine()->DistTo(pos);
double DRange=1;
double DRange=GetAreaSize();
if (UDirection==0||distGoal<DRange)
{
relations.push_back(relation);
......@@ -1121,4 +1122,9 @@ int SimplestModel::GetSSpeed() const
int SimplestModel::GetGCVMU() const
{
return _GCVMUsing;
}
double SimplestModel::GetAreaSize() const
{
return _AreaSize;
}
\ No newline at end of file
......@@ -73,6 +73,7 @@ private:
int _Parallel;
double _WaitingTime;
double _AreaSize;
int _SubmodelDirection;
int _SubmodelSpeed;
......@@ -133,7 +134,7 @@ private:
public:
SimplestModel(std::shared_ptr<DirectionStrategy> dir, double aped, double Dped,
double awall, double Dwall, double Ts, double Td, int Parallel, double waitingTime, int sDirection, int sSpeed, int GCVMU);
double awall, double Dwall, double Ts, double Td, int Parallel, double waitingTime, double areasize, int sDirection, int sSpeed, int GCVMU);
virtual ~SimplestModel(void);
......@@ -198,6 +199,8 @@ public:
int GetSSpeed() const;
int GetGCVMU() const;
double GetAreaSize() const;
};
......
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