# VIRTUALSENSOR

Piece-Wise Affine Simplicial virtual sensor

## Contents

Class of MOBY-DIC TOOLBOX.

## Description

The virtal sensor is a dynamical system which allows to estimate some unmeasurable outputs "z" of another dynamical systems starting from its inputs "u", its measurable outputs "y" and from the estimates of "z" at some previous time instants.

Let's consider the following dynamical system:

where u are the inputs (always measurables), y the outputs which can be measured at all times and z the outputs which can be measured for a finite time T. The aim of the virtual sensor is to estimate the value of z at istant k (k > T) starting from u at time istants (from to ), from y at time instants (from to ) and from the estimates of z at n time instants (from to ). The sensor is a Piecewise-Affine Simplicial function of all (or some of) these variables (collected in variable x) in the form:

where Nb is the number of vertices of the simplicial partition, alpha(x) are the alpha basis functions and w their corresponding weights (see pwas object for a more detailed description). The weights w are found with a least squares minimization starting from a training set of data (u, y and z). The training set can be created since z is measurable until a certain instant. A reduced complexity version of the PWAS virtual sensor can be designed by considering as a sum of PWAS functions defined over a subset of the domain; actually, a PWAS function for each time instant is used. The estimate, thus, is in the form:

where each of the is a PWAS function in the form (1). This solution allows to reduce the problem of the curse of dimensionality, since less weights w are needed. NOTE: if a variable is outside the time window associated to it, it is not considered in the function . For example, consider , for i = 3 in the sum, function takes as argument, but is outside the time window mu associated to it. In this case it is not passed to the function, so will be a function of only and .

## Syntax

**vs = virtualsensor()**

Build an empty virtualsensor object

**vs = virtualsensor(nu,ny)**

Build a virtual sensor defining the number of system inputs () and the number of measurable system outputs ().

**vs = virtualsensor(nu,ny,options)**

Build a virtual sensor defining the number of system inputs () and the number of measurable system outputs (). An options structure is also provided with the following fields:

- reducedComplexity - if it is set to 1 a reduced complexity virtual sensor is obtained (default value: 0)
- current - if it is set to 1 the values of u and y at the current time instant (, ) are used to estimate z at the same instant (); if it is 0, is estimated starting from , . Defalut value: 1.

## Properties

- nu - Number of system inputs
- ny - Number of measurable system outputs
- nz - Number of unmeasurable system outputs
- mu - Input time window
- my - Output time window
- n - Autoregressive time window
- np - Number of partitions per dimension
- fpwas - pwas object
- reducedComplexity - Flag indicating if the virtual sensor is a reduced complexity virtual sensor
- current - Flag indicating if u and y at current time instant are used to estimate z
- info - Information on virtual sensor identification
- identified - Flag indicating whether the virtual sensor has been identified or not

## Methods

- disp - Displays some information about the virtualsensor object
- eval - Evaluates the unmeasurable output z in correspondence of given system inputs and measurable outputs
- getAutoregressiveTimeWindow - Gets the autoregressive time window n
- getFunction - Gets the pwas object defining the virtual sensor
- getIdentificationInformation - Gets information about ridge regression process used for sensor identification
- getInputTimeWindow - Gets the input time window mu
- getNumberOfInputs - Gets the number of input variables
- getNumberOfMeasurableOutputs - Gets the number of measurable output variables
- getNumberOfPartitions - Gets the number of partitions for each dimension of the pwas virtual sensor domain
- getOutputTimeWindow - Gets the output time window my
- getSynthesisInfo - Gets information related to the circuit synthesis of the pwas virtual sensor
- identify - Identifies the virtual sensor starting from the measured system inputs and outputs
- isCurrent - Indicates if the values of the inputs and measured outputs at current time instant are used to estimate the unmeasurable output
- isIdentified - Returns 1 if the virtual sensor has been identified, 0 otherwise
- readSimulationOutputFile - Reads and plots the function computed by the digital circuit
- setAutoregressiveTimeWindow - Sets the autoregressive time window n
- setInputTimeWindow - Sets the input time window mu
- setNumberOfPartitions - Sets the number of partitions per dimension of the pwas virtual sensor domain
- setOutputTimeWindow - Sets the output time window my
- synthesize - Generates the VHDL files describing the digital circuit implementing the pwas virtual sensor
- validate - Validates the virtual sensor through a test set of data
- writeSimulationInputFile - Generates a text file with inputs for the circuit simulation

## Private methods

- writeInterface - Writes the VHDL code implementing block vs_ser_interface or block vs_par_interface in vs circuit
- writePackage - Writes the VHDL code implementing block pwag_ser_package or block pwag_par_package in vs circuit
- writeTest - Writes the VHDL code implementing block test_pwag_ser_interface or block test_pwag_par_interface in vs circuit

## Acknowledgements

Contributors:

- Alberto Oliveri (alberto.oliveri@unige.it)
- Tomaso Poggi (tpoggi@essbilbao.org)

Copyright is with:

- Copyright (C) 2010-2012 University of Genoa, Italy.