fpmas 1.6
Namespaces | Typedefs | Functions
fpmas Namespace Reference

Namespaces

namespace  api
 
namespace  communication
 
namespace  exceptions
 
namespace  graph
 
namespace  io
 
namespace  load_balancing
 
namespace  model
 
namespace  random
 
namespace  runtime
 
namespace  scheduler
 
namespace  synchro
 
namespace  utils
 

Typedefs

template<typename Agent >
using TypedAgentPtr = api::utils::PtrWrapper< Agent >
 

Functions

void init (int argc, char **argv)
 
void finalize ()
 
void seed (unsigned long seed)
 
std::string to_string (const api::graph::DistributedId &id)
 
std::string to_string (const api::model::DiscretePoint &point)
 
template<>
void register_types< void > ()
 
template<typename _T , typename... T>
void register_types ()
 
template<>
void register_types< void > ()
 

Detailed Description

Main fpmas namespace.

Typedef Documentation

◆ TypedAgentPtr

template<typename Agent >
using fpmas::TypedAgentPtr = typedef api::utils::PtrWrapper<Agent>

Typed Agent pointer.

Contrary to api::model::AgentPtr, that represents a polymorphic Agent (i.e. api::utils::PtrWrapper<api::model::Agent>), this pointer is used to wrap a concrete Agent type (e.g. api::utils::PtrWrapper<UserAgent1>).

This type is notably used to define json serialization rules for user defined Agent types.

Template Parameters
Agentconcrete agent type

Function Documentation

◆ init()

void fpmas::init ( int  argc,
char **  argv 
)

Initializes FPMAS.

This must be call before any MPI communication or Model initialization is performed.

fpmas::seed(fpmas::default_seed) is called unless an other fpmas::seed() was performed before fpmas::init()

◆ finalize()

void fpmas::finalize ( )

Finalizes FPMAS.

No FPMAS calls are assumed to be performed after this call. Moreover, notice that because this function calls MPI_Finalize, all FPMAS related structures must have been destroyed to avoid unexpected behaviors. This can be easily achieved using blocks.

Example
#include "fpmas.h"
...
int main(int argc, char** argv) {
// Initializes MPI and FPMAS related structures
fpmas::init(argc, argv);
{
// Beginning of Model scope
fpmas::model::DefaultModel model;
...
// End of Model scope : model is destroyed
}
}
void finalize()
Definition: fpmas.cpp:18
void init(int argc, char **argv)
Definition: fpmas.cpp:6

◆ seed()

void fpmas::seed ( unsigned long  seed)

Seeds internal random generators.

Currently calls:

Those are currently the only static random generators used internally in an FPMAS simulation, so seeding them ensures reproducibility.

The provided seed is not passed directly to the generators: distinct seeds are generated using a deterministic method for each generator (if the same seed was provided to all generators, they would produce exactly the same sequence. Even if their use case is different, this might introduce some bias).

This method does not directly affect user defined random generators, but the provided seed is stored in the fpmas::random::seed static variable, so that it can be used by user defined generators while controlling them with this fpmas::seed() method.

Warning
Even if this ensures that random number sequences are the same for each execution with a given seed, the execution of some simulations can't be considered deterministic due to message exchanges across processors in fpmas::synchro::hard::HardSyncMode for example. Indeed, the relative speed of each process cannot be guaranteed, and the receiving order of some message sequences might alter some agent behavior. However, simulations executed using the fpmas::synchro::ghost::GhostMode will be deterministic.
Parameters
seedrandom seed

◆ to_string() [1/2]

std::string fpmas::to_string ( const api::graph::DistributedId id)

Converts an api::graph::DistributedId instance to a string representation, in the form [id.rank(), id.id()].

Parameters
idid to convert to std::string
Returns
string representation of id

◆ to_string() [2/2]

std::string fpmas::to_string ( const api::model::DiscretePoint point)

DiscretePoint string conversion.

Parameters
pointpoint to convert
Returns
string representation of the point

◆ register_types< void >() [1/2]

template<>
void fpmas::register_types< void > ( )

Register_types recursion base case.

◆ register_types()

template<typename _T , typename... T>
void fpmas::register_types ( )

Recursive function template used to register a set of types into the adl_serializer<std::type_index> and io::datapack::base_io<std::type_index>, so that their corresponding std::type_index can be serialized.

The last type specified MUST be void for the recursion to be valid.

Example
fpmas::register_types<Type1, Type2, void>();

The FPMAS_REGISTER_AGENT_TYPES(...) macro can be used instead as a more expressive and user-friendly way to register types.

◆ register_types< void >() [2/2]

template<>
void fpmas::register_types< void > ( )

Register_types recursion base case.