ssim Namespace Reference

name space for the Siena simulator. More...

## Classes

struct | Action
class | cMessage

cMessage class for OMNET++ API compatibility. This provides a heavier message class than Sim::Event, with short 'kind' and std::string 'name' attributes. The events by default are scheduled using cProcess::scheduleAt(), and handled using cProcess::handleMessage() (as per OMNET++). NB: cProcess::scheduleAt() uses simulation time rather than time in state (which is used by Sim::self_signal_event()). More...

class | CostReport
| CostReport class for collecting statistics on costs. More...
class | cProcess
| cProcess class for OMNET++ API compatibility. More...
class | Event
| basic event in the simulation. More...
class | EventReport
| EventReport class for collecting statistics on person-time, prevalence and numbers of events. More...
class | heap
class | Means
| Utility class to incrementally add values to calculate the mean, sum, variance and standard deviation. This could be replaced by boost::accumulator. More...
struct | PDescr
class | pqueue
struct | pqueueElement
struct | pqueueElementComparator
class | Process
| Virtual class (interface) representing processes running within the simulator. More...
class | ProcessWithPId
| utility Process class providing a utility interface with the simulator. More...
class | Rng
class | RngStream
class | Rpexp
| Rpexp is a random number generator class for piecewise constant hazards. Given time lower bounds t and piecewise constant hazards h, rand() returns a random time. The random number is calculated using the inversion formula. Constructors provided for arrays. More...
class | Sim
| a generic discrete-event sequential simulator More...
class | SimErrorHandler
| an error handler for simulation errors. More...
class | SimImpl
class | SimpleReport
| SimpleReport class for collecting data for homogeneous fields of type T with string names. More...
class | SummaryReport
| SummaryReport class for collecting statistics on person-time, prevalence, events and costs. More...

## Typedefs

typedef heap< Action > | a_table_t
typedef std::vector< PDescr > | PsTable
typedef a_table_t::iterator | ForwardIterator
typedef Time | simtime_t
| simtime_t typedef for OMNET++ API compatibility More...
typedef int | ProcessId
| process identifier type More...
typedef double | Time
| virtual time type More...
typedef std::function< bool(const Event *)> | EventPredicate

## Enumerations

enum | ActionType { A_Event, A_Init, A_Stop, A_Ignore, A_Event, A_Init, A_Stop, A_Ignore }
enum | ActionType { A_Event, A_Init, A_Stop, A_Ignore, A_Event, A_Init, A_Stop, A_Ignore }

## Functions

double | rweibullHR (double shape, double scale, double hr)
| Random Weibull distribution for a given shape, scale and hazard ratio. More...
Time | now ()
| now() function for compatibility with C++SIM More...
Time | simTime ()
| simTime() function for OMNET++ API compatibility More...
void | r_create_current_stream ()
| A utility function to create the current_stream. Used when initialising the microsimulation package in R. More...
void | r_remove_current_stream ()
| A utility function to remove the current_stream. Used when finalising the microsimulation package in R. More...
void | r_set_user_random_seed (double *seed)
| A utility function to set the user random seed for the simulation. More...
void | r_get_user_random_seed (double *seed)
| A utility function to set the user random seed for the simulation. More...
void | r_next_rng_substream ()
| A utility function to move to the next user random stream for the simulation. More...
void | r_rng_advance_substream (double *seed, int *n)
| A utility function to advance the random sub-stream n steps for a specified seed. More...
double * | user_unif_rand ()
void | test_rstream2 (double *x)
| Simple test of the random streams (with a stupid name) More...
RcppExport SEXP | pqueue__new (SEXP _lower)
RcppExport SEXP | pqueue__push (SEXP _ptr, SEXP _priority, SEXP event)
RcppExport SEXP | pqueue__pop (SEXP _ptr)
RcppExport SEXP | pqueue__cancel (SEXP _ptr, SEXP _predicate)
RcppExport SEXP | pqueue__empty (SEXP _ptr)
RcppExport SEXP | pqueue__clear (SEXP _ptr)
void | Rprint_actions ()
void | Cancel (std::function< bool(const cMessage *msg)> pred)
| Cancel is a function to cancel messages who satisfy a predicate. More...
void | RemoveKind (short kind)
| RemoveKind is a function to remove messages with the given kind from the queue. More...
void | CancelKind (short kind)
| CancelKind is a function to remove messages with the given kind from the queue. More...
void | RemoveName (string name)
| RemoveName is a function to remove messages with the given name from the queue. More...
void | CancelName (string name)
| CancelName is a function to remove messages with the given name from the queue. More...
void | CancelEvents ()
| CancelEvents is a function to remove messages from the queue. More...
double | discountedInterval (double start, double end, double discountRate)
| Simple function to calculate the integral between the start and end times for (1+kappa)^(-u), where kappa is the discountRate (e.g. 0.03) More...
double | discountedInterval (double y, double start, double end, double discountRate)
| Simple function to calculate the integral between the start and end times for y*(1+kappa)^(-u), where kappa is the discountRate (e.g. 0.03) More...
double | discountedPoint (double time, double discountRate)
| Simple function to calculate 1/(1+discountRate)^(time) More...
double | discountedPoint (double y, double time, double discountRate)
| Simple function to calculate y/(1+discountRate)^(time) More...
template<class T >
std::vector< std::vector< T > > | transpose (const std::vector< std::vector< T > > data)
| Function to transpose a vector of vectors. This assumes that all inner vectors have the same size and allocates space for the complete result in advance. From http://stackoverflow.com/questions/6009782/how-to-pivot-a-vector-of-vectors. More...

## Variables

static Rng * | default_stream
static Rng * | current_stream
static double | rn = 0.0
static Time | stop_time = INIT_TIME
static Time | current_time = INIT_TIME
static ProcessId | current_process = NULL_PROCESSID
static bool | running = false
static SimErrorHandler * | error_handler = 0
static a_table_t | actions
static PsTable | processes
static int | counter_id = 0
| C++ wrapper class for the RngStream library. set() sets the current R random number stream to this stream. This is compliant with being a Boost random number generator. More...
const ProcessId | NULL_PROCESSID = -1
| no process will be identified by NULL_PROCESSID More...
const Time | INIT_TIME = 0
| beginning of time More...
static Time | stop_time = INIT_TIME
static Time | current_time = INIT_TIME
static ProcessId | current_process = NULL_PROCESSID
static bool | running = false
static SimErrorHandler * | error_handler = 0
static a_table_t | actions
static PsTable | processes

## Detailed Description

name space for the Siena simulator.

This namespace groups all the types and functionalities associated with the Siena simulator. These include:

1. the simulator API

2. the base classes for processes and events

3. a few other utility classes

## Typedef Documentation

## a_table_t

typedef heap< Action > ssim::a_table_t

Definition at line 65 of file ssim.cc.

## EventPredicate

typedef std::function<bool (const Event *)> ssim::EventPredicate

Definition at line 118 of file ssim.h.

## ForwardIterator

typedef a_table_t::iterator ssim::ForwardIterator

Definition at line 129 of file ssim.cc.

## ProcessId

typedef int ssim::ProcessId

process identifier type

Definition at line 55 of file ssim.h.

## PsTable

typedef std::vector< PDescr > ssim::PsTable

Definition at line 78 of file ssim.cc.

## simtime_t

typedef Time ssim::simtime_t

simtime_t typedef for OMNET++ API compatibility

Definition at line 439 of file microsimulation.h.

## Time

typedef double ssim::Time

virtual time type

This type represents the basic time in the virtual (simulated) world. Being defined as an integer type, virtual time is a discrete quantity. The actual semantics of the time unit is determined by the simulated application. In other words, a time interval of 1 may be interpreted as one second, one year, or any other time interval, depending on the semantics of the simulated application.

See also
  Sim::advance_delay(Time), Sim::signal_event(ProcessId, const Event*, Time), and Sim::self_signal_event(const Event*, Time).

Definition at line 75 of file ssim.h.

## Enumeration Type Documentation

## ActionType [1/2]

enum ssim::ActionType

Enumerator
A_Event |
A_Init |
A_Stop |
A_Ignore |
A_Event |
A_Init |
A_Stop |
A_Ignore |

Definition at line 44 of file ssim.cc.

## ActionType [2/2]

enum ssim::ActionType

Enumerator
A_Event |
A_Init |
A_Stop |
A_Ignore |
A_Event |
A_Init |
A_Stop |
A_Ignore |

Definition at line 44 of file ssim.cc.

## Function Documentation

## Cancel()

void ssim::Cancel | ( | std::function< bool(const cMessage *msg)> | pred | ) |

inline

Cancel is a function to cancel messages who satisfy a predicate.

This works across all processes.

Definition at line 244 of file microsimulation.h.

## CancelEvents()

void ssim::CancelEvents | ( |  | ) |

inline

CancelEvents is a function to remove messages from the queue.

This works across all processes.

Definition at line 291 of file microsimulation.h.

## CancelKind()

void ssim::CancelKind | ( | short | kind | ) |

inline

CancelKind is a function to remove messages with the given kind from the queue.

This works across all processes.

Definition at line 265 of file microsimulation.h.

## CancelName()

void ssim::CancelName | ( | string | name | ) |

inline

CancelName is a function to remove messages with the given name from the queue.

This works across all processes.

Definition at line 282 of file microsimulation.h.

## discountedInterval() [1/2]

double ssim::discountedInterval | ( | double | start,
|  | double | end,
|  | double | discountRate
| ) |  |

inline

Simple function to calculate the integral between the start and end times for (1+kappa)^(-u), where kappa is the discountRate (e.g. 0.03)

Definition at line 616 of file microsimulation.h.

## discountedInterval() [2/2]

double ssim::discountedInterval | ( | double | y,
|  | double | start,
|  | double | end,
|  | double | discountRate
| ) |  |

inline

Simple function to calculate the integral between the start and end times for y*(1+kappa)^(-u), where kappa is the discountRate (e.g. 0.03)

Definition at line 625 of file microsimulation.h.

## discountedPoint() [1/2]

double ssim::discountedPoint | ( | double | time,
|  | double | discountRate
| ) |  |

inline

Simple function to calculate 1/(1+discountRate)^(time)

Definition at line 633 of file microsimulation.h.

## discountedPoint() [2/2]

double ssim::discountedPoint | ( | double | y,
|  | double | time,
|  | double | discountRate
| ) |  |

inline

Simple function to calculate y/(1+discountRate)^(time)

Definition at line 639 of file microsimulation.h.

## now()

Time ssim::now | ( |  | ) |

now() function for compatibility with C++SIM

Definition at line 9 of file microsimulation.cc.

## pqueue__cancel()

RcppExport SEXP ssim::pqueue__cancel | ( | SEXP | _ptr,
|  | SEXP | _predicate
| ) |  |

Definition at line 146 of file pqueue.cpp.

## pqueue__clear()

RcppExport SEXP ssim::pqueue__clear | ( | SEXP | _ptr | ) |

Definition at line 158 of file pqueue.cpp.

## pqueue__empty()

RcppExport SEXP ssim::pqueue__empty | ( | SEXP | _ptr | ) |

Definition at line 153 of file pqueue.cpp.

## pqueue__new()

RcppExport SEXP ssim::pqueue__new | ( | SEXP | _lower | ) |

Definition at line 128 of file pqueue.cpp.

## pqueue__pop()

RcppExport SEXP ssim::pqueue__pop | ( | SEXP | _ptr | ) |

Definition at line 141 of file pqueue.cpp.

## pqueue__push()

RcppExport SEXP ssim::pqueue__push | ( | SEXP | _ptr,
|  | SEXP | _priority,
|  | SEXP | event
| ) |  |

Definition at line 134 of file pqueue.cpp.

## r_create_current_stream()

void ssim::r_create_current_stream | ( |  | ) |

A utility function to create the current_stream. Used when initialising the microsimulation package in R.

Definition at line 32 of file microsimulation.cc.

## r_get_user_random_seed()

void ssim::r_get_user_random_seed | ( | double * | outseed | ) |

A utility function to set the user random seed for the simulation.

Definition at line 52 of file microsimulation.cc.

## r_next_rng_substream()

void ssim::r_next_rng_substream | ( |  | ) |

A utility function to move to the next user random stream for the simulation.

Definition at line 60 of file microsimulation.cc.

## r_remove_current_stream()

void ssim::r_remove_current_stream | ( |  | ) |

A utility function to remove the current_stream. Used when finalising the microsimulation package in R.

Definition at line 38 of file microsimulation.cc.

## r_rng_advance_substream()

void ssim::r_rng_advance_substream | ( | double * | inoutseed,
|  | int * | n
| ) |  |

A utility function to advance the random sub-stream n steps for a specified seed.

Definition at line 64 of file microsimulation.cc.

## r_set_user_random_seed()

