cppyabm  1.0.17
An agent-based library to integrate C++ and Python
Public Member Functions | Public Attributes | List of all members
Env< ENV, AGENT, PATCH > Struct Template Reference

Base class for environment. More...

#include <bases.h>

Public Member Functions

 Env ()
 
virtual ~Env ()
 
virtual shared_ptr< PATCH > generate_patch (MESH_ITEM)
 
virtual shared_ptr< AGENT > generate_agent (string class_name)
 A template class to generate patch. More...
 
virtual void update_repo ()
 A template class to generate agent. More...
 
void setup_domain (vector< MESH_ITEM > mesh)
 Sets up the domain by creating patch objects in accordance to mesh objects. More...
 
void setup_agents (map< string, unsigned > config)
 Creates agents and randomly distributes them in the simulation domain. More...
 
void step_agents ()
 Calls step function of agents. More...
 
void step_patches ()
 Calls step function of patches. More...
 
virtual void update ()
 Update the world. All built-in utilities such as Agent::order_move are executed here. More...
 
void place_agent (shared_ptr< PATCH > patch, shared_ptr< AGENT > agent)
 Places the given agent in the given patch. Raises an exception if the patch is not available. More...
 
void place_agent (unsigned patch_index, shared_ptr< AGENT > agent)
 Places the given agent in the given patch index. Raises an exception if the patch is not available. More...
 
void place_agent_randomly (shared_ptr< AGENT > agent)
 Places the given agent randomly in the domain. Raises exception if no patch is available. More...
 
shared_ptr< PATCH > find_empty_patch ()
 Finds empty patches in the entire domain. More...
 
void remove_agent (shared_ptr< AGENT > agent)
 
void process_switch ()
 Process swtich requests. More...
 
void process_hatch ()
 Process hatch requests. More...
 
void process_move ()
 Process move requests. More...
 
void process_disappear ()
 Process disappear requests. More...
 
virtual void step ()
 
map< string, unsigned > count_agents ()
 steps the simulation More...
 
double memory_usage ()
 
 Env ()
 
virtual ~Env ()
 
virtual shared_ptr< PATCH > generate_patch (MESH_ITEM)
 
virtual shared_ptr< AGENT > generate_agent (string class_name)
 A template class to generate patch. More...
 
virtual void update_repo ()
 A template class to generate agent. More...
 
void setup_domain (vector< MESH_ITEM > mesh)
 Sets up the domain by creating patch objects in accordance to mesh objects. More...
 
void setup_agents (map< string, unsigned > config)
 Creates agents and randomly distributes them in the simulation domain. More...
 
void step_agents ()
 Calls step function of agents. More...
 
void step_patches ()
 Calls step function of patches. More...
 
virtual void update ()
 Update the world. All built-in utilities such as Agent::order_move are executed here. More...
 
void place_agent (shared_ptr< PATCH > patch, shared_ptr< AGENT > agent)
 Places the given agent in the given patch. Raises an exception if the patch is not available. More...
 
void place_agent (unsigned patch_index, shared_ptr< AGENT > agent)
 Places the given agent in the given patch index. Raises an exception if the patch is not available. More...
 
void place_agent_randomly (shared_ptr< AGENT > agent)
 Places the given agent randomly in the domain. Raises exception if no patch is available. More...
 
shared_ptr< PATCH > find_empty_patch ()
 Finds empty patches in the entire domain. More...
 
void remove_agent (shared_ptr< AGENT > agent)
 
void process_switch ()
 Process swtich requests. More...
 
void process_hatch ()
 Process hatch requests. More...
 
void process_move ()
 Process move requests. More...
 
void process_disappear ()
 Process disappear requests. More...
 
virtual void step ()
 
map< string, unsigned > count_agents ()
 steps the simulation More...
 
double memory_usage ()
 

Public Attributes

std::map< std::string, unsigned > agents_count
 Keeps the record the agents according to Agent::class_name. More...
 
std::set< string > agent_classes
 stores a list of Agent::class_name. More...
 
vector< shared_ptr< AGENT > > agents
 Agent container. More...
 
map< unsigned, shared_ptr< PATCH > > patches
 Patch container. More...
 

Detailed Description

template<class ENV, class AGENT, class PATCH>
struct Env< ENV, AGENT, PATCH >

Base class for environment.

Env class stores and coordinates agents and patches.

Definition at line 145 of file bases.h.

Constructor & Destructor Documentation

◆ Env() [1/2]

template<class ENV , class AGENT , class PATCH >
Env< ENV, AGENT, PATCH >::Env ( )
inline

Definition at line 146 of file bases.h.

◆ ~Env() [1/2]

