Skip to main content

optiSLang 3D Postprocessing Script API 2024 R2 SP02

ComputeRPCA< TYPE > Class Template Reference

Last update: 16.07.2025

Perform Robust Principal Component Analysis While traditional PCA is very sensitive to data corruption or outliers, RPCA is, as its name implies, robust to data corruption under surprisingly broad conditions. RPCA attempts to split a given matrix M into two matrices S and L: M = L + S where L is a low-rank matrix and S is a sparse matrix of random errors (of arbitrary magnitude and random sign). In the context of SoS, each column vector of M might be a particular field design. Without any prior knowledge about outliers, RPCA is then able to separate correlations between field designs (L) from outliers (S). Security camera footage is a good example, following the M = L + S data model: L represents the slowly changing background, while S represents walking people. See https://arxiv.org/abs/0912.3599 for more examples and a precise definition of the conditions, for RPCA to deliver good results. By default, ComputeRPCA creates two new quantity idents named RPCA[] (L) and RPCAError[] (S). Disable the creation of RPCAError by setting the createRPCAError member variable to false. The algorithm attempts to recover L and S by running the Principal Component Pursuit bi-objective optimization program:

\[ //! \text{minimize} ||L||_* + \lambda ||S||_1 //! \text{subject to} L + S = M //! \]

where $ ||L||_* $ denotes the nuclear norm of $ L $ (i.e. the sum of the singular values of $ L $) and $ ||L||_1 = \sum_{ij}|S_{ij}| $ denotes the $ l_1 $-norm of $ S $ seen as a long vector. Recommended value: $ \lambda = 1/\sqrt{max(dim(M))}$. More...

Public Types

typedef boost::function< DataObject::ptr_type(DataObject::ptr_type input)> TAlgorithmFunction
 defines a function object More...
 
typedef boost::function< DataObject::ptr_type(Structure database, DataObject::ptr_type input)> TAlgorithmFunction2
 defines a function object More...
 

Public Member Functions

 check (Structure database)
 checks the settings on plausibility It throws an exception if there is a problem with the settings. Important: It tries to find out all problems with these settings and then exits the routine. More...
 
bool compute (Structure database)
 
 compute (Structure database, DataObject::ptr_type data, string new_quantity_ident, string new_design_ident)
 performs the action for a single set of samples More...
 
 ComputeRPCA ()
 Create an RPCA object with default settings.
 
 ComputeRPCA (DataObjectContainer dataObjectFilter)
 Create an RPCA object with default settings and set the field data to perform RPCA on. More...
 

Public Attributes

bool createRPCAError
 
DataObjectContainer data
 the data set to be analyzed
 
number lambda
 Singular value threshold parameter. Default: 0, lambda is set to 1/sqrt(max(n,m)), with n and m being the input matrix dimensions.
 
number maxIterations
 Maximum number of iterations. Default: 200.
 
DataObjectContainer::string_vector_type new_quantity_idents
 the new idents for each quantity. The dimension and index space must fit the one of quantity_idents
 
bool overwrite_existing
 is true if already existing output data objects will be replaced. In this case, also all depending objects of the already existing one will be deleted.
 
DataObjectContainer::string_vector_type quantity_idents
 the quantities to be analyzed. If a quantity ident does not exist in data, no error appears.
 
number relativeError
 Iterate until relative error is reached. Default: 1e-9.
 

Detailed Description

template<dataobject_types TYPE>
class ComputeRPCA< TYPE >

Perform Robust Principal Component Analysis While traditional PCA is very sensitive to data corruption or outliers, RPCA is, as its name implies, robust to data corruption under surprisingly broad conditions. RPCA attempts to split a given matrix M into two matrices S and L: M = L + S where L is a low-rank matrix and S is a sparse matrix of random errors (of arbitrary magnitude and random sign). In the context of SoS, each column vector of M might be a particular field design. Without any prior knowledge about outliers, RPCA is then able to separate correlations between field designs (L) from outliers (S). Security camera footage is a good example, following the M = L + S data model: L represents the slowly changing background, while S represents walking people. See https://arxiv.org/abs/0912.3599 for more examples and a precise definition of the conditions, for RPCA to deliver good results. By default, ComputeRPCA creates two new quantity idents named RPCA[] (L) and RPCAError[] (S). Disable the creation of RPCAError by setting the createRPCAError member variable to false. The algorithm attempts to recover L and S by running the Principal Component Pursuit bi-objective optimization program:

\[ //! \text{minimize} ||L||_* + \lambda ||S||_1 //! \text{subject to} L + S = M //! \]

where $ ||L||_* $ denotes the nuclear norm of $ L $ (i.e. the sum of the singular values of $ L $) and $ ||L||_1 = \sum_{ij}|S_{ij}| $ denotes the $ l_1 $-norm of $ S $ seen as a long vector. Recommended value: $ \lambda = 1/\sqrt{max(dim(M))}$.

Template Parameters
TYPEthe field data type

Member Typedef Documentation

◆ TAlgorithmFunction

typedef boost::function<DataObject::ptr_type ( DataObject::ptr_type input)> TAlgorithmFunction
inherited

defines a function object

Parameters
inputa single input object
Returns
the result of the operation

◆ TAlgorithmFunction2

typedef boost::function<DataObject::ptr_type ( Structure database, DataObject::ptr_type input)> TAlgorithmFunction2
inherited

defines a function object

Parameters
databasethe database we refer to
inputa single input object
Returns
the result of the operation

Constructor & Destructor Documentation

◆ ComputeRPCA()

ComputeRPCA ( DataObjectContainer  dataObjectFilter)

Create an RPCA object with default settings and set the field data to perform RPCA on.

Parameters
dataObjectFilterthe field data to perform RPCA on

Member Function Documentation

◆ check()

check ( Structure  database)
inherited

checks the settings on plausibility It throws an exception if there is a problem with the settings. Important: It tries to find out all problems with these settings and then exits the routine.

Parameters
databasethe SoS structure

◆ compute()

compute ( Structure  database,
DataObject::ptr_type  data,
string  new_quantity_ident,
string  new_design_ident 
)
inherited

performs the action for a single set of samples

Parameters
databasethe output object is to be inserted in this object
datathe input data object
new_quantity_identthe quantity ident of the new object
new_design_identthe design ident of the new object If the input object is active, then the output object will be active as well (or inactive, respectively).

Connect with Ansys