Commit ca5d3c6b authored by Arne Graf's avatar Arne Graf

FF save and recover

parent 9a4ce19c
Utest/test_13/flow.png

41.4 KB | W: | H:

Utest/test_13/flow.png

41 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
......@@ -46,9 +46,9 @@
</routing>
<!--persons information and distribution -->
<agents operational_model_id="1">
<agents operational_model_id="3">
<agents_distribution>
<group group_id="2" agent_parameter_id="1" room_id="1" subroom_id="0" number="10" goal_id="0" router_id="1"/>
<group group_id="2" agent_parameter_id="1" room_id="1" subroom_id="0" number="30" goal_id="0" router_id="1"/>
<!-- <group group_id="0" room_id="1" subroom_id="0" number="4" goal_id="0" router_id="1" route_id="" /> -->
<!-- <group group_id="1" room_id="1" number="10" goal_id="0" router_id="1" route_id="" /> -->
</agents_distribution>
......@@ -105,6 +105,26 @@
</agent_parameters>
</model>
<model operational_model_id="3" description="gradnav">
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exit_crossing_strategy>6</exit_crossing_strategy>
<floorfield delta_h="0.0625" wall_avoid_distance="0.5" use_wall_avoidance="true" />
<linkedcells enabled="true" cell_size="4.2" />
<force_ped nu="3" b="1.0" c="3.0" />
<force_wall nu="1" b="0.70" c="3.0" />
<anti_clipping slow_down_distance="1." />
</model_parameters>
<agent_parameters agent_parameter_id="1">
<v0 mu="1.24" 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.1" sigma="0.001" />
</agent_parameters>
</model>
</operational_models>
<route_choice_models>
......
......@@ -232,6 +232,10 @@ void GradientModel::ComputeNextTimeStep(double current, double deltaT, Building*
movDirection = (movDirection + toTarget);
movDirection = (movDirection.Norm() > 1.) ? movDirection.Normalized() : movDirection;
// if (movDirection.Norm() < .6) {
// std::cerr << ".6 unterschritten" << std::endl;
// }
double desired_speed = ped->GetV0Norm();
Point oldMov = Point(0., 0.);
if (desired_speed > 0.) {
......@@ -244,7 +248,7 @@ void GradientModel::ComputeNextTimeStep(double current, double deltaT, Building*
movDirection = oldMov - diff;
movDirection = (movDirection.Norm() > 1.) ? movDirection.Normalized() : movDirection;
//slowdown near wall mechanics:
//redirect near wall mechanics:
Point dir2Wall = dynamic_cast<DirectionFloorfield*>(_direction)->GetDir2Wall(ped);
double distance2Wall = dynamic_cast<DirectionFloorfield*>(_direction)->GetDistance2Wall(ped);
double dotProduct = 0;
......@@ -254,13 +258,18 @@ void GradientModel::ComputeNextTimeStep(double current, double deltaT, Building*
if ((dotProduct > 0) && (distance2Wall < .5 * _slowDownDistance)) { //acute angle && really close to wall
movDirection = movDirection - (dir2Wall*dotProduct); //remove walldirection from movDirection
}
//antiClippingFactor = ( 1 - .5*(dotProduct + fabs(dotProduct)) );
antiClippingFactor = ( 1 - .5*(dotProduct + fabs(dotProduct)) );
}
movDirection = movDirection * (antiClippingFactor * ped->GetV0Norm() * deltaT);
// if ((dotProduct != 0) && (movDirection.Norm() < 0.6 * antiClippingFactor * ped->GetV0Norm() * deltaT)) {
// std::cerr << "@@@@@ " << dotProduct << std::endl;
// }
//if(ped->GetID() == 48) { // Mohcine
// fprintf(stderr, "%f %f %f %f %f %f %f \n", movDirection.GetX(), movDirection.GetY(), ped->GetV().GetX(), ped->GetV().GetY(), ped->GetPos().GetX(), ped->GetPos().GetY(), current);
//}
......
......@@ -35,6 +35,7 @@
#include "../geometry/Wall.h"
#include "../routing/FloorfieldViaFM.h"
#include "DirectionStrategy.h"
#include <fstream>
......@@ -287,7 +288,12 @@ double DirectionFloorfield::GetDistance2Wall(Pedestrian* ped) const
void DirectionFloorfield::Init(Building* building, double stepsize, double threshold, bool useDistancMap) {
//implement mechanic, that can read-in an existing floorfield (from a previous run)
ffviafm = new FloorfieldViaFM(building, stepsize, stepsize, threshold, useDistancMap);
std::ifstream test(("FF"+building->GetGeometryFilename() + ".vtk").c_str());
if (test.good()) {
ffviafm = new FloorfieldViaFM(("FF"+building->GetGeometryFilename() + ".vtk").c_str());
} else {
ffviafm = new FloorfieldViaFM(building, stepsize, stepsize, threshold, useDistancMap);
}
initDone = true;
}
......
......@@ -55,6 +55,9 @@ FloorfieldViaFM::~FloorfieldViaFM()
FloorfieldViaFM::FloorfieldViaFM(const Building* const buildingArg, const double hxArg, const double hyArg,
const double slowdownDistance, const bool useDistancefield) {
std::cerr << "Bin im old constructor" << std::endl;
std::cout << "Bin im old constructor" << std::endl;
//ctor
threshold = -1; //negative value means: ignore threshold
threshold = slowdownDistance;
......@@ -82,9 +85,10 @@ FloorfieldViaFM::FloorfieldViaFM(const Building* const buildingArg, const double
calculateFloorfield(useDistancefield); //use distance2Wall
testoutput("AAFloorfield.vtk","AAFloorfield.txt", cost);
writeFF(("FF" + buildingArg->GetGeometryFilename() + ".vtk").c_str());
}
FloorfieldViaFM::FloorfieldViaFM(const char* filename) {
FloorfieldViaFM::FloorfieldViaFM(const std::string& filename) {
// FileHeaderExample: (GEO_UP_SCALE is assumed to be 1.0)
// # vtk DataFile Version 3.0
......@@ -102,34 +106,106 @@ FloorfieldViaFM::FloorfieldViaFM(const char* filename) {
// 0.505725
// ...
// comments show lineformat in .vtk file (below)
std::cerr << "Bin im read file constructor" << std::endl;
std::cout << "Bin im read file constructor" << std::endl;
std::ifstream file(filename);
std::string line;
std::getline(file, line); //# vtk DataFile Version 3.0
std::getline(file, line);
//read header and extract grid info:
//iMax jMax (->numPoints)
//xMin yMin
//hx hy (->xMax yMax via formula xMax = xMin + hx * iMax)
std::getline(file, line); //Testdata: Fast Marching: Test:
std::getline(file, line); //ASCII
std::getline(file, line); //DATASET STRUCTURED_POINTS
std::getline(file, line); //DIMENSIONS {x} {y} {z}
std::stringstream inputline(line);
long int iMax, jMax, c;
std::string dummy;
double fdummy;
long int nPoints;
double xMin;
double yMin;
double xMax;
double yMax;
double hx;
double hy;
inputline >> dummy >> iMax >> jMax >> c ;
std::getline(file, line); //ORIGIN x y z
inputline.str("");
inputline.clear();
inputline << line;
inputline >> dummy >> xMin >> yMin >> c;
std::getline(file, line); //SPACING 0.062500 0.062500 1
inputline.str("");
inputline.clear();
inputline << line;
inputline >> dummy >> hx >> hy >> c;
xMax = xMin + hx*iMax;
yMax = yMin + hy*jMax;
std::getline(file, line); //POINT_DATA 72772
inputline.str("");
inputline.clear();
inputline.flush();
inputline << line;
inputline >> dummy >> nPoints;
// std::cerr << inputline.str() << std::endl;
// std::cerr << hx << std::endl;
// std::cerr << hy << std::endl;
// std::cerr << iMax << std::endl;
// std::cerr << jMax << std::endl;
// std::cerr << xMin << std::endl;
// std::cerr << yMin << std::endl;
//create grid
//create arrays
//read-in dist2Wall
//create Rect Grid
grid = new RectGrid(nPoints, xMin, yMin, xMax, yMax, hx, hy, iMax, jMax, true);
//read-in neggrad
//create arrays
flag = new int[nPoints]; //flag:( 0 = unknown, 1 = singel, 2 = double, 3 = final, -7 = outside)
dist2Wall = new double[nPoints];
speedInitial = new double[nPoints];
cost = new double[nPoints];
neggrad = new Point[nPoints];
dirToWall = new Point[nPoints];
trialfield = new Trial[nPoints]; //created with other arrays, but not initialized yet
std::getline(file, line); //SCALARS Cost float 1
std::getline(file, line); //LOOKUP_TABLE default
for (long int i = 0; i < nPoints; ++i) {
std::getline(file, line);
inputline.str("");
inputline << line;
inputline >> dist2Wall[i]; //0.505725
//std::cerr << dist2Wall[i] << std::endl;
inputline.clear();
}
//read-in dirToWall
std::getline(file, line); //VECTORS Gradient float
while (std::getline(file, line))
{
std::istringstream iss(line);
for (long int i = 0; i < nPoints; ++i) {
std::getline(file, line);
inputline.str("");
inputline << line;
inputline >> neggrad[i]._x >> neggrad[i]._y >> fdummy; //0.989337 7.88255 0.0
inputline.clear();
}
//int a, b;
// if (!(iss >> a >> b)) { break; } // error
std::getline(file, line); //VECTORS Gradient float
// process pair (a,b)
for (long int i = 0; i < nPoints; ++i) {
std::getline(file, line);
inputline.str("");
inputline << line;
inputline >> dirToWall[i]._x >> dirToWall[i]._y >> fdummy; //0.989337 7.88255 0.0
inputline.clear();
}
}
......@@ -974,7 +1050,7 @@ void FloorfieldViaFM::writeFF(const char* filename) {
file << "ORIGIN " << grid->GetxMin()/GEO_UP_SCALE << " " << grid->GetyMin()/GEO_UP_SCALE << " 0" << std::endl;
file << "SPACING " << std::to_string(grid->Gethx()/GEO_UP_SCALE) << " " << std::to_string(grid->Gethy()/GEO_UP_SCALE) << " 1" << std::endl;
file << "POINT_DATA " << std::to_string(numTotal) << std::endl;
file << "SCALARS Cost float 1" << std::endl;
file << "SCALARS Dist2Wall float 1" << std::endl;
file << "LOOKUP_TABLE default" << std::endl;
for (long int i = 0; i < grid->GetnPoints(); ++i) {
file << dist2Wall[i]/GEO_UP_SCALE << std::endl; //@todo: change target to all dist2wall
......
......@@ -51,7 +51,7 @@ class FloorfieldViaFM
{
public:
FloorfieldViaFM();
FloorfieldViaFM(const char*);
FloorfieldViaFM(const std::string&);
FloorfieldViaFM(const Building* const buildingArg, const double hxArg, const double hyArg, const double slowdownDistance, const bool useDistancefield);
virtual ~FloorfieldViaFM();
FloorfieldViaFM(const FloorfieldViaFM& other);
......
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