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

Merge branch '61-CostFunctionFactory-static-lib-fix' into Wouter-API-DLL

parents 4ec7f1ed 2135a1e5
/* 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 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, 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, Alexandre Bonneau, Wouter Van toll, Benjamin Niay.
**
** Contact : crowd_group@inria.fr
*/
#ifndef LIB_COSTFUNCTIONREGISTRATION_H
#define LIB_COSTFUNCTIONREGISTRATION_H
void RegisterCostFunctions();
#endif //LIB_COSTFUNCTIONREGISTRATION_H
......@@ -121,6 +121,3 @@ void FOEAvoidance::parseParameters(const CostFunctionParameters & params)
range_ = 30;
CostFunction::parseParameters(params);
}
REGISTER_COST_FUNCTION(FOEAvoidance)
\ No newline at end of file
......@@ -54,5 +54,3 @@ void GenericCost::parseParameters(const CostFunctionParameters & params)
{
CostFunction::parseParameters(params);
}
REGISTER_COST_FUNCTION(GenericCost)
\ No newline at end of file
......@@ -88,5 +88,3 @@ void PowerLaw::parseParameters(const CostFunctionParameters & params)
CostFunction::parseParameters(params);
params.ReadFloat("tau0", tau0);
}
REGISTER_COST_FUNCTION(PowerLaw)
\ No newline at end of file
......@@ -53,4 +53,3 @@ void RandomFunction::parseParameters(const CostFunctionParameters & params)
CostFunction::parseParameters(params);
}
REGISTER_COST_FUNCTION(RandomFunction)
......@@ -82,4 +82,3 @@ void SocialForcesAvoidance::parseParameters(const CostFunctionParameters & param
params.ReadFloat("sigma", sigma);
}
REGISTER_COST_FUNCTION(SocialForcesAvoidance)
\ No newline at end of file
......@@ -63,4 +63,3 @@ void SocialForcesGoalReaching::parseParameters(const CostFunctionParameters & pa
CostFunction::parseParameters(params);
}
REGISTER_COST_FUNCTION(SocialForcesGoalReaching)
\ No newline at end of file
......@@ -160,4 +160,3 @@ void TtcaDca::parseParameters(const CostFunctionParameters & params)
params.ReadFloat("sigmaDca", sigDca_);
}
REGISTER_COST_FUNCTION(TtcaDca)
\ No newline at end of file
#include "core/costFunctionFactory.h"
#include "CostFunctions/costFunctionRegistration.h"
#include "CostFunctions/directionalGoalReaching.h"
#include "CostFunctions/FOEAvoidance.h"
#include "CostFunctions/GenericCost.h"
#include "CostFunctions/goalReaching.h"
#include "CostFunctions/PowerLaw.h"
#include "CostFunctions/RandomFunction.h"
#include "CostFunctions/socialforces.h"
#include "CostFunctions/SocialForcesAvoidance.h"
#include "CostFunctions/SocialForcesGoalReaching.h"
#include "CostFunctions/TtcaDca.h"
bool registered = false;
void RegisterCostFunctions() {
if (registered) {
return;
}
registered = true;
REGISTER_COST_FUNCTION(DirGoalReaching);
REGISTER_COST_FUNCTION(FOEAvoidance);
REGISTER_COST_FUNCTION(GenericCost);
REGISTER_COST_FUNCTION(GoalReaching);
REGISTER_COST_FUNCTION(PowerLaw);
REGISTER_COST_FUNCTION(RandomFunction);
REGISTER_COST_FUNCTION(SocialForces);
REGISTER_COST_FUNCTION(SocialForcesAvoidance);
REGISTER_COST_FUNCTION(SocialForcesGoalReaching);
REGISTER_COST_FUNCTION(TtcaDca);
}
\ No newline at end of file
......@@ -23,41 +23,39 @@
#include <CostFunctions/directionalGoalReaching.h>
#include <core/agent.h>
#include "core/costFunctionFactory.h"
#include <iostream>
using namespace std;
const std::string DirGoalReaching::Name = "DirectionalGoalReaching";
DirGoalReaching::DirGoalReaching() {
name_ = "DirectionalGoalReaching";
}
const std::string DirGoalReaching::Name = "DirectionalGoalReaching";
DirGoalReaching::~DirGoalReaching() {
DirGoalReaching::DirGoalReaching() {
name_ = "DirectionalGoalReaching";
}
}
DirGoalReaching::~DirGoalReaching() {
CostFunctionValues DirGoalReaching::GetCostFunctionGradient(Agent* agent, WorldBase * world) {
CostFunctionValues Result;
const Vector2D& Goal = agent->getGoal();
const Vector2D& AgentVelocity = agent->getVelocity();
}
float Speed = agent->getPreferredSpeed();
Vector2D DesiredVelocity = Goal.getnormalized() * Speed;
CostFunctionValues DirGoalReaching::GetCostFunctionGradient(Agent* agent, WorldBase * world) {
CostFunctionValues Result;
const Vector2D& Goal = agent->getGoal();
const Vector2D& AgentVelocity = agent->getVelocity();
const Vector2D& Delta = AgentVelocity - DesiredVelocity;
Result.Gradient = coefficient_ * Delta;
Result.TotalCost = 0.5f*(Delta.sqrMagnitude());
float Speed = agent->getPreferredSpeed();
Vector2D DesiredVelocity = Goal.getnormalized() * Speed;
return Result;
}
const Vector2D& Delta = AgentVelocity - DesiredVelocity;
Result.Gradient = coefficient_ * Delta;
Result.TotalCost = 0.5f*(Delta.sqrMagnitude());
return Result;
}
void DirGoalReaching::parseParameters(const CostFunctionParameters & params)
{
CostFunction::parseParameters(params);
}
void DirGoalReaching::parseParameters(const CostFunctionParameters & params)
{
CostFunction::parseParameters(params);
}
REGISTER_COST_FUNCTION(DirGoalReaching);
\ No newline at end of file
......@@ -61,5 +61,3 @@ void GoalReaching::parseParameters(const CostFunctionParameters & params)
{
CostFunction::parseParameters(params);
}
REGISTER_COST_FUNCTION(GoalReaching)
\ No newline at end of file
......@@ -87,4 +87,3 @@ void SocialForces::parseParameters(const CostFunctionParameters & params)
params.ReadFloat("sigma", sigma);
}
REGISTER_COST_FUNCTION(SocialForces)
\ No newline at end of file
......@@ -26,9 +26,11 @@
#include "tools/csvwriter.h"
#include "core/worldInfinite.h"
#include "core/worldToric.h"
#include "CostFunctions/costFunctionRegistration.h"
CrowdSimulator::CrowdSimulator()
{
RegisterCostFunctions();
//createNewWorld(WorldType::INFINITE);
writer = nullptr;
}
......
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