Convert case 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++ 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++.
As starting point please copy one of openM++ sample models, for case-based model we can start from NewCaseBased.
Rename directory and model solution into YourModelName.sln
:
- rename
NewCaseBased - Copy
directory intoRiskPaths
- rename
NewCaseBased-ompp.sln
intoRiskPaths-ompp.sln
- (optional) rename
NewCaseBased-modgen.sln
intoRiskPaths-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 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.
For our example we need to:
- delete NewCaseBased
parameters/Default/PersonCore.dat
andparameters/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.
Open RiskPaths-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;
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
:
It is possible to open model run results in openM++ UI (beta version) to examine model parameters and output results: