Commit eb581573 authored by LOPEZ GANDIA Axel's avatar LOPEZ GANDIA Axel

Added documentation

parent 3047c6de
......@@ -42,11 +42,12 @@ 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{
......@@ -57,6 +58,14 @@ struct CostFunctionValues {
};
MyNewFunction.cpp
CostFunctionValues MyNewFunction::GetCostFunctionGradient(Agent* agent, WorldBase * world) {
//Implementation
}
void MyNewFunction::parseParameters(tinyxml2::XMLElement* v) {
//Implementation
}
REGISTER_COST_FUNCTION(MyNewFunction)
*
*
......
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