Commit 64475172 authored by VAN TOLL Wouter's avatar VAN TOLL Wouter

Merge branch 'master' into Wouter-API-DLL

parents c85cbd30 5df2f592
......@@ -5,7 +5,6 @@ cmake-build-debug
build/
/.vs
/bin
/release
# Prerequisites
*.d
......@@ -36,7 +35,6 @@ build/
*.lib
# Executables
*.exe
*.out
*.app
......
# Crowd Simulator Engine
# Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
#
# This program 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 General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
# Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
#
# Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
# Alicia Nics Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
#
# Contact: crowd_group@inria.fr
cmake_minimum_required( VERSION 2.8 )
project( CrowdSimulator )
set (CMAKE_CXX_STANDARD 14)
......@@ -48,7 +47,7 @@ target_link_libraries(OCSR_ConsoleApplication Engine)
#add_executable(test_xmlparser ./test/test_xmlparser.cpp ${source_files} ${3rd_party})
#add_executable(test_socialforces ./test/SocialForcesExample.cpp ${source_files} ${tinyxml_src})
#add_executable(test_ttcaDca ./test/DcaTtcaExample.cpp ${source_files} ${3rd_party})
add_executable(test_localSearch ./test/TestLocalSearch.cpp ${source_files} ${3rd_party})
#add_executable(test_localSearch ./test/TestLocalSearch.cpp ${source_files} ${3rd_party})
add_library(OCSR_Library SHARED "APIFunctions.h" "APIFunctions.cpp")
target_link_libraries(OCSR_Library Engine)
......@@ -57,7 +56,7 @@ target_link_libraries(OCSR_Library Engine)
#target_link_libraries(test_xmlparser)
#target_link_libraries(test_socialforces)
#target_link_libraries(test_ttcaDca)
target_link_libraries(test_localSearch)
#target_link_libraries(test_localSearch)
#message(${Boost_LIBRARIES})
#message(${Boost_LIBRARY_DIRS})
......
This diff is collapsed.
......@@ -3,7 +3,7 @@ Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
......@@ -12,15 +12,12 @@ 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 General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
Alicia Nicás Miquel
Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
Contact: crowd_group@inria.fr
================================================================================
================================================================================
\ No newline at end of file
......@@ -48,7 +48,7 @@ class FOEAvoidance : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~FOEAvoidance();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_GENERIC_COST_H
#define LIB_GENERIC_COST_H
......@@ -46,7 +45,7 @@ class GenericCost : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~GenericCost();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_POWER_LAW_H
......@@ -32,15 +30,16 @@
/*
* Deviates the trajectory of the agent to prevent collisions.
* Uses FOE to detect and prevent collisions.
* Parameters: tau0
*/
class PowerLaw : public CostFunction
{
private:
float tau0 = 3;
public:
const static std::string GetName() { return "PowerLaw"; }
float tau0 = 3;
const static std::string Name;
PowerLaw();
......@@ -50,7 +49,7 @@ class PowerLaw : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~PowerLaw();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_RANDOM_FUNCTION_H
#define LIB_RANDOM_FUNCTION_H
......@@ -50,7 +49,7 @@ class RandomFunction : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~RandomFunction();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_SOCIAL_FORCES_AVOIDANCE_H
#define LIB_SOCIAL_FORCES_AVOIDANCE_H
#include <core/costFunction.h>
/*
* Implements social forces algorithm.
* Implements social forces algorithm for collision avoidance only.
* Paramters: sigma
*/
class SocialForcesAvoidance : public CostFunction
{
......@@ -46,7 +46,7 @@ class SocialForcesAvoidance : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~SocialForcesAvoidance();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_SOCIAL_FORCES_GOAL_H
#define LIB_SOCIAL_FORCES_GOAL_H
......@@ -46,7 +45,7 @@ class SocialForcesGoalReaching : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~SocialForcesGoalReaching();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_TTCADCA_H
#define LIB_TTCADCA_H
......@@ -40,20 +39,20 @@
* distance from each other, called dca.
*
* This cost function maximise those 2 metrics together.
* Parameters: sigmaTtca, sigmaDca
*/
class TtcaDca : public CostFunction
{
/*
* Parameters of the cost function
*/
float sigTtca_ = 2;
float sigDca_ = 0.5;
private:
Vector2D GradDca();
Vector2D GradTtca();
float Cost(float ttca, float dca);
/*
* Parameters of the cost function
*/
float sigTtca_ = 2;
float sigDca_ = 0.5;
public:
......@@ -76,7 +75,7 @@ class TtcaDca : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
};
#endif //LIB_TTCADCA_H
......@@ -48,7 +48,7 @@ class DirGoalReaching : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~DirGoalReaching();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_GOAL_REACHING_H
#define LIB_GOAL_REACHING_H
......@@ -48,7 +47,7 @@ class GoalReaching : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~GoalReaching();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_SOCIAL_FORCES_H
#define LIB_SOCIAL_FORCES_H
#include <core/costFunction.h>
/*
* Implements social forces algorithm.
* Implements social forces algorithm for collision avoidance and goal reaching at once.
* Parameters: AtractionForce, RepulsionForce, sigma
*/
class SocialForces : public CostFunction
{
private:
float AtractorForce = 1;
float RepulsionForce = 3;
float sigma = 0.3;
public:
const static std::string GetName() { return "SocialForces"; }
const static std::string Name;
float AtractorForce = 1;
float RepulsionForce = 3;
SocialForces();
......@@ -50,7 +51,7 @@ class SocialForces : public CostFunction
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
virtual ~SocialForces();
};
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nics Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact: crowd_group@inria.fr
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_AGENT_H
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** as published by the Free Software Foundation; either version 3
** of the License, or (at your option) any later version.
**
**
** This program 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
** 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 General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** You should have received a copy of the GNU General Public License
** along with this program.If not, see < https://www.gnu.org/licenses/>.
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak,
** Alicia Nicás Miquel, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_COST_FUNCTION_H
#define LIB_COST_FUNCTION_H
#include "tinyxml2.h"
#include "tools/xmlparser.h"
#include <tools/vector2D.h>
#include <string>
//#include <agent/agent.h>
......@@ -42,21 +40,30 @@ struct CostFunctionValues {
/*
*
* To create a new cost function you need to create a new class and derive it (public inheritance) from CostFunction.
* Then you need to override the functions GetCostFunctionGradient(Agent* agent, WorldBase * world), parseParameters(tinyxml2::XMLElement* v)
* and add a new one const static std::string GetName() { return "MyCostFuncID"; }. Finally in the cpp file you must add REGISTER_COST_FUNCTION(MyNewFunction)
*
It should look like this:
The function you need to add is const static std::string GetName(). This function must return the name that identifies the function in configuration files.
Then, the function GetCostFunctionGradient(Agent* agent, WorldBase * world) must be overrided implementing the gradient computation to update the agent’s speed.
If your function depends on parameters you can implement the function parseParameters(tinyxml2::XMLElement* v) to read them from the configuration file.
Finally in a cpp file you must add REGISTER_COST_FUNCTION(MyNewFunction)
Example:
MyNewFunction.h
class MyNewFunction : public CostFunction{
public:
const static std::string GetName() { return "MyNewFunctionId"; }
CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world) override;
void parseParameters(tinyxml2::XMLElement* v) override;
void parseParameters(const CostFunctionParameters & params) override;
};
MyNewFunction.cpp
CostFunctionValues MyNewFunction::GetCostFunctionGradient(Agent* agent, WorldBase * world) {
//Implementation
}
void MyNewFunction::parseParameters(const CostFunctionParameters & params) {
//Implementation
}
REGISTER_COST_FUNCTION(MyNewFunction)
*
*
......@@ -70,7 +77,8 @@ class CostFunction {
//float lambdaMovementCost_;
//WorldBase* world_;
std::string name_;
float coefficient_ = 1;
float coefficient_ = 1; //tipically scaling factor of the result of the cost function
float range_ = 100; //range of interaction. Typically the range for neighbor search
public:
CostFunction();
......@@ -83,7 +91,7 @@ class CostFunction {
/**
* Parses the parameters of the cost function.
*/
virtual void parseParameters(tinyxml2::XMLElement* v);
virtual void parseParameters(const CostFunctionParameters & params);
virtual ~CostFunction();
std::string getName() const;
......
/* Crowd Simulator Engine
** Copyright(C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or