mlpack  master
Public Types | Public Member Functions | Private Attributes | List of all members
mlpack::optimization::SDP< ObjectiveMatrixType > Class Template Reference

Specify an SDP in primal form. More...

Inheritance diagram for mlpack::optimization::SDP< ObjectiveMatrixType >:
Inheritance graph
[legend]

Public Types

typedef ObjectiveMatrixType objective_matrix_type
 

Public Member Functions

 SDP ()
 Initialize this SDP to an empty state. More...
 
 SDP (const size_t n, const size_t numSparseConstraints, const size_t numDenseConstraints)
 Initialize this SDP to one which structurally has size n. More...
 
ObjectiveMatrixType & C ()
 Modify the sparse objective function matrix (sparseC). More...
 
const ObjectiveMatrixType & C () const
 Return the sparse objective function matrix (sparseC). More...
 
const std::vector< arma::mat > & DenseA () const
 Return the vector of dense A matrices (which correspond to the dense constraints). More...
 
std::vector< arma::mat > & DenseA ()
 Modify the veector of dense A matrices (which correspond to the dense constraints). More...
 
const arma::vec & DenseB () const
 Return the vector of dense B values. More...
 
arma::vec & DenseB ()
 Modify the vector of dense B values. More...
 
bool HasLinearlyIndependentConstraints () const
 Check whether or not the constraint matrices are linearly independent. More...
 
size_t N () const
 Return number of rows and columns in the objective matrix C. More...
 
size_t N2bar () const
 
size_t NumConstraints () const
 Return the total number of constraints in the SDP. More...
 
size_t NumDenseConstraints () const
 Return the number of dense constraints (constraints with dense Ai) in the SDP. More...
 
size_t NumSparseConstraints () const
 Return the number of sparse constraints (constraints with sparse Ai) in the SDP. More...
 
const std::vector< arma::sp_mat > & SparseA () const
 Return the vector of sparse A matrices (which correspond to the sparse constraints). More...
 
std::vector< arma::sp_mat > & SparseA ()
 Modify the veector of sparse A matrices (which correspond to the sparse constraints). More...
 
const arma::vec & SparseB () const
 Return the vector of sparse B values. More...
 
arma::vec & SparseB ()
 Modify the vector of sparse B values. More...
 

Private Attributes

ObjectiveMatrixType c
 Objective function matrix c. More...
 
std::vector< arma::mat > denseA
 A_i for each dense constraint. More...
 
arma::vec denseB
 b_i for each dense constraint. More...
 
std::vector< arma::sp_mat > sparseA
 A_i for each sparse constraint. More...
 
arma::vec sparseB
 b_i for each sparse constraint. More...
 

Detailed Description

template<typename ObjectiveMatrixType>
class mlpack::optimization::SDP< ObjectiveMatrixType >

Specify an SDP in primal form.

min dot(C, X) s.t. dot(Ai, X) = bi, i=1,...,m, X >= 0

This representation allows the constraint matrices Ai to be specified as either dense matrices (arma::mat) or sparse matrices (arma::sp_mat). After initializing the SDP object, you will need to set the constraints yourself, via the SparseA(), SparseB(), DenseA(), DenseB(), and C() functions. Note that for each matrix you add to either SparseA() or DenseA(), you must add the corresponding b value to the corresponding vector SparseB() or DenseB().

The objective matrix (C) may be stored as either dense or sparse depending on the ObjectiveMatrixType parameter.

Template Parameters
ObjectiveMatrixTypeShould be either arma::mat or arma::sp_mat.

Definition at line 39 of file sdp.hpp.

Member Typedef Documentation

template<typename ObjectiveMatrixType>
typedef ObjectiveMatrixType mlpack::optimization::SDP< ObjectiveMatrixType >::objective_matrix_type

Definition at line 43 of file sdp.hpp.

Constructor & Destructor Documentation

template<typename ObjectiveMatrixType>
mlpack::optimization::SDP< ObjectiveMatrixType >::SDP ( )

Initialize this SDP to an empty state.

To add constraints, you will have to modify the constraints via the SparseA(), DenseA(), SparseB(), DenseB(), and C() functions. For the sake of speed, there is no error checking, so if you specify an invalid SDP, whatever solver you use will gladly try to solve it! (And it will probably crash horribly.)

Referenced by mlpack::optimization::LRSDP< optimization::SDP< arma::sp_mat > >::SDP().

template<typename ObjectiveMatrixType>
mlpack::optimization::SDP< ObjectiveMatrixType >::SDP ( const size_t  n,
const size_t  numSparseConstraints,
const size_t  numDenseConstraints 
)

Initialize this SDP to one which structurally has size n.

To set the constraints you will still need to access through SparseA(), DenseA(), SparseB(), DenseB(), and C(). Consider using move semantics to keep things fast. As with the previous constructor, there is no error checking for the sake of speed, so if you build an invalid SDP, whatever solver you use will gladly try to solve it! (And it will probably crash horribly.)

Parameters
nNumber of rows (and columns) in the objective matrix C.
numSparseConstraintsNumber of sparse constraints.
numDenseConstraintsNumber of dense constraints.

Member Function Documentation

template<typename ObjectiveMatrixType>
ObjectiveMatrixType& mlpack::optimization::SDP< ObjectiveMatrixType >::C ( )
inline

Modify the sparse objective function matrix (sparseC).

Definition at line 86 of file sdp.hpp.

