ModestPy facilitates parameter estimation in models compliant with Functional Mock-up Interface.
Features:
- combination of global and local search methods (genetic algorithm, pattern search, truncated Newton method, L-BFGS-B, sequential least squares),
- suitable also for non-continuous and non-differentiable models,
- scalable to multiple cores (genetic algorithm from modestga),
- Python 3.
Due to time constraints, ModestPy is no longer actively developed. The last system known to work well was Ubuntu 18.04. Unit tests in GitHub Actions are run on Ubuntu 18.04 and Python 3.6/3.7. It does not mean it will not work on other systems, but it is not guaranteed. Use Docker (as described below) if you want to run ModestPy on a tested platform.
It is now possible to install ModestPy with a single command:
pip install modestpy
Alternatively:
pip install https://github.com/sdu-cfei/modest-py/archive/master.zip
Conda is installation is less frequently tested, but should work:
conda config --add channels conda-forge conda install modestpy
Due to time constraints, Modestpy is no longer actively developed. The last system known to work well was Ubuntu 18.04. If you encounter any issues with running ModestPy on your system (e.g. some libs missing), try using Docker.
I prepared a Dockerfile
and some initial make
commands:
make build
- build an image with ModestPy, based on Ubuntu 18.04 (tag =modestpy
)make run
- run the container (name =modestpy_container
)make test
- run unit tests in the running container and print output to terminalmake bash
- run Bash in the running container
Most likely you will like to modify Dockerfile
and Makefile
to your needs, e.g. by adding bind volumes with your FMUs.
The unit tests will work only if you installed ModestPy with conda or cloned the project from GitHub. To run tests:
>>> from modestpy.test import run
>>> run.tests()
or
cd <project_directory> python ./bin/test.py
Users are supposed to call only the high level API included in
modestpy.Estimation
. The API is fully discussed in the docs.
You can also check out this simple example.
The basic usage is as follows:
from modestpy import Estimation
if __name__ == "__main__":
session = Estimation(workdir, fmu_path, inp, known, est, ideal)
estimates = session.estimate()
err, res = session.validate()
More control is possible via optional arguments, as discussed in the documentation.
The if __name__ == "__main__":
wrapper is needed on Windows, because modestpy
relies on multiprocessing
. You can find more explanation on why this is needed
here.
modestpy
automatically saves results in the working
directory including csv files with estimates and some useful plots,
e.g.:
- Error evolution in combined GA+PS estimation (dots represent switch from GA to PS):
- Visualization of GA evolution:
- Scatter matrix plot for interdependencies between parameters:
To cite ModestPy, please use:
K. Arendt, M. Jradi, M. Wetter, C.T. Veje, ModestPy: An Open-Source Python Tool for Parameter Estimation in Functional Mock-up Units, Proceedings of the American Modelica Conference 2018, Cambridge, MA, USA, October 9-10, 2018.
The preprint version of the conference paper presenting ModestPy is available here. The paper was based on v.0.0.8.
Copyright (c) 2017-2019, University of Southern Denmark. All rights reserved.
This code is licensed under BSD 2-clause license. See LICENSE file in the project root for license terms.