Skip to content

Enumerations

esseff edited this page Jun 7, 2024 · 2 revisions

Home > Model Development Topics > Enumerations

This topic is under construction and/or revision.

Topic summary, two sentences max.

Related topics

Topic contents

Introduction and outline

Content to follow.

[back to topic contents]

Enumerations as dimensions

Each dimension of a multi-dimensional parameter, derived table or entity array is declared using an enumeration. In RiskPaths, for example,

parameters
{
    //EN Age baseline for first pregnancy
    double  AgeBaselinePreg1[AGEINT_STATE];
...
};

declares the 1-dimensional array parameter AgeBaselinePreg1 using the enumeration AGEINT_STATE, which is a partition whose declaration is

partition AGEINT_STATE //EN 2.5 year age intervals
{
    15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40
};

In C++ model code, an element of an array can be referenced using an index. For example, in the following code fragment

TIME Person::timeFirstPregEvent()
{
...
    dHazard = AgeBaselinePreg1[age_status]
...

AgeBaselinePreg1 is indexed by the attribute age_status to obtain an age-specific hazard.

Enumeration index validity

Index errors are a common source of errors in C++ programs. Such errors are typically not detected by the C++ compiler and often manifest only indirectly when the program is executed. They can be hard to detect and resolve, because they manifest outside of a program's logic, by reading or modifying unrelated locations in memory.

In model code,
an index is invalid if it falls outside the lower and upper integer limits of an enumeration dimension. For example, the parameter ProbMort

parameters
{
...
    double ProbMort[LIFE]; //EN Death probabilities
};

is declared using the range LIFE:

range LIFE //EN Simulated age range
{
    0,100
};

The model code fragment

TIME Person::timeDeathEvent()
{
...
    if (ProbMort[integer_age] >= 1)
...
}

would be invalid if integer_age was less than 0 or greater than 100.

The option

options index_errors = on;

causes the OpenM++ compiler to generate code which verifies that all indices are valid during a model run.

Home

Getting Started

Model development in OpenM++

Using OpenM++

Model Development Topics

OpenM++ web-service: API and cloud setup

Using OpenM++ from Python and R

Docker

OpenM++ Development

OpenM++ Design, Roadmap and Status

OpenM++ web-service API

GET Model Metadata

GET Model Extras

GET Model Run results metadata

GET Model Workset metadata: set of input parameters

Read Parameters, Output Tables or Microdata values

GET Parameters, Output Tables or Microdata values

GET Parameters, Output Tables or Microdata as CSV

GET Modeling Task metadata and task run history

Update Model Profile: set of key-value options

Update Model Workset: set of input parameters

Update Model Runs

Update Modeling Tasks

Run Models: run models and monitor progress

Download model, model run results or input parameters

Upload model runs or worksets (input scenarios)

Download and upload user files

User: manage user settings

Model run jobs and service state

Administrative: manage web-service state

Clone this wiki locally