Skip to content

Simulink

The Simulink front-end is loaded from a separate, closed-source library; see Importing models. The usual entry point is intrepyd.tools.translate_simulink.

Python binding of the Simulink front-end.

The translator from Simulink models to intrepyd circuits is a C library (libintrepid_simulink.so on Linux, intrepid_simulink.dll on Windows, libintrepid_simulink.dylib on macOS), built and released from its own repository, as intrepid is. This module loads it with ctypes, when it is first needed: intrepyd works without it, and only translate_simulink() requires it.

The library is looked up first in the INTREPID_SIMULINK_LIBRARY environment variable, which must be the path of the library file, and then next to this module, which is where the packaged intrepyd ships it.

Translating needs a valid license of intrepid, the one the engines run under (see intrepyd.license): it is found and checked as the engines find and check it, and without one translate_file raises SimulinkError saying why. license_info tells which license the translator runs under.

The functions that have no operator in intrepid (sin, cos, tan, asin, acos, atan, atan2, exp, log, log10) are abstracted by the translator: each is an input of the circuit, tied to its arguments by an assumption of true facts of the function, listed in the circuit's abstractions. A proof holds for the model; a counterexample is the model's if each such input is the function of its arguments, which check_abstractions tells; confirm_counterexample replays it with each such input the function of its arguments, and tells whether it still reaches its target.

SimulinkError

Bases: Exception

A model that cannot be translated: the message lists the reasons

translate_file

translate_file(infilename, realtype='float', variables=None, scripts=None, mats=None, callbacks=True, finite_inputs=False, design_ranges=False)

Translates a Simulink model, a .mdl or a .slx file, and returns the python module of its circuit, as a string. Raises SimulinkError, listing the blocks that cannot be translated, if the model cannot be.

realtype is 'float', to translate single and double as floats, exactly, or 'real', as reals, which is not exact but much easier for the engines. The workspace of MATLAB the model refers to is filled, in order, by the callbacks of the model (PreLoadFcn, PostLoadFcn, InitFcn: their loads of MAT files and their scripts), unless callbacks is False; then by the MAT files in mats (their Simulink.Bus objects and numeric variables); then by the MATLAB scripts of assignments in scripts; then by variables, which maps names to MATLAB expressions. With finite_inputs, the float inputs of the model are assumed finite at every step, neither NaN nor infinite (an assumption 'finite(input)' each); with design_ranges, each input within the design minimum and maximum (OutMin, OutMax) of its root Inport and of the Inports of subsystems it enters as it is, as Simulink Design Verifier takes them (an assumption 'range(input)' each). An older translator refuses these two options. Needs a valid license of intrepid (see the module's documentation).

library_path

library_path()

The path of the library, or None if it is not available

license_info

license_info()

The license the translator runs under, as intrepyd.license.license_info tells the engines': its fields (but its signature), valid, error when it is not valid or none was found, source, skipped, key and release. None for a library older than its licenses, which needs none.

version

version()

The version of the library