Commit f5663c3c authored by Arne Graf's avatar Arne Graf

Merge branch 'develop' into escalator

parents c58f05d5 311f63fa
Pipeline #9332 failed with stages
in 4 minutes and 13 seconds
......@@ -6,8 +6,8 @@ before_script:
- nproc=`grep -c '^processor' /proc/cpuinfo`
- echo "nproc = $nproc"
- export LD_LIBRARY_PATH=$HOME/boost_1_61_0/stage/lib/:$LD_LIBRARY_PATH
#========== Pipeline ==================
stages:
- configure
......@@ -46,7 +46,7 @@ make-linux:
- lib
- lib/Debug
- bin
stage: compile
tags:
- linux
......@@ -54,13 +54,14 @@ make-linux:
- cd build
- make -j$nproc
- echo "compile | ${CI_PROJECT_DIR}"
tags:
- linux
#============== unit_test ============
test:
dependencies:
- make-linux
stage: unit_test
stage: unit_test
script:
- cd build
- ctest -R Boost
......@@ -75,7 +76,7 @@ verification:
script:
- cd build
- ctest -R juelich
only:
only:
- develop
tags:
- linux
......@@ -90,7 +91,7 @@ verification:
# script:
# - cd build
# - ctest -R rimea
# only:
# only:
# - develop
# tags:
# - linux
......@@ -105,7 +106,7 @@ verification:
# script:
# - cd build
# - ctest -R validation
# only:
# only:
# - develop
# tags:
# - linux
......
......@@ -35,7 +35,7 @@
#include "math/GompertzModel.h"
#include "math/GradientModel.h"
#include "pedestrian/AgentsQueue.h"
#include "pedestrian/AgentsSourcesManager.h"
#ifdef _OPENMP
#else
......@@ -61,6 +61,7 @@ Simulation::Simulation(Configuration* args)
_fps = 1;
_em = nullptr;
_gotSources = false;
_maxSimTime = 100;
// _config = args;
}
......@@ -201,6 +202,7 @@ bool Simulation::InitArgs()
sprintf(tmp, "\tt_max: %f\n", _config->GetTmax());
s.append(tmp);
_deltaT = _config->Getdt();
_maxSimTime = _config->GetTmax();
sprintf(tmp, "\tdt: %f\n", _deltaT);
_periodic = _config->IsPeriodic();
sprintf(tmp, "\t periodic: %d\n", _periodic);
......@@ -214,10 +216,11 @@ bool Simulation::InitArgs()
_routingEngine = _config->GetRoutingEngine();
auto distributor = std::unique_ptr<PedDistributor>(new PedDistributor(_config));
// IMPORTANT: do not change the order in the following..
_building = std::unique_ptr<Building>(new Building(_config, *distributor));
_building = std::shared_ptr<Building>(new Building(_config, *distributor));
// Initialize the agents sources that have been collected in the pedestrians distributor
_agentSrcManager.SetBuilding(_building.get());
_agentSrcManager.SetMaxSimTime(GetMaxSimTime());
_gotSources = (bool) distributor->GetAgentsSources().size(); // did we have any sources? false if no sources
for (const auto& src: distributor->GetAgentsSources()) {
_agentSrcManager.AddSource(src);
......@@ -529,12 +532,31 @@ void Simulation::RunFooter()
void Simulation::ProcessAgentsQueue()
{
/* std::cout << "Call Simulation::ProcessAgentsQueue() at: " << Pedestrian::GetGlobalTime() << std::endl; */
/* std::cout << KRED << " SIMULATION building " << _building << " size " << _building->GetAllPedestrians().size() << "\n" << RESET; */
/* for(auto pp: _building->GetAllPedestrians()) */
/* std::cout<< KBLU << "BUL: Simulation: " << pp->GetPos()._x << ", " << pp->GetPos()._y << RESET << std::endl; */
//incoming pedestrians
vector<Pedestrian*> peds;
// std::cout << ">>> peds " << peds.size() << RESET<< std::endl;
AgentsQueueIn::GetandClear(peds);
//std::cout << "SIMULATION BEFORE BOOL = " << _agentSrcManager.IsBuildingUpdated() << " peds size " << peds.size() << "\n" ;
//_agentSrcManager.SetBuildingUpdated(true);
/* std::cout << "SIMULATION AFTER BOOL = " << _agentSrcManager.IsBuildingUpdated() << "\n" ; */
for (auto&& ped: peds) {
/* std::cout << "Add to building : " << ped->GetPos()._x << ", " << ped->GetPos()._y << " t: "<< Pedestrian::GetGlobalTime() << std::endl; */
_building->AddPedestrian(ped);
}
// for(auto pp: _building->GetAllPedestrians())
// std::cout<< KBLU << "BUL: Simulation: " << pp->GetPos()._x << ", " << pp->GetPos()._y << " t: "<< Pedestrian::GetGlobalTime() <<RESET << std::endl;
/* std::cout << "LEAVE Simulation::ProcessAgentsQueue() with " << " size " << _building->GetAllPedestrians().size() << "\n" << RESET; */
}
void Simulation::UpdateDoorticks() const {
......@@ -619,3 +641,7 @@ Building* Simulation::GetBuilding()
{
return _building.get();
}
int Simulation::GetMaxSimTime() const{
return _maxSimTime;
}
......@@ -67,7 +67,7 @@ private:
///seed using for the random number generator
unsigned int _seed;
/// building object
std::unique_ptr<Building> _building;
std::shared_ptr<Building> _building;
/// Force model to use
std::shared_ptr<OperationalModel> _operationalModel;
/// Manage all route choices algorithms
......@@ -85,6 +85,8 @@ private:
/// hybrid simulation manager
//HybridSimulationManager
int _periodic;
int _maxSimTime;
bool _gotSources; // is true if we got some sources. Otherwise, false.
// bool _printPB; // print progressbar
public:
......@@ -182,6 +184,8 @@ public:
*
*/
void UpdateDoorticks() const;
int GetMaxSimTime() const;
};
......
......@@ -841,7 +841,7 @@ void Building::AddPedestrian(Pedestrian* ped)
for (unsigned int p = 0; p<_allPedestians.size(); p++) {
Pedestrian* ped1 = _allPedestians[p];
if (ped->GetID()==ped1->GetID()) {
cout << "Pedestrian already in the room ??? " << ped->GetID() << endl;
cout << "Pedestrian " << ped->GetID() << " already in the room." << endl;
return;
}
}
......@@ -1047,5 +1047,3 @@ Transition* Building::GetTransitionByUID(int uid) const
//}
#endif // _SIMULATOR
......@@ -49,7 +49,7 @@ int main(int argc, char** argv)
Configuration* configuration = new Configuration();
// Parsing the arguments
bool status = false;
{
{
//ArgumentParser* p = new ArgumentParser(configuration); //Memory Leak
std::unique_ptr<ArgumentParser> p(new ArgumentParser(configuration));
status = p->ParseArgs(argc, argv);
......@@ -86,8 +86,12 @@ int main(int argc, char** argv)
//Start the thread for managing the sources of agents if any
//std::thread t1(sim.GetAgentSrcManager());
double simMaxTime = configuration->GetTmax();
std::thread t1(&AgentsSourcesManager::Run, &sim.GetAgentSrcManager());//@todo pass simMaxTime to Run
//main thread for the simulation
std::thread t1(&AgentsSourcesManager::Run, &sim.GetAgentSrcManager());
while(!sim.GetAgentSrcManager().IsRunning())
{
// std::cout << "waiting...\n";
}
//main thread for the simulation
evacTime = sim.RunStandardSimulation(simMaxTime);
//Join the main thread
t1.join();
......@@ -111,7 +115,6 @@ int main(int argc, char** argv)
}
double execTime = difftime(endtime, starttime);
std::stringstream summary;
summary << std::setprecision(2) << std::fixed;
summary << "\nExec Time [s] : " << execTime << std::endl;
......
......@@ -242,7 +242,7 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
//double winkel = spacings[0].second;
//Point tmp;
Point speed = direction.Normalized() *OptimalSpeed(ped, spacing);
result_acc.push_back(speed);
result_acc.push_back(speed);
spacings.clear(); //clear for ped p
......@@ -369,7 +369,8 @@ my_pair VelocityModel::GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei,
//printf("ERROR: \tin VelocityModel::forcePedPed() ep12 can not be calculated!!!\n");
Log->Write("WARNING: \tin VelocityModel::GetSPacing() ep12 can not be calculated!!!\n");
Log->Write("\t\t Pedestrians are too near to each other (%f).", Distance);
exit(EXIT_FAILURE);
my_pair(FLT_MAX, ped2->GetID());
exit(EXIT_FAILURE); //TODO
}
double condition1 = ei.ScalarProduct(ep12); // < e_i , e_ij > should be positive
......@@ -410,7 +411,9 @@ Point VelocityModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2, int periodi
Log->Write("\t\t Maybe the value of <a> in force_ped should be increased. Going to exit.\n");
printf("ped1 %d ped2 %d\n", ped1->GetID(), ped2->GetID());
printf("ped1 at (%f, %f), ped2 at (%f, %f)\n", ped1->GetPos()._x, ped1->GetPos()._y, ped2->GetPos()._x, ped2->GetPos()._y);
exit(EXIT_FAILURE);
exit(EXIT_FAILURE); //TODO: quick and dirty fix for issue #158
// (sometimes sources create peds on the same location)
}
Point ei = ped1->GetV().Normalized();
if(ped1->GetV().NormSquare()<0.01){
......
This diff is collapsed.
......@@ -84,6 +84,7 @@ public:
* Set the building object
*/
void SetBuilding(Building* building);
void SetRunning(bool running);
/**
* @return true if all agents have been generated
......@@ -91,6 +92,14 @@ public:
*/
bool IsCompleted() const;
/**
* @return true if the building is updated
*
*/
bool IsBuildingUpdated() const;
void SetBuildingUpdated(bool update);
/**
* Return a pointer to the building object
*/
......@@ -111,10 +120,13 @@ public:
/**
* Return the total number of agents that will be generated.
* used by visualisation to allocate space
*
*/
long GetMaxAgentNumber() const;
int GetMaxSimTime() const;
void SetMaxSimTime(int t);
bool IsRunning() const;
private:
/**
......@@ -165,11 +177,16 @@ private:
std::vector<std::shared_ptr<AgentsSource> > _sources;
///to control the trigger of the events
long int _lastUpdateTime = 0;
int maxSimTime = 0;
/// building object
Building* _building=nullptr;
/// whether all agents have been dispatched
static bool _isCompleted;
//std::atomic<bool>_isCompleted=false;
// std::atomic<bool>_buildingUpdated=false;
bool _buildingUpdated;
bool _isRunning = false;
};
#endif /* AGENTSSOURCESMANAGER_H_ */
......@@ -198,7 +198,9 @@ void Pedestrian::SetID(int i)
_id = i;
if(i<=0)
{
cout<<"invalid ID"<<i<<endl;exit(0);
cerr<<">> Invalid pedestrians ID " << i<< endl;
cerr<<">> Pedestrian ID should be > 0. Exit." << endl;
exit(0);
}
}
......@@ -597,7 +599,7 @@ double Pedestrian::GetV0Norm() const
// // getc(stdin);
walking_speed =(1-f*g)*_ellipse.GetV0() + f*g*speed_down;
// printf("%f DOWN max_e=%f, z=%f, f=%f, v0=%f, v0d=%f, ret=%f\n", _globalTime, maxSubElevation, ped_elevation, f, _ellipse.GetV0(), _V0DownStairs, (1-f*g)*_ellipse.GetV0() + f*g*speed_down);
}
......@@ -630,7 +632,7 @@ double Pedestrian::GetV0Norm() const
walking_speed = (1-f*g)*_ellipse.GetV0() + f*g*speed_up;
}
}
}
//IF execution of WalkingInSmoke depending on JPSfire section in INI file
if(_WalkingSpeed && _WalkingSpeed->ReduceWalkingSpeed()) {
......@@ -641,7 +643,7 @@ double Pedestrian::GetV0Norm() const
//WHERE should the call to that routine be placed properly?
//only executed every 3 seconds
// fprintf(stderr, "%f\n", walking_speed);
return walking_speed;
// orthogonal projection on the stair
//return _ellipse.GetV0()*_building->GetRoom(_roomID)->GetSubRoom(_subRoomID)->GetCosAngleWithHorizontal();
......@@ -1225,6 +1227,3 @@ bool Pedestrian::Relocate(std::function<void(const Pedestrian&)> flowupdater) {
}
return status;
}
This diff is collapsed.
......@@ -30,67 +30,67 @@ class Point;
// TODO: bool IsSpace(SubRoom* subroom, Point& pt,Point& v1);
/**
* Calculates if a point (which is inside the subroom) is far enough from the walls, transitions, crossings ( > radius of a person)
* @param subroom
* @param pt
*/
bool IsEnoughInSubroom( SubRoom* subroom, Point& pt, double radius );
/**
* Position incoming pedestrian using voronoi from boost library
* @param src
* @param peds
*/
bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>& peds, Building* _building);
/**
* Position incoming pedestrian on the vertex with the greatest distance
* @param discrete_positions, positions of existing pedestrians + fake pedestrians (but multiplied with the factor)
* @param vd
* @param subroom
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
/**
* Calculates if a point (which is inside the subroom) is far enough from the walls, transitions, crossings ( > radius of a person)
* @param subroom
* @param pt
*/
bool IsEnoughInSubroom( SubRoom* subroom, Point& pt, double radius );
/**
* Position incoming pedestrian using voronoi from boost library
* @param src
* @param peds
*/
bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>& peds, Building* _building, std::vector<Pedestrian*>& peds_queue);
/**
* Position incoming pedestrian on the vertex with the greatest distance
* @param discrete_positions, positions of existing pedestrians + fake pedestrians (but multiplied with the factor)
* @param vd
* @param subroom
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
void VoronoiBestVertexMax(const std::vector<Point>& discrete_positions, const voronoi_diagram<double>& vd,
SubRoom* subroom, double factor, voronoi_diagram<double>::const_vertex_iterator& max_it, double& max_dis,
double radius);
/**
* Position incoming pedestrian on the vertex with greater probability for greater distances
* @param discrete_positions
* @param vd
* @param subroom
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
void VoronoiBestVertexRandMax (const std::vector<Point>& discrete_positions, const voronoi_diagram<double>& vd, SubRoom* subroom, double factor,
/**
* Position incoming pedestrian on the vertex with greater probability for greater distances
* @param discrete_positions
* @param vd
* @param subroom
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
void VoronoiBestVertexRandMax (const std::vector<Point>& discrete_positions, const voronoi_diagram<double>& vd, SubRoom* subroom, double factor,
voronoi_diagram<double>::const_vertex_iterator& max_it, double& max_dis, double radius);
void VoronoiBestVertexGreedy (const std::vector<Point>& discrete_positions, const voronoi_diagram<double>& vd, SubRoom* subroom, double factor,
void VoronoiBestVertexGreedy (const std::vector<Point>& discrete_positions, const voronoi_diagram<double>& vd, SubRoom* subroom, double factor,
voronoi_diagram<double>::const_vertex_iterator& max_it, double& max_dis, double radius);
void plotVoronoi(const std::vector<Point>& discrete_positions, const voronoi_diagram<double>& vd, SubRoom* subroom, double factor);
/**
* Position incoming pedestrian on a random vertex
* @param discrete_positions
* @param vd
* @param subroom
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
void VoronoiBestVertexRand (const std::vector<Point>& discrete_positions, const voronoi_diagram<double>& vd, SubRoom* subroom, double factor,
voronoi_diagram<double>::const_vertex_iterator& max_it, double& max_dis, double radius );
/**
* Gives a person the mean velocity of his voronoi-neighbours
* @param vd
* @param chosen_it
* @param velocities_vector
*/
/**
* Position incoming pedestrian on a random vertex
* @param discrete_positions
* @param vd
* @param subroom
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
void VoronoiBestVertexRand (const std::vector<Point>& discrete_positions, const voronoi_diagram<double>& vd, SubRoom* subroom, double factor,
voronoi_diagram<double>::const_vertex_iterator& max_it, double& max_dis, double radius );
/**
* Gives a person the mean velocity of his voronoi-neighbours
* @param vd
* @param chosen_it
* @param velocities_vector
*/
void VoronoiAdjustVelocityNeighbour(voronoi_diagram<double>::const_vertex_iterator& chosen_it, Pedestrian* ped,
const std::vector<Point>& velocities_vector, const std::vector<int>& goal_vector);
......
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