mlpack  2.0.1
sdp.hpp
Go to the documentation of this file.
1 
13 #ifndef __MLPACK_CORE_OPTIMIZERS_SDP_SDP_HPP
14 #define __MLPACK_CORE_OPTIMIZERS_SDP_SDP_HPP
15 
16 #include <mlpack/core.hpp>
17 
18 namespace mlpack {
19 namespace optimization {
20 
39 template <typename ObjectiveMatrixType>
40 class SDP
41 {
42  public:
43 
44  typedef ObjectiveMatrixType objective_matrix_type;
45 
53  SDP();
54 
67  SDP(const size_t n,
68  const size_t numSparseConstraints,
69  const size_t numDenseConstraints);
70 
72  size_t N() const { return c.n_rows; }
73 
74  size_t N2bar() const { return N() * (N() + 1) / 2; }
75 
78  size_t NumSparseConstraints() const { return sparseB.n_elem; }
81  size_t NumDenseConstraints() const { return denseB.n_elem; }
82 
84  size_t NumConstraints() const { return sparseB.n_elem + denseB.n_elem; }
85 
87  ObjectiveMatrixType& C() { return c; }
89  const ObjectiveMatrixType& C() const { return c; }
90 
93  const std::vector<arma::sp_mat>& SparseA() const { return sparseA; }
94 
97  std::vector<arma::sp_mat>& SparseA() { return sparseA; }
98 
101  const std::vector<arma::mat>& DenseA() const { return denseA; }
102 
105  std::vector<arma::mat>& DenseA() { return denseA; }
106 
108  const arma::vec& SparseB() const { return sparseB; }
110  arma::vec& SparseB() { return sparseB; }
111 
113  const arma::vec& DenseB() const { return denseB; }
115  arma::vec& DenseB() { return denseB; }
116 
123 
124  private:
126  ObjectiveMatrixType c;
127 
129  std::vector<arma::sp_mat> sparseA;
131  arma::vec sparseB;
132 
134  std::vector<arma::mat> denseA;
136  arma::vec denseB;
137 };
138 
139 } // namespace optimization
140 } // namespace mlpack
141 
142 // Include implementation.
143 #include "sdp_impl.hpp"
144 
145 #endif
const arma::vec & DenseB() const
Return the vector of dense B values.
Definition: sdp.hpp:113
const ObjectiveMatrixType & C() const
Return the sparse objective function matrix (sparseC).
Definition: sdp.hpp:89
ObjectiveMatrixType & C()
Modify the sparse objective function matrix (sparseC).
Definition: sdp.hpp:87
Linear algebra utility functions, generally performed on matrices or vectors.
std::vector< arma::sp_mat > sparseA
A_i for each sparse constraint.
Definition: sdp.hpp:129
arma::vec denseB
b_i for each dense constraint.
Definition: sdp.hpp:136
const std::vector< arma::sp_mat > & SparseA() const
Return the vector of sparse A matrices (which correspond to the sparse constraints).
Definition: sdp.hpp:93
bool HasLinearlyIndependentConstraints() const
Check whether or not the constraint matrices are linearly independent.
size_t N() const
Return number of rows and columns in the objective matrix C.
Definition: sdp.hpp:72
const arma::vec & SparseB() const
Return the vector of sparse B values.
Definition: sdp.hpp:108
size_t NumConstraints() const
Return the total number of constraints in the SDP.
Definition: sdp.hpp:84
const std::vector< arma::mat > & DenseA() const
Return the vector of dense A matrices (which correspond to the dense constraints).
Definition: sdp.hpp:101
SDP()
Initialize this SDP to an empty state.
arma::vec sparseB
b_i for each sparse constraint.
Definition: sdp.hpp:131
size_t NumDenseConstraints() const
Return the number of dense constraints (constraints with dense Ai) in the SDP.
Definition: sdp.hpp:81
size_t NumSparseConstraints() const
Return the number of sparse constraints (constraints with sparse Ai) in the SDP.
Definition: sdp.hpp:78
ObjectiveMatrixType c
Objective function matrix c.
Definition: sdp.hpp:126
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
std::vector< arma::mat > & DenseA()
Modify the veector of dense A matrices (which correspond to the dense constraints).
Definition: sdp.hpp:105
std::vector< arma::sp_mat > & SparseA()
Modify the veector of sparse A matrices (which correspond to the sparse constraints).
Definition: sdp.hpp:97
std::vector< arma::mat > denseA
A_i for each dense constraint.
Definition: sdp.hpp:134
size_t N2bar() const
Definition: sdp.hpp:74
Specify an SDP in primal form.
Definition: sdp.hpp:40
ObjectiveMatrixType objective_matrix_type
Definition: sdp.hpp:44
arma::vec & DenseB()
Modify the vector of dense B values.
Definition: sdp.hpp:115
arma::vec & SparseB()
Modify the vector of sparse B values.
Definition: sdp.hpp:110