GAMS  1.4.0
gams::controllers::HiveController Class Reference

A controller that has the capability of managing multiple controllers. More...

#include <HiveController.h>

Public Member Functions

 HiveController ()
 Default constructor. More...
 
 HiveController (madara::knowledge::Hive &hive, size_t init_id=0, size_t num_controllers=1, const ControllerSettings &settings=ControllerSettings())
 Constructor. More...
 
virtual ~HiveController ()
 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::BaseAlgorithmget_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::BasePlatformget_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 init_id, 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...
 
void set_hive (madara::knowledge::Hive &hive)
 Sets the hive to control a portion of. More...
 

Protected Attributes

std::vector< BaseController * > controllers_
 Controllers that need to be instrumented. More...
 
madara::knowledge::Hive * hive_
 Pointer to a hive mind managed by parent. More...
 
size_t offset_
 the starting id within offsets and transports More...
 
ControllerSettings settings_
 Settings for controller management and qos. More...
 

Detailed Description

A controller that has the capability of managing multiple controllers.

Definition at line 85 of file HiveController.h.

Constructor & Destructor Documentation

◆ HiveController() [1/2]

gams::controllers::HiveController::HiveController ( )

Default constructor.

◆ HiveController() [2/2]

gams::controllers::HiveController::HiveController ( madara::knowledge::Hive &  hive,
size_t  init_id = 0,
size_t  num_controllers = 1,
const ControllerSettings settings = ControllerSettings() 
)

Constructor.

Parameters
hivelinked knowledge bases to control
init_idinitial id of the controlled hive
num_controllersnumber of sequential controllers to manage
settingssettings to use

◆ ~HiveController()

virtual gams::controllers::HiveController::~HiveController ( )
virtual

Destructor.

Member Function Documentation

◆ add_algorithm_factory()

void gams::controllers::HiveController::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 HiveController.

Parameters
aliasesthe named aliases for the factory. All aliases will be converted to lower case
factorythe factory for creating an algorithm

◆ add_platform_factory()

void gams::controllers::HiveController::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 HiveController.

Parameters
aliasesthe named aliases for the factory. All aliases will be converted to lower case
factorythe factory for creating a platform

◆ add_transports()

void gams::controllers::HiveController::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 HiveController managing colocated agents that need to communicate with each other. Note that you should resize the HiveController to the appropriate number of controllers BEFORE calling this function. Changes made here are not retroactive for all future resizes.

Parameters
source_settingsbase transport settings to copy from

◆ clear_accents()

void gams::controllers::HiveController::clear_accents ( size_t  controller_index = 0)

Clears all accent algorithms.

Parameters
controller_indexthe index of the managed controllers

◆ clear_knowledge()

void gams::controllers::HiveController::clear_knowledge ( void  )

Clears all controller knowledge bases.

◆ evaluate() [1/2]

void gams::controllers::HiveController::evaluate ( const std::string &  logic,
const madara::knowledge::EvalSettings &  settings = madara::knowledge::EvalSettings::DELAY 
)

Evaluates a karl logic across all controllers and knowledge bases.

Parameters
logickarl logic to evaluate
settingsevaluation settings for the logic evaluation

◆ evaluate() [2/2]

void gams::controllers::HiveController::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.

Parameters
controller_indexthe index of the managed controllers
logickarl logic to evaluate
settingsevaluation settings for the logic evaluation

◆ get_algorithm()

algorithms::BaseAlgorithm* gams::controllers::HiveController::get_algorithm ( size_t  controller_index = 0)

Gets the current algorithm at the controller index.

Parameters
controller_indexthe index of the managed controllers
Returns
the algorithm

◆ get_kb()

madara::knowledge::KnowledgeBase gams::controllers::HiveController::get_kb ( size_t  controller_index)

Returns the kb that is being used by the internal controller.

Parameters
controller_indexthe index of the managed controllers
Returns
the knowledge base that is being referenced

◆ get_num_controllers()

size_t gams::controllers::HiveController::get_num_controllers ( void  )

Returns the number of controllers being managed.

Returns
the number of controllers managed by the multicontroller

◆ get_platform()

platforms::BasePlatform* gams::controllers::HiveController::get_platform ( size_t  controller_index = 0)

Gets the current platform at the controller index.

Parameters
controller_indexthe index of the managed controllers
Returns
the platform

◆ init_accent() [1/2]

void gams::controllers::HiveController::init_accent ( const std::string &  algorithm,
const madara::knowledge::KnowledgeMap &  args = madara::knowledge::KnowledgeMap() 
)

Initializes all managed controllers with an accent algorithm.

Parameters
algorithmthe name of the accent algorithm to add
argsvector of knowledge record arguments

◆ init_accent() [2/2]

void gams::controllers::HiveController::init_accent ( size_t  controller_index,
const std::string &  algorithm,
const madara::knowledge::KnowledgeMap &  args = madara::knowledge::KnowledgeMap() 
)

Adds an accent algorithm.

Parameters
controller_indexthe index of the managed controllers
algorithmthe name of the accent algorithm to add
argsvector of knowledge record arguments

◆ init_algorithm() [1/3]

