Skip to content

Microdata Output

esseff edited this page Nov 10, 2022 · 123 revisions

Home > Model Development Topics > Microdata Output

Microdata output allows a model to output values of entity attributes during a run for later use. This topic describes microdata output from a model developer perspective.

Related topics

Topic contents

Introduction and outline

A model with microdata output enabled can output values of entity attributes during a run for later use.

Microdata output is controlled by run-time settings, build-time settings, and model code.

Run-time settings specify which attributes (if any) are output during a run. If a model is enabled for microdata output by build-time settings, all attributes are available for selection at run-time without rebuilding the model.

Build-time settings enable microdata output capability and can specify when microdata is written during the entity life cycle (enter, exit, event).

Optionally, model code can write microdata explicitly by calling the write_microdata() function, or by hooking write_microdata to an existing entity function in model code, e.g. the implementation function of a specific event.

Microdata can be written to the model database. After a run completes, the OpenM++ dbcopy utility can be used to extract run microdata for downstream processing. Future OpenM++ functionality will allow tabulation of run microdata in the model database, including micro-level comparison operations between runs.

Microdata can also be written in CSV format to the run trace file. The examples in this topic use CSV format.

Quick Start shows how to build a model with microdata output capability and how to enable that capability in a model run. General Information contains information not covered in other sub-topics.

[back to topic contents]

Quick start

This subtopic contains the following sections.

[back to topic contents]

1. Build model with microdata output capability

Add the following statement to the model source code file RiskPaths/code/ompp_framework.ompp:

options microdata_output = on;
options microdata_write_on_exit = on;

Build the Release version of RiskPaths.
In Windows, the model executable will be RiskPaths/ompp/bin/RiskPaths.exe.
In Linux, the model executable will be RiskPaths/ompp-linux/bin/RiskPaths.

[back to quick start]
[back to topic contents]

2. Modify model ini file with microdata output options

In the same folder as the RiskPaths executable there may already be a copy of the default model ini file RiskPaths.ini. If not create it using your IDE or a text editor such as Notepad.

Edit RiskPaths.ini to have the following content:

[OpenM]
TraceToFile = true

[Parameter]
SimulationCases = 1

[Microdata]
ToCsv = yes
ToDB = no
Person = time, union_status, parity_status

[back to quick start]
[back to topic contents]

3. Run model using microdata output

Launch the model in its bin directory using the ini file created in the previous step.

RiskPaths -ini RiskPaths.ini

In Windows you can run the Release version of RiskPaths from inside Visual Studio as follows:

  • Solution Configurations to Release and Solution Platforms to x64
  • Project Properties > Configuration Properties > Debugging > Command Arguments to
    -ini RiskPaths.ini
  • Project Properties > Configuration Properties > Debugging > Working Directory to $(TargetDir)
  • To launch the model, do Debug > Start without debugging or Press Ctrl-F5.

After the model runs the trace file RiskPaths.trace.txt should be present in the model bin directory and look like this:

key,parity_status,time,union_status
1,1,100,2

The model log will contain the following warning, which is expected.

Warning : model can expose microdata at run-time with output_microdata = on

[back to quick start]
[back to topic contents]

General information

A model built with microdata output enabled will output the following warning to the log whenever it is run:

 Warning : model can expose microdata at run-time with microdata_output = on

If this is not a concern, for example if the model generates entities synthetically, this warning can be disabled by the following statement:

options microdata_output_warning = off;

Some entity attributes are created by the OpenM++ compiler to implement model functionality. For example, if an entity table has a filter, an identity attribute is created to implement it. These internal generated attributes are normally hidden but they can be made visible by the following statement:

options all_attributes_visible = on;

[back to topic contents]

Run-time settings

Content to follow.

[back to topic contents]

Build-time settings

Content to follow.

[back to topic contents]

Model code

Content to follow.

[back to topic contents]

Microdata key

Content to follow.

[back to topic contents]

Home

Getting Started

Model development in OpenM++

Using OpenM++

OpenM++ user interface

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

Global Administrator: manage all web-services

Clone this wiki locally