Skip to content

Class Agent

template <typename TSeq>

ClassList > Agent

Agent (agents)More...

  • #include <agent-bones.hpp>

Public Functions

Type Name
Agent () = default
Agent (Agent< TSeq > && p)
Agent (const Agent< TSeq > & p)
void add_entity (Model< TSeq > & model, Entity< TSeq > & entity, epiworld_fast_int state_new=-99, epiworld_fast_int queue=-99)
void add_neighbor (Agent< TSeq > & p, bool check_source=true, bool check_target=true)
void add_tool (Model< TSeq > & model, const Tool< TSeq > & tool, epiworld_fast_int state_new=-99, epiworld_fast_int queue=-99)
void change_state (Model< TSeq > & model, epiworld_fast_uint new_state, epiworld_fast_int queue=0)
epiworld_double get_death_reduction (VirusPtr< TSeq > & v, Model< TSeq > & model)
const std::vector< size_t > & get_entities () const
const Entity< TSeq > & get_entity (size_t i, const Model< TSeq > & model) const
Entity< TSeq > & get_entity (size_t i, Model< TSeq > & model)
int get_id () const
Id of the individual.
size_t get_n_entities () const
size_t get_n_neighbors () const
size_t get_n_tools () noexcept const
std::vector< Agent< TSeq > * > get_neighbors (Model< TSeq > & model)
epiworld_double get_recovery_enhancer (VirusPtr< TSeq > & v, Model< TSeq > & model)
const unsigned int & get_state () const
const unsigned int & get_state_prev () const
epiworld_double get_susceptibility_reduction (VirusPtr< TSeq > & v, Model< TSeq > & model)
ToolPtr< TSeq > & get_tool (int i)
ToolPtr< TSeq > & get_tool (std::string name)
std::vector< ToolPtr< TSeq > > get_tools ()
const std::vector< ToolPtr< TSeq > > get_tools () const
epiworld_double get_transmission_reduction (VirusPtr< TSeq > & v, Model< TSeq > & model)
VirusPtr< TSeq > & get_virus ()
const VirusPtr< TSeq > & get_virus () const
bool has_entity (epiworld_fast_uint t) const
bool has_entity (std::string_view name, const Model< TSeq > & model) const
bool has_tool (epiworld_fast_uint t) const
bool has_tool (std::string_view name) const
bool has_tool (const Tool< TSeq > & t) const
bool has_virus (epiworld_fast_uint t) const
bool has_virus (std::string_view name) const
bool has_virus (const Virus< TSeq > & v) const
void mutate_virus ()
bool operator!= (const Agent< TSeq > & other) const
double & operator() (size_t j, Model< TSeq > & model)
Access the j-th column of the agent.
double operator() (size_t j, const Model< TSeq > & model) const
Agent< TSeq > & operator= (const Agent< TSeq > & other_agent)
bool operator== (const Agent< TSeq > & other) const
void print (Model< TSeq > & model, bool compressed=false) const
void rm_agent_by_virus (Model< TSeq > & model) = delete
Agent removed by virus.
void rm_entity (Model< TSeq > & model, epiworld_fast_uint entity_idx, epiworld_fast_int state_new=-99, epiworld_fast_int queue=-99)
void rm_entity (Model< TSeq > & model, Entity< TSeq > & entity, epiworld_fast_int state_new=-99, epiworld_fast_int queue=-99)
void rm_tool (Model< TSeq > & model, epiworld_fast_uint tool_idx, epiworld_fast_int state_new=-99, epiworld_fast_int queue=-99)
void rm_tool (Model< TSeq > & model, ToolPtr< TSeq > & tool, epiworld_fast_int state_new=-99, epiworld_fast_int queue=-99)
void rm_virus (Model< TSeq > & model, epiworld_fast_int state_new=-99, epiworld_fast_int queue=-99)
void set_virus (Model< TSeq > & model, const Virus< TSeq > & virus, epiworld_fast_int state_new=-99, epiworld_fast_int queue=-99)
void swap_neighbors (Agent< TSeq > & other, size_t n_this, size_t n_other, Model< TSeq > & model)
Swaps neighbors between the current agent and agent other __
~Agent ()

Protected Attributes

Type Name
std::vector< size_t > entities
Entity IDs (indices intoModel::entities )
int id = -1
size_t n_neighbors = 0u
std::vector< size_t > * neighbors = nullptr
std::vector< size_t > * neighbors_locations = nullptr
unsigned int state = 0u
int state_last_changed = -1
Last time the agent was updated.
unsigned int state_prev = 0u
For accounting, if need to undo a change.
std::vector< ToolPtr< TSeq > > tools
VirusPtr< TSeq > virus = nullptr

Protected Functions

Type Name
void reset ()
Resets the agent to the initial state (no virus, no tools, no entities, state 0.)

Detailed Description

Template parameters:

  • TSeq Sequence type (should match TSeq across the model)

Public Functions Documentation

function Agent [1/3]

Agent::Agent () = default

function Agent [2/3]

inline Agent::Agent (
    Agent < TSeq > && p
) 

function Agent [3/3]

inline Agent::Agent (
    const Agent < TSeq > & p
) 

function add_entity

inline void Agent::add_entity (
    Model < TSeq > & model,
    Entity < TSeq > & entity,
    epiworld_fast_int state_new=-99,
    epiworld_fast_int queue=-99
) 

function add_neighbor

inline void Agent::add_neighbor (
    Agent < TSeq > & p,
    bool check_source=true,
    bool check_target=true
) 

function add_tool

inline void Agent::add_tool (
    Model < TSeq > & model,
    const Tool < TSeq > & tool,
    epiworld_fast_int state_new=-99,
    epiworld_fast_int queue=-99
) 

function change_state

inline void Agent::change_state (
    Model < TSeq > & model,
    epiworld_fast_uint new_state,
    epiworld_fast_int queue=0
) 

function get_death_reduction

inline epiworld_double Agent::get_death_reduction (
    VirusPtr < TSeq > & v,
    Model < TSeq > & model
) 

function get_entities

inline const std::vector< size_t > & Agent::get_entities () const

function get_entity [1/2]

inline const Entity < TSeq > & Agent::get_entity (
    size_t i,
    const Model < TSeq > & model
) const

function get_entity [2/2]

inline Entity < TSeq > & Agent::get_entity (
    size_t i,
    Model < TSeq > & model
) 

function get_id

Id of the individual.

inline int Agent::get_id () const


function get_n_entities

inline size_t Agent::get_n_entities () const

function get_n_neighbors

inline size_t Agent::get_n_neighbors () const

function get_n_tools

inline size_t Agent::get_n_tools () noexcept const

function get_neighbors

inline std::vector< Agent < TSeq > * > Agent::get_neighbors (
    Model < TSeq > & model
) 

function get_recovery_enhancer

inline epiworld_double Agent::get_recovery_enhancer (
    VirusPtr < TSeq > & v,
    Model < TSeq > & model
) 

function get_state

inline const unsigned int & Agent::get_state () const

function get_state_prev

inline const unsigned int & Agent::get_state_prev () const

function get_susceptibility_reduction

inline epiworld_double Agent::get_susceptibility_reduction (
    VirusPtr < TSeq > & v,
    Model < TSeq > & model
) 

function get_tool [1/2]

inline ToolPtr < TSeq > & Agent::get_tool (
    int i
) 

function get_tool [2/2]

inline ToolPtr < TSeq > & Agent::get_tool (
    std::string name
) 

function get_tools [1/2]

inline std::vector< ToolPtr < TSeq > > Agent::get_tools () 

function get_tools [2/2]

inline const std::vector< ToolPtr < TSeq > > Agent::get_tools () const

function get_transmission_reduction

inline epiworld_double Agent::get_transmission_reduction (
    VirusPtr < TSeq > & v,
    Model < TSeq > & model
) 

function get_virus [1/2]

inline VirusPtr < TSeq > & Agent::get_virus () 

function get_virus [2/2]

inline const VirusPtr < TSeq > & Agent::get_virus () const

function has_entity [1/2]

inline bool Agent::has_entity (
    epiworld_fast_uint t
) const

function has_entity [2/2]

inline bool Agent::has_entity (
    std::string_view name,
    const Model < TSeq > & model
) const

function has_tool [1/3]

inline bool Agent::has_tool (
    epiworld_fast_uint t
) const

function has_tool [2/3]