void gams::controllers::HiveController::init_algorithm ( const std::string &  algorithm,
const madara::knowledge::KnowledgeMap &  args = madara::knowledge::KnowledgeMap() 
)

Initializes all managed controllers with an algorithm.

Parameters
algorithmthe name of the algorithm to run
argsvector of knowledge record arguments

◆ init_algorithm() [2/3]

void gams::controllers::HiveController::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.

Parameters
controller_indexthe index of the managed controllers
algorithmthe algorithm to use

◆ init_algorithm() [3/3]

void gams::controllers::HiveController::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.

Parameters
controller_indexthe index of the managed controllers
algorithmthe name of the algorithm to run
argsvector of knowledge record arguments

◆ init_platform() [1/3]

void gams::controllers::HiveController::init_platform ( const std::string &  platform,
const madara::knowledge::KnowledgeMap &  args = madara::knowledge::KnowledgeMap() 
)

Initializes all managed controllers with the platform.

Parameters
platformthe name of the platform the controller is using
argsvector of knowledge record arguments

◆ init_platform() [2/3]

void gams::controllers::HiveController::init_platform ( size_t  controller_index,
const std::string &  platform,
const madara::knowledge::KnowledgeMap &  args = madara::knowledge::KnowledgeMap() 
)

Initializes the platform.

Parameters
controller_indexthe index of the managed controllers
platformthe name of the platform the controller is using
argsvector of knowledge record arguments

◆ init_platform() [3/3]

void gams::controllers::HiveController::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.

Parameters
controller_indexthe index of the managed controllers
platformthe platform to use

◆ init_vars() [1/3]

void gams::controllers::HiveController::init_vars ( const madara::knowledge::KnowledgeRecord::Integer &  id = 0,
const madara::knowledge::KnowledgeRecord::Integer &  processes = -1 
)

Initializes global variable containers.

Parameters
idnode identifier
processesprocesses

◆ init_vars() [2/3]

void gams::controllers::HiveController::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.

Parameters
controller_indexthe index of the managed controllers
algorithmthe algorithm to initialize

◆ init_vars() [3/3]

void gams::controllers::HiveController::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.

Parameters
controller_indexthe index of the managed controllers
platformthe platform to initialize

◆ refresh_vars()

void gams::controllers::HiveController::refresh_vars ( bool  init_non_self_vars = false)

Calls init_vars for each controller.

Useful after clearing knowledge to repopulate the self identifying variables

Parameters
init_non_self_varsif true, populate agent vars for swarm, which is very memory expensive with 400+

◆ resize()

void gams::controllers::HiveController::resize ( size_t  init_id,
size_t  num_controllers,
bool  init_non_self_vars = false 
)

Resizes the number of controllers and knowledge bases.

Parameters
init_idinitial id of the controlled hive
num_controllersthe number of controllers to manage
init_non_self_varsif true, populate agent vars for swarm, which is very memory expensive with 400+

◆ run() [1/2]

int gams::controllers::HiveController::run ( double  loop_period,
double  max_runtime = -1,
double  send_period = -1.0 
)

Runs iterations of the MAPE loop with specified periods.

Parameters
loop_periodtime(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_runtimemaximum total runtime to execute the MAPE loops
send_periodtime(in seconds) between sending data. If send_period <= 0, send period will use the loop period.
Returns
the result of the MAPE loop

◆ run() [2/2]

int gams::controllers::HiveController::run ( void  )

Runs iterations of the MAPE loop with configured settings.

Returns
the result of the MAPE loop

◆ run_hz()

int gams::controllers::HiveController::run_hz ( double  loop_hz = 0.0,
double  max_runtime = -1,
double  send_hz = -1.0 
)
inline

Runs iterations of the MAPE loop with specified hertz.

Parameters
loop_hzthe intended hz at which the loop should execute. anything non-negative is valid. 0hz is treated as as infinite hertz
max_runtimemaximum total runtime to execute the MAPE loops
send_hzthe intended hz at which updates should be sent. If non-positive, loop_hz is used.
Returns
the result of the MAPE loop

Definition at line 397 of file HiveController.h.

◆ run_once()

int gams::controllers::HiveController::run_once ( void  )

Runs a single iteration of the MAPE loop Always sends updates after the iteration.

Returns
the result of the MAPE loop iteration

◆ set_hive()

void gams::controllers::HiveController::set_hive ( madara::knowledge::Hive &  hive)
inline

Sets the hive to control a portion of.

Parameters
hivethe hive to control

Definition at line 367 of file HiveController.h.

Member Data Documentation

◆ controllers_

std::vector<BaseController *> gams::controllers::HiveController::controllers_
protected

Controllers that need to be instrumented.

Definition at line 426 of file HiveController.h.

◆ hive_

madara::knowledge::Hive* gams::controllers::HiveController::hive_
protected

Pointer to a hive mind managed by parent.

Definition at line 429 of file HiveController.h.

◆ offset_

size_t gams::controllers::HiveController::offset_
protected

the starting id within offsets and transports

Definition at line 423 of file HiveController.h.

◆ settings_

ControllerSettings gams::controllers::HiveController::settings_
protected

Settings for controller management and qos.

Definition at line 432 of file HiveController.h.


The documentation for this class was generated from the following file: