autofmu¶
Automatic FMU approximation tool.
Installation¶
Compilers¶
To correctly build an FMU this program needs to compile the generated C source into a shared library, therefore it requires the installation of C compilers.
If you are using the provided docker
image to run the program then you are
already able to cross compile the generated FMU to linux32
, linux64
,
win32
and win64
platforms.
Otherwise if you are using a Linux distribution, you probably already have
gcc
installed, so you should be able to compile FMUs for your system. If
you want to share the generated FMU it is advisable to also install a cross
compiler to produce the binaries for Windows platforms (like
MinGW). Below are the instructions to install with
apt
and dnf
:
Debian/Ubuntu:
sudo apt install gcc-x86-64-linux-gnu gcc-i686-linux-gnu gcc-mingw-w64 gcc-mingw-w64-i686
Fedora:
sudo dnf install gcc-x86_64-linux-gnu mingw64-gcc mingw32-gcc
Usage¶
autofmu
process a dataset
autofmu "dataset.csv" --inputs "x" "y" --outputs "z" -o "My Awesome Model.fmu"
This will read the dataset.csv
file, select the x
, y
and z
columns and find an approximation of the relation between the inputs and the
outputs. Based on this relation, the sources files for the FMU will be
generated and compiled, resulting in the My Awesome Model.fmu
file ready
to be used for simulations.
Contributing¶
License¶
This project is licensed under MIT license.
Table of contents¶
Installation¶
Compilers¶
To correctly build an FMU this program needs to compile the generated C source into a shared library, therefore it requires the installation of C compilers.
If you are using the provided docker
image to run the program then you are
already able to cross compile the generated FMU to linux32
, linux64
,
win32
and win64
platforms.
Otherwise if you are using a Linux distribution, you probably already have
gcc
installed, so you should be able to compile FMUs for your system. If
you want to share the generated FMU it is advisable to also install a cross
compiler to produce the binaries for Windows platforms (like
MinGW). Below are the instructions to install with
apt
and dnf
:
Debian/Ubuntu:
sudo apt install gcc-x86-64-linux-gnu gcc-i686-linux-gnu gcc-mingw-w64 gcc-mingw-w64-i686
Fedora:
sudo dnf install gcc-x86_64-linux-gnu mingw64-gcc mingw32-gcc
Usage¶
autofmu
process a dataset
autofmu "dataset.csv" --inputs "x" "y" --outputs "z" -o "My Awesome Model.fmu"
This will read the dataset.csv
file, select the x
, y
and z
columns and find an approximation of the relation between the inputs and the
outputs. Based on this relation, the sources files for the FMU will be
generated and compiled, resulting in the My Awesome Model.fmu
file ready
to be used for simulations.
License¶
MIT License
Copyright (c) 2020 Afonso Cerejeira
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
API Reference¶
autofmu¶
Automatic FMU approximation tool.
autofmu.main¶
Main entry point for running the program from the command line.
autofmu.cli¶
Utilities for exposing a command line interface of the program.
autofmu.generator¶
Utilities for generating valid Functional Mockup Units.
-
autofmu.generator.
generate_fmu
(dataframe, model_name, inputs, outputs, outfile, strategy)[source]¶ Generate a valid FMU model.
- Parameters
- Return type
-
autofmu.generator.
generate_model_description
(model_name, model_identifier, guid, inputs, outputs)[source]¶ Generate a valid FMI 2.0 model description XML document.
- Parameters
- Return type
ElementTree
- Returns
Valid FMI 2.0 model description XML document
autofmu.utils¶
General utilities.
-
autofmu.utils.
compile_fmu
(model_identifier, fmu_path)[source]¶ Compile the C sources files of an FMU.
Extracts the FMU into a temporary directory, calling cmake to build the FMU, copying the generated library back into the FMU file. If MinGW is installed, it also cross compiles the FMU for Linux and Windows.
-
autofmu.utils.
run_cmake
(source_dir, build_dir, variables=None)[source]¶ Run cmake command and build the targets.
Roughly equivalent to running the following two commands:
cmake -S source_dir -B build_dir cmake --build build_dir
- Parameters
- Return type
-
autofmu.utils.
slugify
(value, allow_unicode=False)[source]¶ Convert a string to a URL slug.
Convert to ASCII if ‘allow_unicode’ is False. Convert spaces or repeated dashes to single dashes. Remove characters that aren’t alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace, dashes, and underscores.
- Return type
Command line reference¶
usage: autofmu [-h] [-o FILE] [-v] [-V] --inputs VARIABLE [VARIABLE ...]
--outputs VARIABLE [VARIABLE ...] [-s {linear,logistic}]
FILE
Positional Arguments¶
- FILE
CSV files that contain the datasets for training the FMU model
Named Arguments¶
- -o, --outfile
file to output the generated FMU model (default ‘model.fmu’)
Default: model.fmu
- -v, --verbose
run the program in verbose mode
Default: False
- -V, --version
show program’s version number and exit
- --inputs
list of names of the model input variables
- --outputs
list of names of the model output variables
- -s, --strategy
Possible choices: linear, logistic
strategy to use to deduce the approximation
Default: “linear”