Download and Installation

The toolbox is available in Matlab and Python with full installation instructions below. If you use this toolbox in your research, please cite

Erik Frisk, Mattias Krysander, and Daniel Jung. “A Toolbox for Analysis and Design of Model Based Diagnosis Systems for Large Scale Models” IFAC World Congress, 2017. Toulouse, France, 2017.

You can also find more references to related work on our references page.

Python Installation

The package is uploaded to the Python Package Index at https://pypi.org/project/faultdiagnosistoolbox/ and the installation procedure is as easy as

pip install faultdiagnosistoolbox

The toolbox requires a recent Python and works on Linux, MacOS, and Windows. The package is a binary installation, if there are any issues with installation on your system, please contact Erik Frisk (erik.frisk@liu.se).

Python-specific documentation can be found at readthedocs.

Matlab Installation

The latest version of the package can always be obtained from this page (https://faultdiagnosistoolbox.github.io/). The current version of the toolbox can be found in the zip-archive FaultDiagnosisToolbox_2024-02-22.zip and the current documentation (also included in the zip file) documentation.

The toolbox requires a Matlab v7.6 (R2008a) or later for the object-oriented functionality. Main functionality also requires the Symbolic Toolbox version 7.14 (2012a) or later.

The installation procedure is very simple:

  • Uncompress the zip-file
  • Add the src directory to the Matlab-path
  • (optional) There are C++ implementations of some computationally expensive algorithms. It is not necessary to compile these for the toolbox to work, there are Matlab implementations directly installed. However, with the compiled versions there might be significant increases in performance. See below for instructions

After the installation, head to the examples directory to try out functionality or look in the tutorials section of this site.

Compiled implementations

To compile the C++ sources, it is required that a functioning compiler is installed and configured for use with Matlab. Instructions below are directly applicable for Linux/MacOS systems. There are binaries included in the distribution if you do not want to compile the sources yourself. In the directory binaries there are compiled files for 64 bit Linux and MacOS. Copy the files corresponding to your system into the src directory and hope for the best.

There are two algorithms that have C++ implementations; minimal hitting set and an MSO algorithm.

Minimal Hitting Set

To compile, open Matlab and go to the src directory. To compile, type (output from an MacOS system)

>> mex MHScompiled.cc
Building with 'Xcode Clang++'.
MEX completed successfully.

Verify that everything has worked by

>> exist('MHSCompiled')

ans =

     3

The use of the compiled algorithm is optional, full functionality is obtained with the Matlab implementation of the minimal hitting set algorithm.

MSO algorithm

The MSO algorithm uses a library for computing with sparse matrices. The sparse matrix library is part of the software SuiteSparse and can be downloaded from http://faculty.cse.tamu.edu/davis/suitesparse.html. You do not have to compile and install the entire SuiteSparse library, only the CSparse part. The CSparse source is included in the zip-archive.

To install on a Linux or a MacOS system with developer tools installed, go to the CSparse directory and write at a terminal prompt, not in Matlab:

> cd CSparse
> make

When the CSParse library is compiled, open Matlab and go to the src directory and type:

%% Specify installation directory for CSparse
CSPARSEDIR = '../CSparse';

% Derive include and lib directory
CSPARSEINC=['-I' fullfile(CSPARSEDIR, '/Include')];
CSPARSELIB=['-L' fullfile(CSPARSEDIR, '/Lib')];

%% Compile sources and link mex-file

mex('-c', '-largeArrayDims', CSPARSEINC,'MSOAlg.cc');
mex('-c', '-largeArrayDims', CSPARSEINC,'SparseMatrix.cc');
mex('-c', '-largeArrayDims', CSPARSEINC,'StructuralAnalysisModel.cc');
mex('-c', '-largeArrayDims', CSPARSEINC,'FindMSOcompiled.cc');

% Link
mex(CSPARSELIB, 'FindMSOcompiled.o', 'SparseMatrix.o', 'StructuralAnalysisModel.o', 'MSOAlg.o', '-lcsparse');

%Specify installation directory for CSparse
CSPARSEDIR = '[INSTALLATIONDIR]';

% Derive include and lib directory
CSPARSEINC=['-I' fullfile(CSPARSEDIR, '/Include')];
CSPARSELIB=['-L' fullfile(CSPARSEDIR, '/Lib')];

% Compile sources
mex('-c', '-largeArrayDims', CSPARSEINC,'MSOAlg.cc');
mex('-c', '-largeArrayDims', CSPARSEINC,'SparseMatrix.cc');
mex('-c', '-largeArrayDims', CSPARSEINC,'StructuralAnalysisModel.cc');
mex('-c', '-largeArrayDims', CSPARSEINC,'FindMSOcompiled.cc');

% Link
mex(CSPARSELIB, 'FindMSOcompiled.o', 'SparseMatrix.o', ...
'StructuralAnalysisModel.o', 'MSOAlg.o', '-lcsparse');  

On a Mac system, you might get warnings when linking due to different deployment versions used by the Matlab compiler and the compiler used, ``ld: warning: object file (../CSparse/Lib/libcsparse.a(cs_add.o)) was built for newer OSX version (10.12) than being linked (10.9)’’. To avoid this warning, recompile CSparse with the build version of Matlab by setting the environment variable MACOSX_DEPLOYMENT_TARGET=10.9 before running make to build CSparse.

Verify that everything has worked and the binary has been generated by

>> exist('FindMSOcompiled')

ans =

     3  

For Linux and MacOS there are pre-compiled versions and to install, copy the suitable files from the binaries directory into the src directory.