Convert time based Model from Modgen - openmpp/openmpp.github.io GitHub Wiki

Overview

OpenM++ provides superset of Modgen language specification and therefore able to compile Modgen source files. Conversion from Modgen include following:

  • Make sure you are done with: Windows: Quick Start for Model Developers
  • Clone existing openM++ time-based model, for example: NewTimeBased
  • Rename model directory and solution to YourModelName, for example: IDMM
  • Replace NewTimeBased *.mpp modules with your model IDMM *.mpp files and inspect your code for any quirks (often none)
  • Replace NewTimeBased *.dat parameter data with your model IDMM *.dat files
  • Open Visual Studio, build the model and fix errors if necessary
  • Run the model and verify simulation results

Below is step-by-step example how to convert IDMM model from Modgen 12.1 to openM++.

Convert Modgen IDMM to openM++

Clone existing openM++ model

As starting point please copy one of openM++ sample models, for time-based model we can start from NewTimeBased.

Copy existing NewTimeBased model

Rename model directory and solution

Rename directory and model solution into YourModelName.sln:

  • rename NewTimeBased - Copy directory into IDMM
  • rename NewTimeBased-ompp.sln into IDMM-ompp.sln
  • (optional) rename NewTimeBased-modgen.sln into IDMM-modgen.sln

Note: It is not required to use model name as directory name and solution name, but it is openM++ convention and significantly simplifies model maintenance.

Rename directory and projects from NewTimeBased to IDMM

Replace sample model *.mpp modules with your model *.mpp files

Delete NewTimeBased *.mpp modules and copy your model substantive *.mpp files instead. For complex models with long maintenance history it may be not always easy to understand what *.mpp files are "substantive" and you may need to repeat this step multiple times.

It is also rare, but possible for some *.mpp modules to contain special quirky code in order to overcome issues in old version of Modgen or c++. Please inspect your code and adjust it, if necessary, to comply with c++17 standard.

Replace NewTimeBased modules with your model modules

IDMM *.mpp modules

Replace sample model parameter data with your model *.dat files

For our example we need to:

  • delete NewTimeBased parameters/Default/PersonCore.dat and parameters/Default/scenario_info.odat
  • copy Base(IDMM).dat
  • (optional) rename it into IDMM.dat

For complex models it is also possible to have Fixed parameters data. Please copy it into parameters/Fixed/ sub-folder.

Copy IDMM parameters data

IDMM default parameters data

Open Visual Studio solution and build the model

Open IDMM-ompp.sln solution in Visual Studio and build the model, fix errors, if necessary.

Build IDMM model

Run the model and verify simulation results

Last, but obviously very important step, is to run the model and compare Modgen and openM++ simulation results.

Check parameters/Default/Framework.odat values:

parameters {
  int SimulationSeed = 16807;
  Time SimulationEnd = 101.0;
};

and adjust number of simulation end time if required, re-build the model to update SimulationEnd value in IDMM.sqlite model database.

You can run openM++ model from command line, or from Visual Studio by changing Project -> Properties -> OpenM++ -> Run Options:

Project properties to run the model and open UI

It is possible to open model run results in openM++ UI (beta version) to examine model parameters and output results:

IDMM run results in openM++ UI

⚠️ **GitHub.com Fallback** ⚠️