Commit 8b1cec28 authored by LOPEZ GANDIA Axel's avatar LOPEZ GANDIA Axel

WIP fix for static library

parent 4ec7f1ed
/* 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
......@@ -28,29 +28,31 @@
#include <core/costFunction.h>
/*
* Performs a directional goal reaching at the desired speed of the agent.
* CF = AV - ADS*GD
* CF: Cost function, ADS: Agent Desired Speed, AV: Agent current Velocity.
*/
class DirGoalReaching : public CostFunction
{
private:
public:
const static std::string Name;
const static std::string GetName() { return "DirectionalGoalReaching"; }
DirGoalReaching();
/**
* Computes the value and gradient of the cost function.
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(const CostFunctionParameters & params) override;
virtual ~DirGoalReaching();
};
/*
* Performs a directional goal reaching at the desired speed of the agent.
* CF = AV - ADS*GD
* CF: Cost function, ADS: Agent Desired Speed, AV: Agent current Velocity.
*/
class __declspec(dllexport) DirGoalReaching : public CostFunction
{
private:
public:
const static std::string Name;
const static std::string GetName() { return "DirectionalGoalReaching"; }
DirGoalReaching();
/**
* Computes the value and gradient of the cost function.
* Return the values to the policy to update the agent.
*/
virtual CostFunctionValues GetCostFunctionGradient(Agent* agent, WorldBase * world);
void parseParameters(const CostFunctionParameters & params) override;
virtual ~DirGoalReaching();
};
#endif //LIB_DIRGOAL_REACHING_H
......@@ -42,7 +42,7 @@ public:
static std::shared_ptr<CostFunction> CreateCostFunction(const std::string& name);
static void RegisterCostFunction(const std::string &name, Creator creator);
private:
//private:
static Registry& GetRegistry();
};
......@@ -54,10 +54,10 @@ std::shared_ptr<CostFunction> DefaultObjectCreator() {
class CostFunctionRegistrator {
public:
CostFunctionRegistrator(const std::string &name, CostFunctionFactory::Creator creator);
//CostFunctionFactory::Registry& GetRegistry() { return CostFunctionFactory::GetRegistry(); }
};
#define REGISTER_COST_FUNCTION(classname) CostFunctionRegistrator g_##classname(classname::GetName(), DefaultObjectCreator<classname>);
#endif
......@@ -23,9 +23,7 @@
#include <vector>
#include <iostream>
#include "core/crowdSimulator.h"
#include <CostFunctions/goalReaching.h>
#include <CostFunctions/socialforces.h>
#include <CostFunctions/directionalGoalReaching.h>
#include "CostFunctions/costFunctionRegistration.h"
#include <iostream>
#include <fstream>
......@@ -33,7 +31,8 @@ using namespace std;
int main( int argc, char * argv[] )
{
CrowdSimulator cs;
RegisterCostFunctions();
CrowdSimulator cs;
cs.setOutputDir("./output/");
cs.runMasterConfigFile("./MainConfig.xml");
......@@ -44,7 +43,7 @@ int main( int argc, char * argv[] )
std::cout << "---------------" << std::endl;
system("pause");
// for(int i = 0; i < MAX_AGENTS; i++){
// agents.push_back(new Agent());
......
......@@ -39,7 +39,7 @@ CostFunctionFactory::Registry& CostFunctionFactory::GetRegistry() {
void CostFunctionFactory::RegisterCostFunction(const std::string &name, Creator creator) {
Registry &registry = GetRegistry();
if (registry.count(name) > 0) {
std::cerr << "Error: cost function " << name << " has already been registered." << std::endl;
std::cerr << "Warning: cost function " << name << " has already been registered." << std::endl;
return;
}
registry[name] = creator;
......@@ -61,8 +61,7 @@ std::shared_ptr<CostFunction>
return registry[name]();
}
CostFunctionRegistrator::CostFunctionRegistrator(const std::string &name, CostFunctionFactory::Creator creator) {
CostFunctionFactory::RegisterCostFunction(name, creator);
}
\ No newline at end of file
}
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