Convert time based Model from Modgen - openmpp/openmpp.github.io GitHub Wiki
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++.

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

Rename directory and model solution into YourModelName.sln:
- rename
NewTimeBased - Copydirectory intoIDMM - rename
NewTimeBased-ompp.slnintoIDMM-ompp.sln - (optional) rename
NewTimeBased-modgen.slnintoIDMM-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.

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++20 standard.


For our example we need to:
- delete NewTimeBased
parameters/Default/PersonCore.datandparameters/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.


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

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:

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