Convert case 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++ case-based model, for example: NewCaseBased
  • Rename model directory and solution to YourModelName, for example: RiskPaths
  • Replace NewCaseBased *.mpp modules with your model RiskPaths *.mpp files and inspect your code for any quirks (often none)
  • Replace NewCaseBased *.dat parameter data with your model RiskPaths *.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 RiskPaths model from Modgen 12.1 to openM++.

Convert Modgen RiskPaths to openM++

Clone existing openM++ model

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

Copy existing NewCaseBased model

Rename model directory and solution

Rename directory and model solution into YourModelName.sln:

  • rename NewCaseBased - Copy directory into RiskPaths
  • rename NewCaseBased-ompp.sln into RiskPaths-ompp.sln
  • (optional) rename NewCaseBased-modgen.sln into RiskPaths-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 NewCaseBased to RiskPaths

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

Delete NewCaseBased *.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 NewCaseBased modules with your model modules

RiskPaths *.mpp modules

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

For our example we need to:

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

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

Copy RiskPaths parameters data

RiskPaths default parameters data

Open Visual Studio solution and build the model

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

Build RiskPaths 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;
  long long SimulationCases = 5000;
};

and adjust number of simulation cases if required, re-build the model to update SimulationCases value in RiskPaths.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:

RiskPaths run results in openM++ UI

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