inline bool Agent::has_tool (
    std::string_view name
) const

function has_tool [3/3]

inline bool Agent::has_tool (
    const Tool < TSeq > & t
) const

function has_virus [1/3]

inline bool Agent::has_virus (
    epiworld_fast_uint t
) const

function has_virus [2/3]

inline bool Agent::has_virus (
    std::string_view name
) const

function has_virus [3/3]

inline bool Agent::has_virus (
    const Virus < TSeq > & v
) const

function mutate_virus

inline void Agent::mutate_virus () 

function operator!=

inline bool Agent::operator!= (
    const Agent < TSeq > & other
) const

function operator()

Access the j-th column of the agent.

inline double & Agent::operator() (
    size_t j,
    Model < TSeq > & model
) 

If an external array has been specified, then these two functions can be used to access additional agent's features not included in the model.

Parameters:

  • j
  • model Reference to the Model

Returns:

double&


function operator()

inline double Agent::operator() (
    size_t j,
    const Model < TSeq > & model
) const

function operator=

inline Agent < TSeq > & Agent::operator= (
    const Agent < TSeq > & other_agent
) 

function operator==

inline bool Agent::operator== (
    const Agent < TSeq > & other
) const

function print

inline void Agent::print (
    Model < TSeq > & model,
    bool compressed=false
) const

function rm_agent_by_virus

Agent removed by virus.

void Agent::rm_agent_by_virus (
    Model < TSeq > & model
) = delete


function rm_entity [1/2]

inline void Agent::rm_entity (
    Model < TSeq > & model,
    epiworld_fast_uint entity_idx,
    epiworld_fast_int state_new=-99,
    epiworld_fast_int queue=-99
) 

function rm_entity [2/2]

inline void Agent::rm_entity (
    Model < TSeq > & model,
    Entity < TSeq > & entity,
    epiworld_fast_int state_new=-99,
    epiworld_fast_int queue=-99
) 

function rm_tool [1/2]

inline void Agent::rm_tool (
    Model < TSeq > & model,
    epiworld_fast_uint tool_idx,
    epiworld_fast_int state_new=-99,
    epiworld_fast_int queue=-99
) 

function rm_tool [2/2]

inline void Agent::rm_tool (
    Model < TSeq > & model,
    ToolPtr < TSeq > & tool,
    epiworld_fast_int state_new=-99,
    epiworld_fast_int queue=-99
) 

function rm_virus

inline void Agent::rm_virus (
    Model < TSeq > & model,
    epiworld_fast_int state_new=-99,
    epiworld_fast_int queue=-99
) 

function set_virus

inline void Agent::set_virus (
    Model < TSeq > & model,
    const Virus < TSeq > & virus,
    epiworld_fast_int state_new=-99,
    epiworld_fast_int queue=-99
) 

function swap_neighbors

Swaps neighbors between the current agent and agent other __

inline void Agent::swap_neighbors (
    Agent < TSeq > & other,
    size_t n_this,
    size_t n_other,
    Model < TSeq > & model
) 

Parameters:

  • other
  • n_this
  • n_other

function ~Agent

inline Agent::~Agent () 

Protected Attributes Documentation

variable entities

Entity IDs (indices intoModel::entities )

std::vector< size_t > Agent< TSeq >::entities;


variable id

int Agent< TSeq >::id;

variable n_neighbors

size_t Agent< TSeq >::n_neighbors;

variable neighbors

std::vector< size_t >* Agent< TSeq >::neighbors;

variable neighbors_locations

std::vector< size_t >* Agent< TSeq >::neighbors_locations;

variable state

unsigned int Agent< TSeq >::state;

variable state_last_changed

Last time the agent was updated.

int Agent< TSeq >::state_last_changed;


variable state_prev

For accounting, if need to undo a change.

unsigned int Agent< TSeq >::state_prev;


variable tools

std::vector< ToolPtr<TSeq> > Agent< TSeq >::tools;

variable virus

VirusPtr<TSeq> Agent< TSeq >::virus;

Protected Functions Documentation

function reset

Resets the agent to the initial state (no virus, no tools, no entities, state 0.)

inline void Agent::reset () 



The documentation for this class was generated from the following file epiworld-src/include/epiworld/agent-bones.hpp