sdp.hpp
Go to the documentation of this file.
1 
11 #ifndef MLPACK_CORE_OPTIMIZERS_SDP_SDP_HPP
12 #define MLPACK_CORE_OPTIMIZERS_SDP_SDP_HPP
13 
14 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace optimization {
19 
38 template <typename ObjectiveMatrixType>
39 class SDP
40 {
41  public:
42  typedef ObjectiveMatrixType objective_matrix_type;
43 
51  SDP();
52 
65  SDP(const size_t n,
66  const size_t numSparseConstraints,
67  const size_t numDenseConstraints);
68 
70  size_t N() const { return c.n_rows; }
71 
72  size_t N2bar() const { return N() * (N() + 1) / 2; }
73 
76  size_t NumSparseConstraints() const { return sparseB.n_elem; }
79  size_t NumDenseConstraints() const { return denseB.n_elem; }
80 
82  size_t NumConstraints() const { return sparseB.n_elem + denseB.n_elem; }
83 
85  ObjectiveMatrixType& C() { return c; }
87  const ObjectiveMatrixType& C() const { return c; }
88 
91  const std::vector<arma::sp_mat>& SparseA() const { return sparseA; }
92 
95  std::vector<arma::sp_mat>& SparseA() { return sparseA; }
96 
99  const std::vector<arma::mat>& DenseA() const { return denseA; }
100 
103  std::vector<arma::mat>& DenseA() { return denseA; }
104 
106  const arma::vec& SparseB() const { return sparseB; }
108  arma::vec& SparseB() { return sparseB; }
109 
111  const arma::vec& DenseB() const { return denseB; }
113  arma::vec& DenseB() { return denseB; }
114 
121 
122  private:
124  ObjectiveMatrixType c;
125 
127  std::vector<arma::sp_mat> sparseA;
129  arma::vec sparseB;
130 
132  std::vector<arma::mat> denseA;
134  arma::vec denseB;
135 };
136 
137 } // namespace optimization
138 } // namespace mlpack
139 
140 // Include implementation.
141 #include "sdp_impl.hpp"
142 
143 #endif
std::vector< arma::mat > & DenseA()
Modify the vector of dense A matrices (which correspond to the dense constraints).
Definition: sdp.hpp:103
.hpp
Definition: add_to_po.hpp:21
const ObjectiveMatrixType & C() const
Return the sparse objective function matrix (sparseC).
Definition: sdp.hpp:87
size_t NumSparseConstraints() const
Return the number of sparse constraints (constraints with sparse Ai) in the SDP.
Definition: sdp.hpp:76
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t N() const
Return number of rows and columns in the objective matrix C.
Definition: sdp.hpp:70
const std::vector< arma::sp_mat > & SparseA() const
Return the vector of sparse A matrices (which correspond to the sparse constraints).
Definition: sdp.hpp:91
size_t NumConstraints() const
Return the total number of constraints in the SDP.
Definition: sdp.hpp:82
size_t N2bar() const
Definition: sdp.hpp:72
const std::vector< arma::mat > & DenseA() const
Return the vector of dense A matrices (which correspond to the dense constraints).
Definition: sdp.hpp:99
ObjectiveMatrixType & C()
Modify the sparse objective function matrix (sparseC).
Definition: sdp.hpp:85
ObjectiveMatrixType objective_matrix_type
Definition: sdp.hpp:42
size_t NumDenseConstraints() const
Return the number of dense constraints (constraints with dense Ai) in the SDP.
Definition: sdp.hpp:79
SDP()
Initialize this SDP to an empty state.
Specify an SDP in primal form.
Definition: sdp.hpp:39
arma::vec & SparseB()
Modify the vector of sparse B values.
Definition: sdp.hpp:108
std::vector< arma::sp_mat > & SparseA()
Modify the vector of sparse A matrices (which correspond to the sparse constraints).
Definition: sdp.hpp:95
arma::vec & DenseB()
Modify the vector of dense B values.
Definition: sdp.hpp:113
const arma::vec & DenseB() const
Return the vector of dense B values.
Definition: sdp.hpp:111
const arma::vec & SparseB() const
Return the vector of sparse B values.
Definition: sdp.hpp:106
bool HasLinearlyIndependentConstraints() const
Check whether or not the constraint matrices are linearly independent.