template<class ENV , class AGENT , class PATCH >
virtual Env< ENV, AGENT, PATCH >::~Env ( )
inlinevirtual

Definition at line 147 of file bases.h.

◆ Env() [2/2]

template<class ENV , class AGENT , class PATCH >
Env< ENV, AGENT, PATCH >::Env ( )
inline

Definition at line 146 of file bases.h.

◆ ~Env() [2/2]

template<class ENV , class AGENT , class PATCH >
virtual Env< ENV, AGENT, PATCH >::~Env ( )
inlinevirtual

Definition at line 147 of file bases.h.

Member Function Documentation

◆ count_agents() [1/2]

template<class ENV , class AGENT , class PATCH >
map< string, unsigned > Env< ENV, AGENT, PATCH >::count_agents ( )
inline

steps the simulation

Counts the agents according to Agent::class_name.

Definition at line 424 of file bases.h.

◆ count_agents() [2/2]

template<class ENV , class AGENT , class PATCH >
map<string,unsigned> Env< ENV, AGENT, PATCH >::count_agents ( )

steps the simulation

Counts the agents according to Agent::class_name.

◆ find_empty_patch() [1/2]

template<class ENV , class AGENT , class PATCH >
shared_ptr< PATCH > Env< ENV, AGENT, PATCH >::find_empty_patch ( )
inline

Finds empty patches in the entire domain.

Definition at line 481 of file bases.h.

◆ find_empty_patch() [2/2]

template<class ENV , class AGENT , class PATCH >
shared_ptr<PATCH> Env< ENV, AGENT, PATCH >::find_empty_patch ( )

Finds empty patches in the entire domain.

◆ generate_agent() [1/2]

template<class ENV , class AGENT , class PATCH >
virtual shared_ptr<AGENT> Env< ENV, AGENT, PATCH >::generate_agent ( string  class_name)
inlinevirtual

A template class to generate patch.

Definition at line 151 of file bases.h.

◆ generate_agent() [2/2]

template<class ENV , class AGENT , class PATCH >
virtual shared_ptr<AGENT> Env< ENV, AGENT, PATCH >::generate_agent ( string  class_name)
inlinevirtual

A template class to generate patch.

Definition at line 151 of file bases.h.

◆ generate_patch() [1/2]

template<class ENV , class AGENT , class PATCH >
virtual shared_ptr<PATCH> Env< ENV, AGENT, PATCH >::generate_patch ( MESH_ITEM  )
inlinevirtual

Reimplemented in Domain, and Domain.

Definition at line 148 of file bases.h.

◆ generate_patch() [2/2]

template<class ENV , class AGENT , class PATCH >
virtual shared_ptr<PATCH> Env< ENV, AGENT, PATCH >::generate_patch ( MESH_ITEM  )
inlinevirtual

Reimplemented in Domain, and Domain.

Definition at line 148 of file bases.h.

◆ memory_usage() [1/2]

template<class ENV , class AGENT , class PATCH >
double Env< ENV, AGENT, PATCH >::memory_usage ( )
inline

Definition at line 195 of file bases.h.

◆ memory_usage() [2/2]

template<class ENV , class AGENT , class PATCH >
double Env< ENV, AGENT, PATCH >::memory_usage ( )
inline

Definition at line 195 of file bases.h.

◆ place_agent() [1/4]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::place_agent ( shared_ptr< PATCH >  patch,
shared_ptr< AGENT >  agent 
)
inline

Places the given agent in the given patch. Raises an exception if the patch is not available.

Definition at line 443 of file bases.h.

◆ place_agent() [2/4]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::place_agent ( shared_ptr< PATCH >  patch,
shared_ptr< AGENT >  agent 
)

Places the given agent in the given patch. Raises an exception if the patch is not available.

◆ place_agent() [3/4]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::place_agent ( unsigned  patch_index,
shared_ptr< AGENT >  agent 
)
inline

Places the given agent in the given patch index. Raises an exception if the patch is not available.

Definition at line 457 of file bases.h.

◆ place_agent() [4/4]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::place_agent ( unsigned  patch_index,
shared_ptr< AGENT >  agent 
)

Places the given agent in the given patch index. Raises an exception if the patch is not available.

◆ place_agent_randomly() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::place_agent_randomly ( shared_ptr< AGENT >  agent)
inline

Places the given agent randomly in the domain. Raises exception if no patch is available.

Definition at line 476 of file bases.h.

◆ place_agent_randomly() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::place_agent_randomly ( shared_ptr< AGENT >  agent)

Places the given agent randomly in the domain. Raises exception if no patch is available.

◆ process_disappear() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::process_disappear ( )
inline

Process disappear requests.

Definition at line 391 of file bases.h.

◆ process_disappear() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::process_disappear ( )

Process disappear requests.

◆ process_hatch() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::process_hatch ( )
inline

Process hatch requests.

Definition at line 332 of file bases.h.

◆ process_hatch() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::process_hatch ( )

Process hatch requests.

◆ process_move() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::process_move ( )
inline

Process move requests.

Definition at line 282 of file bases.h.

◆ process_move() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::process_move ( )

Process move requests.

◆ process_switch() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::process_switch ( )
inline

Process swtich requests.

Definition at line 408 of file bases.h.

◆ process_switch() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::process_switch ( )

Process swtich requests.

◆ remove_agent() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::remove_agent ( shared_ptr< AGENT >  agent)
inline

Definition at line 165 of file bases.h.

◆ remove_agent() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::remove_agent ( shared_ptr< AGENT >  agent)
inline

Definition at line 165 of file bases.h.

◆ setup_agents() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::setup_agents ( map< string, unsigned >  config)
inline

Creates agents and randomly distributes them in the simulation domain.

Definition at line 255 of file bases.h.

◆ setup_agents() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::setup_agents ( map< string, unsigned >  config)

Creates agents and randomly distributes them in the simulation domain.

◆ setup_domain() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::setup_domain ( vector< MESH_ITEM mesh)
inline

Sets up the domain by creating patch objects in accordance to mesh objects.

Definition at line 499 of file bases.h.

◆ setup_domain() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::setup_domain ( vector< MESH_ITEM mesh)

Sets up the domain by creating patch objects in accordance to mesh objects.

◆ step() [1/2]

template<class ENV , class AGENT , class PATCH >
virtual void Env< ENV, AGENT, PATCH >::step ( )
inlinevirtual

Reimplemented in Domain, and Domain.

Definition at line 185 of file bases.h.

◆ step() [2/2]

template<class ENV , class AGENT , class PATCH >
virtual void Env< ENV, AGENT, PATCH >::step ( )
inlinevirtual

Reimplemented in Domain, and Domain.

Definition at line 185 of file bases.h.

◆ step_agents() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::step_agents ( )
inline

Calls step function of agents.

Definition at line 242 of file bases.h.

◆ step_agents() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::step_agents ( )

Calls step function of agents.

◆ step_patches() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::step_patches ( )
inline

Calls step function of patches.

Definition at line 248 of file bases.h.

◆ step_patches() [2/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::step_patches ( )

Calls step function of patches.

◆ update() [1/2]

template<class ENV , class AGENT , class PATCH >
void Env< ENV, AGENT, PATCH >::update ( )
inlinevirtual

Update the world. All built-in utilities such as Agent::order_move are executed here.

move

hatch

switch

process disappearing

Reimplemented in Domain, and Domain.

Definition at line 266 of file bases.h.

◆ update() [2/2]

template<class ENV , class AGENT , class PATCH >
virtual void Env< ENV, AGENT, PATCH >::update ( )
virtual

Update the world. All built-in utilities such as Agent::order_move are executed here.

Reimplemented in Domain, and Domain.

◆ update_repo() [1/2]

template<class ENV , class AGENT , class PATCH >
virtual void Env< ENV, AGENT, PATCH >::update_repo ( )
inlinevirtual

A template class to generate agent.

To remove the dead agents from the repo. This needs to be implemented.

Definition at line 154 of file bases.h.

◆ update_repo() [2/2]

template<class ENV , class AGENT , class PATCH >
virtual void Env< ENV, AGENT, PATCH >::update_repo ( )
inlinevirtual

A template class to generate agent.

To remove the dead agents from the repo. This needs to be implemented.

Definition at line 154 of file bases.h.

Member Data Documentation

◆ agent_classes

template<class ENV , class AGENT , class PATCH >
std::set< string > Env< ENV, AGENT, PATCH >::agent_classes

stores a list of Agent::class_name.

Definition at line 192 of file bases.h.

◆ agents

template<class ENV , class AGENT , class PATCH >
vector< shared_ptr< AGENT > > Env< ENV, AGENT, PATCH >::agents

Agent container.

Definition at line 193 of file bases.h.

◆ agents_count

template<class ENV , class AGENT , class PATCH >
std::map< std::string, unsigned > Env< ENV, AGENT, PATCH >::agents_count

Keeps the record the agents according to Agent::class_name.

Definition at line 191 of file bases.h.

◆ patches

template<class ENV , class AGENT , class PATCH >
map< unsigned, shared_ptr< PATCH > > Env< ENV, AGENT, PATCH >::patches

Patch container.

Definition at line 194 of file bases.h.


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