In order to use SMC methods on widder and more complex models, we worked on interfacing PLASMA Lab with MATLAB/Simulink. This project is available either as a PLASMA Lab plugin or as a MATLAB App.
We first describes how we implemented the interface between PLASMA Lab and Simulink, and give a short explanation on how to use the Simulink plugin in PLASMA Lab. Then, in the second section, we details the PLASMA2Simulink MATLAB App. Its specificity and how to install and use it.
The Simulink PLASMA Lab plugin is developed in the fr.inria.plasmalab.matlab and use the Simulator API.
To connect Simulink to PLASMA Lab we used the MATLAB Control library. This API allows to interact with MATLAB from Java. A proxy object, MATLABProxy can be used to eval, feval, as well as get and set variables.
This library allowed us to execute the same calls we would have used in MATLAB. Simulink produces and stores an output data structure. This structure traces signals declared as output in Simulink as well as Time. The output is retrieved in Java and stored in an InterfaceState object.
// SIMULATE @ fr.inria.plasmalab.matlab.MatLabSessionModel
proxy.eval(plasmaOutput+" = sim(idSML, "
+ "'StopTime', num2str("+simTimeLength+"), "
+ "'StartTime', num2str("+simLatestTime+"), "
+ simParameters +");");
To emulate the state on demand approach we took in PLASMA Lab design, we simulate the Simulink model for a parameterized amount of time and store the latest state. If more states are needed to decided the requirement, the simulation can be extended from the latest state. If not, a new run is executed from the initial state. The length of each simulation run is parameterized by the Stop time parameter of the Simulink model.
Although MATLAB Control is used to communicate with MATLAB, the PLASMALab2Simulink can only execute a Simulink model due to its implementation.
To use the PLASMALab2Simulink plugin, create a new MATLAB Interface model in PLASMA Lab. Once created, the plugin will launch MATLAB. It is not currently possible to connect to an existing MATLAB session.
We specify the absolute path to the Simulink model in the PLASMA Lab edition panel. Openning the model can take some time as it require MATLAB to load the Simulink library.
A configuration step must be done on the Simulink model, but it is straightforward. The PLASMA Lab plugin will only trace signal set as output. This is accomplished by setting Log signal data in the signal properties we want to trace. The model logging format should also be set to DataSet and Structure with time. These options are set in the Data Import/Export of the Model configuration parameters panel.
Each time more states are needed, Simulink will move the simulation forward from the latest state for a parameterized amount of time. We use the Stop time parameter of the Simulink model for this purpose.
Once our model is configured, we can test it in the Simulation panel and then launch a new experiment.
The PLASMALab2Simulink interface is not yet compatible with the distributed mode.
The PLASMALab2Simulink App is a MATLAB App aimed at using PLASMA Lab directly in MATLAB. The App provides a small user interface written in M (MATLAB language). It also contains the PLASMA Lab library, the PLASMALab2Simulink plugin and the BLTL requirement plugin.
The fr.inria.plasmalab.matlab_ui project contains a code layer communicating with the MATLAB code. Sources for the MATLAB part of the code can be found in the plasma_lab_simulink directory. The build procedure for the App is documented in the Continuous Integration section of the 4th chapter, Project manual.
To use the PLASMALab2Simulink App download the mlappinstall file on the download page and open it with MATLAB. This will install it on your MATLAB installation and a PLASMALab2Simulink icon will be added to the Apps tool bar.
To configure a Simulink model, follow the same procedure described in the PLASMA Lab plugin, How to use it section. The App has less functionnality than the regular PLASMA Lab GUI. To launch a new experiment specify the path to the Simulink model and enter a property using BLTL syntax.
Algorithms parameter are set in a single text field using whitespace as separator. Parameters should be given in the same order as in the PLASMA Lab GUI experimental panel.