GAMS
1.4.0
|
A controller that has the capability of managing multiple controllers. More...
#include <Multicontroller.h>
Public Member Functions | |
Multicontroller (size_t num_controllers=1, const ControllerSettings &settings=ControllerSettings()) | |
Constructor. More... | |
virtual | ~Multicontroller () |
Destructor. More... | |
void | add_algorithm_factory (const std::vector< std::string > &aliases, algorithms::AlgorithmFactory *factory) |
Adds an aliased algorithm factory. More... | |
void | add_platform_factory (const std::vector< std::string > &aliases, platforms::PlatformFactory *factory) |
Adds an aliased platform factory. More... | |
void | add_transports (const madara::transport::QoSTransportSettings &source_settings) |
Add transports to the knowledge bases that are being used by each controller. More... | |
void | clear_accents (size_t controller_index=0) |
Clears all accent algorithms. More... | |
void | clear_knowledge (void) |
Clears all controller knowledge bases. More... | |
void | evaluate (const std::string &logic, const madara::knowledge::EvalSettings &settings=madara::knowledge::EvalSettings::DELAY) |
Evaluates a karl logic across all controllers and knowledge bases. More... | |
void | evaluate (size_t controller_index, const std::string &logic, const madara::knowledge::EvalSettings &settings=madara::knowledge::EvalSettings::DELAY) |
Evaluates a karl logic across all controllers and knowledge bases. More... | |
algorithms::BaseAlgorithm * | get_algorithm (size_t controller_index=0) |
Gets the current algorithm at the controller index. More... | |
madara::knowledge::KnowledgeBase | get_kb (size_t controller_index) |
Returns the kb that is being used by the internal controller. More... | |
size_t | get_num_controllers (void) |
Returns the number of controllers being managed. More... | |
platforms::BasePlatform * | get_platform (size_t controller_index=0) |
Gets the current platform at the controller index. More... | |
void | init_accent (const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes all managed controllers with an accent algorithm. More... | |
void | init_accent (size_t controller_index, const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Adds an accent algorithm. More... | |
void | init_algorithm (const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes all managed controllers with an algorithm. More... | |
void | init_algorithm (size_t controller_index, algorithms::BaseAlgorithm *algorithm) |
Initializes the controller with a user-provided algorithm. More... | |
void | init_algorithm (size_t controller_index, const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes a specific controller with an algorithm. More... | |
void | init_platform (const std::string &platform, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes all managed controllers with the platform. More... | |
void | init_platform (size_t controller_index, const std::string &platform, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes the platform. More... | |
void | init_platform (size_t controller_index, platforms::BasePlatform *platform) |
Initializes the controller with a user-provided platform. More... | |
void | init_vars (const madara::knowledge::KnowledgeRecord::Integer &id=0, const madara::knowledge::KnowledgeRecord::Integer &processes=-1) |
Initializes global variable containers. More... | |
void | init_vars (size_t controller_index, algorithms::BaseAlgorithm &algorithm) |
Initializes containers and knowledge base in an algorithm. More... | |
void | init_vars (size_t controller_index, platforms::BasePlatform &platform) |
Initializes containers and knowledge base in a platform This is usually the first thing a developer should do with a user-defined platform. More... | |
void | refresh_vars (bool init_non_self_vars=false) |
Calls init_vars for each controller. More... | |
void | resize (size_t num_controllers, bool init_non_self_vars=false) |
Resizes the number of controllers and knowledge bases. More... | |
int | run (double loop_period, double max_runtime=-1, double send_period=-1.0) |
Runs iterations of the MAPE loop with specified periods. More... | |
int | run (void) |
Runs iterations of the MAPE loop with configured settings. More... | |
int | run_hz (double loop_hz=0.0, double max_runtime=-1, double send_hz=-1.0) |
Runs iterations of the MAPE loop with specified hertz. More... | |
int | run_once (void) |
Runs a single iteration of the MAPE loop Always sends updates after the iteration. More... | |
Protected Attributes | |
std::vector< BaseController * > | controllers_ |
Controllers that need to be instrumented. More... | |
std::vector< madara::knowledge::KnowledgeBase > | kbs_ |
Knowledge base. More... | |
ControllerSettings | settings_ |
Settings for controller management and qos. More... | |
int | sim_step_ = 0 |
used explicitly by the scrimmage platform. Will be moved More... | |
std::vector< madara::transport::SharedMemoryPush * > | transports_ |
transports meant for fast memory transport within the controller More... | |
A controller that has the capability of managing multiple controllers.
Definition at line 89 of file Multicontroller.h.
gams::controllers::Multicontroller::Multicontroller | ( | size_t | num_controllers = 1 , |
const ControllerSettings & | settings = ControllerSettings() |
||
) |
Constructor.
num_controllers | the number of controllers to manage |
settings | settings to use |
|
virtual |
Destructor.
void gams::controllers::Multicontroller::add_algorithm_factory | ( | const std::vector< std::string > & | aliases, |
algorithms::AlgorithmFactory * | factory | ||
) |
Adds an aliased algorithm factory.
This factory will be initialized with all appropriate variables in the AlgorithmFactory class by the Multicontroller.
aliases | the named aliases for the factory. All aliases will be converted to lower case |
factory | the factory for creating an algorithm |
void gams::controllers::Multicontroller::add_platform_factory | ( | const std::vector< std::string > & | aliases, |
platforms::PlatformFactory * | factory | ||
) |
Adds an aliased platform factory.
This factory will be initialized with all appropriate variables in the PlatformFactory class by the Multicontroller.
aliases | the named aliases for the factory. All aliases will be converted to lower case |
factory | the factory for creating a platform |
void gams::controllers::Multicontroller::add_transports | ( | const madara::transport::QoSTransportSettings & | source_settings | ) |
Add transports to the knowledge bases that are being used by each controller.
If multicast or broadcast transports, the hosts are simply copied. If using unicast-based connections, then the first host in the settings is used and ports are added in an ascending order for each subsequent KB. This latter functionality is meant to aid in the expected use case of the Multicontroller managing colocated agents that need to communicate with each other. Note that you should resize the Multicontroller to the appropriate number of controllers BEFORE calling this function. Changes made here are not retroactive for all future resizes.
source_settings | base transport settings to copy from |
void gams::controllers::Multicontroller::clear_accents | ( | size_t | controller_index = 0 | ) |
Clears all accent algorithms.
controller_index | the index of the managed controllers |
void gams::controllers::Multicontroller::clear_knowledge | ( | void | ) |
Clears all controller knowledge bases.
void gams::controllers::Multicontroller::evaluate | ( | const std::string & | logic, |
const madara::knowledge::EvalSettings & | settings = madara::knowledge::EvalSettings::DELAY |
||
) |
Evaluates a karl logic across all controllers and knowledge bases.
logic | karl logic to evaluate |
settings | evaluation settings for the logic evaluation |
void gams::controllers::Multicontroller::evaluate | ( | size_t | controller_index, |
const std::string & | logic, | ||
const madara::knowledge::EvalSettings & | settings = madara::knowledge::EvalSettings::DELAY |
||
) |
Evaluates a karl logic across all controllers and knowledge bases.
controller_index | the index of the managed controllers |
logic | karl logic to evaluate |
settings | evaluation settings for the logic evaluation |
algorithms::BaseAlgorithm* gams::controllers::Multicontroller::get_algorithm | ( | size_t | controller_index = 0 | ) |
Gets the current algorithm at the controller index.
controller_index | the index of the managed controllers |
madara::knowledge::KnowledgeBase gams::controllers::Multicontroller::get_kb | ( | size_t | controller_index | ) |
Returns the kb that is being used by the internal controller.
controller_index | the index of the managed controllers |
size_t gams::controllers::Multicontroller::get_num_controllers | ( | void | ) |
Returns the number of controllers being managed.
platforms::BasePlatform* gams::controllers::Multicontroller::get_platform | ( | size_t | controller_index = 0 | ) |
Gets the current platform at the controller index.
controller_index | the index of the managed controllers |
void gams::controllers::Multicontroller::init_accent | ( | const std::string & | algorithm, |
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes all managed controllers with an accent algorithm.
algorithm | the name of the accent algorithm to add |
args | vector of knowledge record arguments |
void gams::controllers::Multicontroller::init_accent | ( | size_t | controller_index, |
const std::string & | algorithm, | ||
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Adds an accent algorithm.
controller_index | the index of the managed controllers |
algorithm | the name of the accent algorithm to add |
args | vector of knowledge record arguments |
void gams::controllers::Multicontroller::init_algorithm | ( | const std::string & | algorithm, |
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes all managed controllers with an algorithm.
algorithm | the name of the algorithm to run |
args | vector of knowledge record arguments |
void gams::controllers::Multicontroller::init_algorithm | ( | size_t | controller_index, |
algorithms::BaseAlgorithm * | algorithm | ||
) |
Initializes the controller with a user-provided algorithm.
This algorithm's memory will be maintained by the controller. DO NOT DELETE THIS POINTER.
controller_index | the index of the managed controllers |
algorithm | the algorithm to use |
void gams::controllers::Multicontroller::init_algorithm | ( | size_t | controller_index, |
const std::string & | algorithm, | ||
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes a specific controller with an algorithm.
controller_index | the index of the managed controllers |
algorithm | the name of the algorithm to run |
args | vector of knowledge record arguments |
void gams::controllers::Multicontroller::init_platform | ( | const std::string & | platform, |
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes all managed controllers with the platform.
platform | the name of the platform the controller is using |
args | vector of knowledge record arguments |
void gams::controllers::Multicontroller::init_platform | ( | size_t | controller_index, |
const std::string & | platform, | ||
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes the platform.
controller_index | the index of the managed controllers |
platform | the name of the platform the controller is using |
args | vector of knowledge record arguments |
void gams::controllers::Multicontroller::init_platform | ( | size_t | controller_index, |
platforms::BasePlatform * | platform | ||
) |
Initializes the controller with a user-provided platform.
This platform's memory will be maintained by the controller. DO NOT DELETE THIS POINTER.
controller_index | the index of the managed controllers |
platform | the platform to use |
void gams::controllers::Multicontroller::init_vars | ( | const madara::knowledge::KnowledgeRecord::Integer & | id = 0 , |
const madara::knowledge::KnowledgeRecord::Integer & | processes = -1 |
||
) |
Initializes global variable containers.
id | node identifier |
processes | processes |
void gams::controllers::Multicontroller::init_vars | ( | size_t | controller_index, |
algorithms::BaseAlgorithm & | algorithm | ||
) |
Initializes containers and knowledge base in an algorithm.
This is usually the first thing a developer should do with a user-defined algorithm.
controller_index | the index of the managed controllers |
algorithm | the algorithm to initialize |
void gams::controllers::Multicontroller::init_vars | ( | size_t | controller_index, |
platforms::BasePlatform & | platform | ||
) |
Initializes containers and knowledge base in a platform This is usually the first thing a developer should do with a user-defined platform.
controller_index | the index of the managed controllers |
platform | the platform to initialize |
void gams::controllers::Multicontroller::refresh_vars | ( | bool | init_non_self_vars = false | ) |
Calls init_vars for each controller.
Useful after clearing knowledge to repopulate the self identifying variables
init_non_self_vars | if true, populate agent vars for swarm, which is very memory expensive with 400+ |
void gams::controllers::Multicontroller::resize | ( | size_t | num_controllers, |
bool | init_non_self_vars = false |
||
) |
Resizes the number of controllers and knowledge bases.
num_controllers | the number of controllers to manage |
init_non_self_vars | if true, populate agent vars for swarm, which is very memory expensive with 400+ |
int gams::controllers::Multicontroller::run | ( | double | loop_period, |
double | max_runtime = -1 , |
||
double | send_period = -1.0 |
||
) |
Runs iterations of the MAPE loop with specified periods.
loop_period | time(in seconds) between executions of the loop. 0 period is meant to run loop iterations as fast as possible. Negative loop periods are invalid. |
max_runtime | maximum total runtime to execute the MAPE loops |
send_period | time(in seconds) between sending data. If send_period <= 0, send period will use the loop period. |
int gams::controllers::Multicontroller::run | ( | void | ) |
Runs iterations of the MAPE loop with configured settings.
|
inline |
Runs iterations of the MAPE loop with specified hertz.
loop_hz | the intended hz at which the loop should execute. anything non-negative is valid. 0hz is treated as as infinite hertz |
max_runtime | maximum total runtime to execute the MAPE loops |
send_hz | the intended hz at which updates should be sent. If non-positive, loop_hz is used. |
Definition at line 381 of file Multicontroller.h.
int gams::controllers::Multicontroller::run_once | ( | void | ) |
Runs a single iteration of the MAPE loop Always sends updates after the iteration.
|
protected |
Controllers that need to be instrumented.
Definition at line 407 of file Multicontroller.h.
|
protected |
Knowledge base.
Definition at line 410 of file Multicontroller.h.
|
protected |
Settings for controller management and qos.
Definition at line 416 of file Multicontroller.h.
|
protected |
used explicitly by the scrimmage platform. Will be moved
Definition at line 419 of file Multicontroller.h.
|
protected |
transports meant for fast memory transport within the controller
Definition at line 413 of file Multicontroller.h.