Skip to content

FMI-compliant Model Estimation in Python

License

Notifications You must be signed in to change notification settings

filokot/modest-py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FMI-compliant Model Estimation in Python

modestpy

Description

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,
  • compatible with both Python 2.7 and 3.

Installation with conda (recommended)

It is now possible to install ModestPy through conda:

conda config --add channels conda-forge
conda install modestpy

Installation with conda and pip

This procedure has been tested on Debian 9 and Ubuntu 16.04 with Python 3.

It is advised to use conda to install the required dependencies. modestpy itself can be installed using pip inside the conda environment.

Create separate environment (optional):

conda create --name modestpy
conda activate modestpy

Install dependencies:

conda install scipy pandas numpy matplotlib
conda install -c chria pyfmi
conda install -c conda-forge pydoe

Install modestpy:

python -m pip install modestpy

Installation with pip

This procedure has been tested on Windows 7 with Python 2.

Install pyfmi as part of JModelica.

To install modestpy use pip (other dependencies will be installed automatically):

python -m pip install modestpy

To get the latest development version download directly from GitHub repository:

python -m pip install https://github.com/sdu-cfei/modest-py/archive/master.zip

Note, that JModelica installs Python and libraries in a separate directory than the standard Python distribution. Therefore either the path to those libraries needs to be added to PYTHONPATH or ModestPy needs to be installed inside the JModelica distribution.

Test your installation

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

Usage

Users are supposed to call only the high level API included in modestpy.Estimation. The API is fully discussed in this wiki. You can also check out this simple example. The basic usage is as follows:

>>> from modestpy import Estimation
>>> 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.

modestpy automatically saves results in the working directory including csv files with estimates and some useful plots, e.g.:

  1. Error evolution in combined GA+PS estimation (dots represent switch from GA to PS): Error-evolution
  2. Visualization of GA evolution: GA-evolution
  3. Scatter matrix plot for interdependencies between parameters: Intedependencies

Cite

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.

License

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.

About

FMI-compliant Model Estimation in Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 96.1%
  • Modelica 3.9%