API Reference

autofmu

Automatic FMU approximation tool.

autofmu.main

Main entry point for running the program from the command line.

autofmu.main.main(args=None)[source]

Execute the program in a command line environment.

Parameters

args (Optional[Sequence[str]]) – sequence of command line arguments

Return type

None

autofmu.cli

Utilities for exposing a command line interface of the program.

autofmu.cli.create_argument_parser()[source]

Create an argument parser object to process command line arguments.

Return type

ArgumentParser

Returns

An argument parser object

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
  • dataframe (DataFrame) – dataframe that contains the data used for the approximation

  • model_name (str) – name of the model as used in the modeling environment

  • inputs (Iterable[str]) – variable input names

  • outputs (Iterable[str]) – variable output names

  • outfile (Path) – path to the file to write the FMU

  • strategy (str) – strategy to use to find the approximation (e.g, “linear”)

Return type

None

autofmu.generator.generate_model_description(model_name, model_identifier, guid, inputs, outputs)[source]

Generate a valid FMI 2.0 model description XML document.

Parameters
  • model_name (str) – name of the model as used in the modeling environment

  • model_identifier (str) – short class name according to C syntax, for example, “A_B_C”

  • guid (str) – globaly unique identifier that identifies this model

  • inputs (Iterable[str]) – variable input names

  • outputs (Iterable[str]) – variable output names

Return type

ElementTree

Returns

Valid FMI 2.0 model description XML document

autofmu.generator.generate_model_source(guid, inputs, outputs, strategy, result)[source]

Generate a valid FMI 2.0 C source code implementation.

Parameters
  • guid (str) – globaly unique identifier that identifies this model

  • inputs (Iterable[str]) – variable input names

  • outputs (Iterable[str]) – variable output names

  • result (Union[LinearRegressionResult, LogisticRegressionResult]) – a result from an approximation calculation

Return type

str

Returns

Valid C source code that implements the FMI

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.

Parameters
  • model_identifier (str) – short class name according to C syntax, for example, “A_B_C”

  • fmu_path (Path) – path to the FMU file

Return type

None

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
  • source_dir (Path) – path to source directory

  • build_dir (Path) – path to build directory

  • variables (Optional[Mapping[str, str]]) – a mapping between variable names and their values, e.g, {"CMAKE_PROJECT_NAME": "Unicorn"} would be passed as DCMAKE_PROJECT_NAME=Unicorn in the command line

Return type

None

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.

See:

https://docs.djangoproject.com/en/3.1/ref/utils/#django.utils.text.slugify

Return type

str