template<typename ObjectiveMatrixType>
const ObjectiveMatrixType& mlpack::optimization::SDP< ObjectiveMatrixType >::C ( ) const
inline

Return the sparse objective function matrix (sparseC).

Definition at line 88 of file sdp.hpp.

template<typename ObjectiveMatrixType>
const std::vector<arma::mat>& mlpack::optimization::SDP< ObjectiveMatrixType >::DenseA ( ) const
inline

Return the vector of dense A matrices (which correspond to the dense constraints).

Definition at line 100 of file sdp.hpp.

template<typename ObjectiveMatrixType>
std::vector<arma::mat>& mlpack::optimization::SDP< ObjectiveMatrixType >::DenseA ( )
inline

Modify the veector of dense A matrices (which correspond to the dense constraints).

Definition at line 104 of file sdp.hpp.

template<typename ObjectiveMatrixType>
const arma::vec& mlpack::optimization::SDP< ObjectiveMatrixType >::DenseB ( ) const
inline

Return the vector of dense B values.

Definition at line 112 of file sdp.hpp.

template<typename ObjectiveMatrixType>
arma::vec& mlpack::optimization::SDP< ObjectiveMatrixType >::DenseB ( )
inline

Modify the vector of dense B values.

Definition at line 114 of file sdp.hpp.

template<typename ObjectiveMatrixType>
bool mlpack::optimization::SDP< ObjectiveMatrixType >::HasLinearlyIndependentConstraints ( ) const

Check whether or not the constraint matrices are linearly independent.

Warning: possibly very expensive check.

Referenced by mlpack::optimization::SDP< arma::sp_mat >::DenseB().

template<typename ObjectiveMatrixType>
size_t mlpack::optimization::SDP< ObjectiveMatrixType >::N ( ) const
inline

Return number of rows and columns in the objective matrix C.

Definition at line 71 of file sdp.hpp.

Referenced by mlpack::optimization::SDP< arma::sp_mat >::N2bar().

template<typename ObjectiveMatrixType>
size_t mlpack::optimization::SDP< ObjectiveMatrixType >::N2bar ( ) const
inline

Definition at line 73 of file sdp.hpp.

template<typename ObjectiveMatrixType>
size_t mlpack::optimization::SDP< ObjectiveMatrixType >::NumConstraints ( ) const
inline

Return the total number of constraints in the SDP.

Definition at line 83 of file sdp.hpp.

template<typename ObjectiveMatrixType>
size_t mlpack::optimization::SDP< ObjectiveMatrixType >::NumDenseConstraints ( ) const
inline

Return the number of dense constraints (constraints with dense Ai) in the SDP.

Definition at line 80 of file sdp.hpp.

template<typename ObjectiveMatrixType>
size_t mlpack::optimization::SDP< ObjectiveMatrixType >::NumSparseConstraints ( ) const
inline

Return the number of sparse constraints (constraints with sparse Ai) in the SDP.

Definition at line 77 of file sdp.hpp.

template<typename ObjectiveMatrixType>
const std::vector<arma::sp_mat>& mlpack::optimization::SDP< ObjectiveMatrixType >::SparseA ( ) const
inline

Return the vector of sparse A matrices (which correspond to the sparse constraints).

Definition at line 92 of file sdp.hpp.

template<typename ObjectiveMatrixType>
std::vector<arma::sp_mat>& mlpack::optimization::SDP< ObjectiveMatrixType >::SparseA ( )
inline

Modify the veector of sparse A matrices (which correspond to the sparse constraints).

Definition at line 96 of file sdp.hpp.

template<typename ObjectiveMatrixType>
const arma::vec& mlpack::optimization::SDP< ObjectiveMatrixType >::SparseB ( ) const
inline

Return the vector of sparse B values.

Definition at line 107 of file sdp.hpp.

template<typename ObjectiveMatrixType>
arma::vec& mlpack::optimization::SDP< ObjectiveMatrixType >::SparseB ( )
inline

Modify the vector of sparse B values.

Definition at line 109 of file sdp.hpp.

Member Data Documentation

template<typename ObjectiveMatrixType>
ObjectiveMatrixType mlpack::optimization::SDP< ObjectiveMatrixType >::c
private

Objective function matrix c.

Definition at line 125 of file sdp.hpp.

Referenced by mlpack::optimization::SDP< arma::sp_mat >::C(), and mlpack::optimization::SDP< arma::sp_mat >::N().

template<typename ObjectiveMatrixType>
std::vector<arma::mat> mlpack::optimization::SDP< ObjectiveMatrixType >::denseA
private

A_i for each dense constraint.

Definition at line 133 of file sdp.hpp.

Referenced by mlpack::optimization::SDP< arma::sp_mat >::DenseA().

template<typename ObjectiveMatrixType>
arma::vec mlpack::optimization::SDP< ObjectiveMatrixType >::denseB
private
template<typename ObjectiveMatrixType>
std::vector<arma::sp_mat> mlpack::optimization::SDP< ObjectiveMatrixType >::sparseA
private

A_i for each sparse constraint.

Definition at line 128 of file sdp.hpp.

Referenced by mlpack::optimization::SDP< arma::sp_mat >::SparseA().

template<typename ObjectiveMatrixType>
arma::vec mlpack::optimization::SDP< ObjectiveMatrixType >::sparseB
private

The documentation for this class was generated from the following file: