![]() |
The ROme OpTimistic Simulator
2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
|
ROOT-Sim header for model development. More...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <argp.h>
Go to the source code of this file.
Macros | |
#define | INIT 0 |
This is the message code which is sent by the simulation kernel upon startup. | |
#define | INFTY DBL_MAX |
Infinite timestamp: this is the highest timestamp in a simulation run. | |
Typedefs | |
typedef double | simtime_t |
This defines the type with whom timestamps are represented. | |
typedef enum _direction_t | direction_t |
typedef unsigned long long | agent_t |
Enumerations | |
enum | _topology_geometry_t { TOPOLOGY_GEOMETRY_OFFSET = 1000, TOPOLOGY_HEXAGON = TOPOLOGY_GEOMETRY_OFFSET, TOPOLOGY_SQUARE, TOPOLOGY_RING, TOPOLOGY_BIDRING, TOPOLOGY_TORUS, TOPOLOGY_STAR, TOPOLOGY_GRAPH } |
enum | _direction_t { DIRECTION_E = 0, DIRECTION_W = 1, DIRECTION_N = 2, DIRECTION_S = 3, DIRECTION_NE = 2, DIRECTION_SW = 3, DIRECTION_NW = 4, DIRECTION_SE = 5, DIRECTION_INVALID = UINT_MAX } |
enum | _topology_type_t { TOPOLOGY_OBSTACLES, TOPOLOGY_COSTS, TOPOLOGY_PROBABILITIES } |
Functions | |
__attribute ((weak)) extern struct argp model_argp | |
This can be implemented by the model for smart argument handling. More... | |
double | Random (void) |
int | RandomRange (int min, int max) |
int | RandomRangeNonUniform (int x, int min, int max) |
double | Expent (double mean) |
double | Normal (void) |
double | Gamma (int ia) |
double | Poisson (void) |
int | Zipf (double skew, int limit) |
void | SetState (void *new_state) |
double | GetValueTopology (unsigned from, unsigned to) |
void | SetValueTopology (unsigned from, unsigned to, double value) |
unsigned int | FindReceiver (void) |
unsigned int | RegionsCount (void) |
unsigned int | DirectionsCount (void) |
unsigned int | NeighboursCount (unsigned int region) |
unsigned int | GetReceiver (unsigned int from, direction_t direction, bool reachable) |
unsigned int | FindReceiverToward (unsigned int to) |
double | ComputeMinTour (unsigned int source, unsigned int dest, unsigned int result[RegionsCount()]) |
int | GetNeighbourInfo (direction_t i, unsigned int *region_id, void **data_p) |
void | TrackNeighbourInfo (void *neighbour_data) |
bool | IterAgents (agent_t *agent_p) |
unsigned | CountAgents (void) |
agent_t | SpawnAgent (unsigned user_data_size) |
void | KillAgent (agent_t agent) |
void * | DataAgent (agent_t agent, unsigned *data_size_p) |
void | ScheduleNewLeaveEvent (simtime_t time, unsigned int event_type, agent_t agent) |
unsigned | CountVisits (const agent_t agent) |
void | GetVisit (const agent_t agent, unsigned *region_p, unsigned *event_type_p, unsigned i) |
void | SetVisit (const agent_t agent, unsigned region, unsigned event_type, unsigned i) |
void | EnqueueVisit (agent_t agent, unsigned region, unsigned event_type) |
void | AddVisit (agent_t agent, unsigned region, unsigned event_type, unsigned i) |
void | RemoveVisit (agent_t agent, unsigned i) |
unsigned | CountPastVisits (const agent_t agent) |
void | GetPastVisit (const agent_t agent, unsigned *region_p, unsigned *event_type_p, simtime_t *time_p, unsigned i) |
Variables | |
unsigned int | n_prc_tot |
This is the definition of the number of LPs running in the current simulation. More... | |
void(* | ScheduleNewEvent )(unsigned int receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size) |
This is the function pointer to correctly set ScheduleNewEvent API version, depending if we're running serially or in parallel. | |
topology_settings | |
abm_settings | |
ROOT-Sim header for model development.
This header defines all the symbols which are needed to develop a model to be simulated on top of ROOT-Sim.
This header is the only file which should be included when developing a simulation model. All function prototypes exposed to the application developer are exposed and defined here.
This file is part of ROOT-Sim (ROme OpTimistic Simulator).
ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.
ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Definition in file ROOT-Sim.h.
typedef enum _direction_t direction_t |
These are the supported basic directions: TOPOLOGY_HEXAGON recognizes E, W, NE, SW, NW, SE TOPOLOGY_SQUARE and TOPOLOGY_TORUS recognize E, W, N, S TOPOLOGY_RING recognizes E TOPOLOGY_BIDRING recognizes E, W TOPOLOGY_STAR xxx to implement TOPOLOGY_GRAPH directions are actually directly mapped to the LPs IDs The enum layout is intentional: do not modify it if you don't know what you're doing!
enum _direction_t |
These are the supported basic directions: TOPOLOGY_HEXAGON recognizes E, W, NE, SW, NW, SE TOPOLOGY_SQUARE and TOPOLOGY_TORUS recognize E, W, N, S TOPOLOGY_RING recognizes E TOPOLOGY_BIDRING recognizes E, W TOPOLOGY_STAR xxx to implement TOPOLOGY_GRAPH directions are actually directly mapped to the LPs IDs The enum layout is intentional: do not modify it if you don't know what you're doing!
Definition at line 110 of file ROOT-Sim.h.
enum _topology_geometry_t |
This are the supported topology geometries
Definition at line 88 of file ROOT-Sim.h.
enum _topology_type_t |
Definition at line 125 of file ROOT-Sim.h.
__attribute | ( | (weak) | ) |
This can be implemented by the model for smart argument handling.
Defining this struct in the model source code activates the topology subsystem.
The topology type the model wants to use
The default geometry to use when nothing else is specified
The minimum number of LPs needed out of the topology
This is set if the model needs to use SetTopology()
Definition at line 134 of file ROOT-Sim.h.
double Expent | ( | double | mean | ) |
This function returns a random number according to an Exponential distribution. The mean value of the distribution must be passed as the mean value.
mean | Mean value of the distribution |
Definition at line 120 of file numerical.c.
double Gamma | ( | int | ia | ) |
This function returns a number in according to a Gamma Distribution of Integer Order ia, a waiting time to the ia-th event in a Poisson process of unit mean.
ia | Integer Order of the Gamma Distribution |
Definition at line 179 of file numerical.c.
double GetValueTopology | ( | unsigned | from, |
unsigned | to | ||
) |
TODO Documentation!
from | |
to |
Definition at line 288 of file topology.c.
double Normal | ( | void | ) |
This function returns a number according to a Normal Distribution with mean 0
Definition at line 141 of file numerical.c.
double Poisson | ( | void | ) |
This function returns the waiting time to the next event in a Poisson process of unit mean.
Definition at line 223 of file numerical.c.
double Random | ( | void | ) |
This function returns a number in between (0,1), according to a Uniform Distribution. It is based on Multiply with Carry by George Marsaglia
Definition at line 80 of file numerical.c.
void SetState | ( | void * | new_state | ) |
void SetValueTopology | ( | unsigned | from, |
unsigned | to, | ||
double | value | ||
) |
Change the weight assigned to the link between region from to region to. A link is intended as a crossable edge on the topology graph. A weight has different meanings depending on the _topology_type_t of the topology. For TOPOLOGY_COSTS it's the cost to pay to cross the link For TOPOLOGY_PROBABILITIES it's the weight of the probability to choose that link during movement. In other words given a region n0 having self weight w0 having links to regions n1 n2 n3 n4... with weights w1 w2 w3 w4 the probability of choosing region nk as next hop is wk/(w0+w1+w2+w3...)
from | the LP id of the source region of the link |
to | the LP id of the sink region of the link |
value | the new weight to be assigned to the link |
Definition at line 261 of file topology.c.
int Zipf | ( | double | skew, |
int | limit | ||
) |
This function returns a random sample from a Zipf distribution. Based on the rejection method by Luc Devroye for sampling: "Non-Uniform Random Variate Generation, page 550, Springer-Verlag, 1986
skew | The skew of the distribution |
limit | The largest sample to retrieve |
Definition at line 237 of file numerical.c.