Monolix
Auto Light Dark
Auto Light Dark

Writing a model from scratch

If the models present in the libraries do not suit your needs, you can write a model yourself. You can either start completely from scratch or adapt a model existing in the libraries. In both cases, the syntax of the Mlxtran language is detailed in: Model syntax: mlxtran language. You can also copy-paste models from the pages of model examples.


In the “Structural model” tab, you can click on “New model” to open the editor integrated within Monolix, and start writing your own model. The new model contains a convenient template defining the main blocks, input parameters and output variables. When you are done, click on the “Create model” button to save your new model as a .txt file. After saving, the model is automatically loaded in the project.


The figure below shows how to use the editor integrated within the interface of Monolix. The model shown as example corresponds to the model included in the Monolix demo 8.case_studies/hcv_project.mlxtran.


Workflow of five Monolix screenshots joined by arrows. Click New model in the Structural model tab, the editor opens a template with DESCRIPTION, LONGITUDINAL, PK, EQUATION and OUTPUT blocks, write the HCV viral kinetics model and click Create model, save it as hcvNeumann98_model.txt, and the model is then loaded and mapped to the data.


You can even create your own library of models. An example of a basic library which includes several viral kinetics model is available in the demos 8.case_studies/model.

A button “Check syntax” is available to check that there is no syntax error in the model. In case of an error, informative messages are displayed to help correct the error. The syntax check is also automatically applied before saving the model so that only a model with a valid syntax can be saved.

Model editor toolbar with the Check syntax button highlighted, beside Cancel and Create model.

Understanding the error messages

The error messages generated when syntax errors are present in the model are very informative and quickly help to get the model right. The most common error messages are explained in detail in this video.


Using the external editor

This video shows how to write a new structural model with the mlxEditor application, that could only be used as a separate applications in versions of MonolixSuite prior to 2021R1:


Last updated: