mlpack  master
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 
43  typedef ObjectiveMatrixType objective_matrix_type;
44 
52  SDP();
53 
66  SDP(const size_t n,
67  const size_t numSparseConstraints,
68  const size_t numDenseConstraints);
69 
71  size_t N() const { return c.n_rows; }
72 
73  size_t N2bar() const { return N() * (N() + 1) / 2; }
74 
77  size_t NumSparseConstraints() const { return sparseB.n_elem; }
80  size_t NumDenseConstraints() const { return denseB.n_elem; }
81 
83  size_t NumConstraints() const { return sparseB.n_elem + denseB.n_elem; }
84 
86  ObjectiveMatrixType& C() { return c; }
88  const ObjectiveMatrixType& C() const { return c; }
89 
92  const std::vector<arma::sp_mat>& SparseA() const { return sparseA; }
93 
96  std::vector<arma::sp_mat>& SparseA() { return sparseA; }
97 
100  const std::vector<arma::mat>& DenseA() const { return denseA; }
101 
104  std::vector<arma::mat>& DenseA() { return denseA; }
105 
107  const arma::vec& SparseB() const { return sparseB; }
109  arma::vec& SparseB() { return sparseB; }
110 
112  const arma::vec& DenseB() const { return denseB; }
114  arma::vec& DenseB() { return denseB; }
115 
122 
123  private:
125  ObjectiveMatrixType c;
126 
128  std::vector<arma::sp_mat> sparseA;
130  arma::vec sparseB;
131 
133  std::vector<arma::mat> denseA;
135  arma::vec denseB;
136 };
137 
138 } // namespace optimization
139 } // namespace mlpack
140 
141 // Include implementation.
142 #include "sdp_impl.hpp"
143 
144 #endif
const std::vector< arma::mat > & DenseA() const
Return the vector of dense A matrices (which correspond to the dense constraints).
Definition: sdp.hpp:100
ObjectiveMatrixType & C()
Modify the sparse objective function matrix (sparseC).
Definition: sdp.hpp:86
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
const arma::vec & DenseB() const
Return the vector of dense B values.
Definition: sdp.hpp:112
The core includes that mlpack expects; standard C++ includes and Armadillo.
const arma::vec & SparseB() const
Return the vector of sparse B values.
Definition: sdp.hpp:107
std::vector< arma::sp_mat > sparseA
A_i for each sparse constraint.
Definition: sdp.hpp:128
arma::vec denseB
b_i for each dense constraint.
Definition: sdp.hpp:135
size_t N() const
Return number of rows and columns in the objective matrix C.
Definition: sdp.hpp:71
bool HasLinearlyIndependentConstraints() const
Check whether or not the constraint matrices are linearly independent.
size_t NumDenseConstraints() const
Return the number of dense constraints (constraints with dense Ai) in the SDP.
Definition: sdp.hpp:80
SDP()
Initialize this SDP to an empty state.
arma::vec sparseB
b_i for each sparse constraint.
Definition: sdp.hpp:130
size_t NumSparseConstraints() const
Return the number of sparse constraints (constraints with sparse Ai) in the SDP.
Definition: sdp.hpp:77
size_t NumConstraints() const
Return the total number of constraints in the SDP.
Definition: sdp.hpp:83
ObjectiveMatrixType c
Objective function matrix c.
Definition: sdp.hpp:125
std::vector< arma::mat > & DenseA()
Modify the veector of dense A matrices (which correspond to the dense constraints).
Definition: sdp.hpp:104
std::vector< arma::sp_mat > & SparseA()
Modify the veector of sparse A matrices (which correspond to the sparse constraints).
Definition: sdp.hpp:96
std::vector< arma::mat > denseA
A_i for each dense constraint.
Definition: sdp.hpp:133
const std::vector< arma::sp_mat > & SparseA() const
Return the vector of sparse A matrices (which correspond to the sparse constraints).
Definition: sdp.hpp:92
size_t N2bar() const
Definition: sdp.hpp:73
Specify an SDP in primal form.
Definition: sdp.hpp:39
ObjectiveMatrixType objective_matrix_type
Definition: sdp.hpp:43
arma::vec & DenseB()
Modify the vector of dense B values.
Definition: sdp.hpp:114
arma::vec & SparseB()
Modify the vector of sparse B values.
Definition: sdp.hpp:109
const ObjectiveMatrixType & C() const
Return the sparse objective function matrix (sparseC).
Definition: sdp.hpp:88