void ssim::r_set_user_random_seed | ( | double * | inseed | ) |

A utility function to set the user random seed for the simulation.

Definition at line 43 of file microsimulation.cc.

## RemoveKind()

void ssim::RemoveKind | ( | short | kind | ) |

inline

RemoveKind is a function to remove messages with the given kind from the queue.

This works across all processes.

Definition at line 256 of file microsimulation.h.

## RemoveName()

void ssim::RemoveName | ( | string | name | ) |

inline

RemoveName is a function to remove messages with the given name from the queue.

This works across all processes.

Definition at line 274 of file microsimulation.h.

## Rprint_actions()

void ssim::Rprint_actions | ( |  | ) |

Definition at line 81 of file ssim.cc.

## rweibullHR()

double ssim::rweibullHR | ( | double | shape,
|  | double | scale,
|  | double | hr
| ) |  |

Random Weibull distribution for a given shape, scale and hazard ratio.

Definition at line 5 of file microsimulation.cc.

## simTime()

Time ssim::simTime | ( |  | ) |

simTime() function for OMNET++ API compatibility

Definition at line 13 of file microsimulation.cc.

## test_rstream2()

void ssim::test_rstream2 | ( | double * | x | ) |

Simple test of the random streams (with a stupid name)

Definition at line 86 of file microsimulation.cc.

## transpose()

template<class T >

std::vector<std::vector<T> > ssim::transpose | ( | const std::vector< std::vector< T > > | data | ) |

Function to transpose a vector of vectors. This assumes that all inner vectors have the same size and allocates space for the complete result in advance. From http://stackoverflow.com/questions/6009782/how-to-pivot-a-vector-of-vectors.

Definition at line 651 of file microsimulation.h.

## user_unif_rand()

double* ssim::user_unif_rand | ( |  | ) |

Definition at line 76 of file microsimulation.cc.

## Variable Documentation

## actions [1/2]

a_table_t ssim::actions

static

Definition at line 67 of file ssim.cc.

## actions [2/2]

a_table_t ssim::actions

static

Definition at line 67 of file ssim.cc.

## counter_id

int ssim::counter_id = 0

static

C++ wrapper class for the RngStream library. set() sets the current R random number stream to this stream. This is compliant with being a Boost random number generator.

Definition at line 547 of file microsimulation.h.

## current_process [1/2]

ProcessId ssim::current_process = NULL_PROCESSID

static

Definition at line 38 of file ssim.cc.

## current_process [2/2]

ProcessId ssim::current_process = NULL_PROCESSID

static

Definition at line 38 of file ssim.cc.

## current_stream

Rng * ssim::current_stream

static

Definition at line 18 of file microsimulation.cc.

## current_time [1/2]

Time ssim::current_time = INIT_TIME

static

Definition at line 36 of file ssim.cc.

## current_time [2/2]

Time ssim::current_time = INIT_TIME

static

Definition at line 36 of file ssim.cc.

## default_stream

Rng* ssim::default_stream

static

Definition at line 18 of file microsimulation.cc.

## error_handler [1/2]

SimErrorHandler* ssim::error_handler = 0

static

Definition at line 42 of file ssim.cc.

## error_handler [2/2]

SimErrorHandler* ssim::error_handler = 0

static

Definition at line 42 of file ssim.cc.

## INIT_TIME

const Time ssim::INIT_TIME = 0

beginning of time

Definition at line 79 of file ssim.h.

## NULL_PROCESSID

const ProcessId ssim::NULL_PROCESSID = -1

no process will be identified by NULL_PROCESSID

Definition at line 59 of file ssim.h.

## processes [1/2]

PsTable ssim::processes

static

Definition at line 79 of file ssim.cc.

## processes [2/2]

PsTable ssim::processes

static

Definition at line 79 of file ssim.cc.

## rn

double ssim::rn = 0.0

static

Definition at line 19 of file microsimulation.cc.

## running [1/2]

bool ssim::running = false

static

Definition at line 40 of file ssim.cc.

## running [2/2]

bool ssim::running = false

static

Definition at line 40 of file ssim.cc.

## stop_time [1/2]

Time ssim::stop_time = INIT_TIME

static

Definition at line 35 of file ssim.cc.

## stop_time [2/2]

Time ssim::stop_time = INIT_TIME

static

Definition at line 35 of file ssim.cc.