MLPACK  1.0.8
lrsdp.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_CORE_OPTIMIZERS_LRSDP_LRSDP_HPP
24 #define __MLPACK_CORE_OPTIMIZERS_LRSDP_LRSDP_HPP
25 
26 #include <mlpack/core.hpp>
28 
29 namespace mlpack {
30 namespace optimization {
31 
32 class LRSDP
33 {
34  public:
44  LRSDP(const size_t numConstraints,
45  const arma::mat& initialPoint);
46 
56  LRSDP(const size_t numConstraints,
57  const arma::mat& initialPoint,
58  AugLagrangian<LRSDP>& augLagrangian);
59 
66  double Optimize(arma::mat& coordinates);
67 
72  double Evaluate(const arma::mat& coordinates) const;
73 
78  void Gradient(const arma::mat& coordinates, arma::mat& gradient) const;
79 
83  double EvaluateConstraint(const size_t index,
84  const arma::mat& coordinates) const;
85 
90  void GradientConstraint(const size_t index,
91  const arma::mat& coordinates,
92  arma::mat& gradient) const;
93 
95  size_t NumConstraints() const { return b.n_elem; }
96 
98  const arma::mat& GetInitialPoint();
99 
101  const arma::mat& C() const { return c; }
103  arma::mat& C() { return c; }
104 
106  const std::vector<arma::mat>& A() const { return a; }
108  std::vector<arma::mat>& A() { return a; }
109 
111  const arma::uvec& AModes() const { return aModes; }
113  arma::uvec& AModes() { return aModes; }
114 
116  const arma::vec& B() const { return b; }
118  arma::vec& B() { return b; }
119 
121  const AugLagrangian<LRSDP>& AugLag() const { return augLag; }
124 
125  private:
126  // Should probably use sparse matrices for some of these.
127 
129  arma::mat c;
131  std::vector<arma::mat> a;
133  arma::vec b;
134 
136  arma::uvec aModes;
137 
139  arma::mat initialPoint;
140 
143 
146 };
147 
148 }; // namespace optimization
149 }; // namespace mlpack
150 
151 // Include implementation.
152 #include "lrsdp_impl.hpp"
153 
154 #endif
arma::mat initialPoint
Initial point.
Definition: lrsdp.hpp:139
double EvaluateConstraint(const size_t index, const arma::mat &coordinates) const
Evaluate a particular constraint of the LRSDP at the given coordinates.
arma::vec & B()
Modify the vector of B values.
Definition: lrsdp.hpp:118
AugLagrangian< LRSDP > augLagInternal
Internal AugLagrangian object, if one was not passed at construction time.
Definition: lrsdp.hpp:142
const arma::mat & GetInitialPoint()
Get the initial point of the LRSDP.
arma::uvec aModes
1 if entries in matrix, 0 for normal.
Definition: lrsdp.hpp:136
arma::vec b
b_i for each constraint.
Definition: lrsdp.hpp:133
const std::vector< arma::mat > & A() const
Return the vector of A matrices (which correspond to the constraints).
Definition: lrsdp.hpp:106
arma::uvec & AModes()
Modify the vector of modes for the A matrices.
Definition: lrsdp.hpp:113
AugLagrangian< LRSDP > & AugLag()
Modify the augmented Lagrangian object.
Definition: lrsdp.hpp:123
std::vector< arma::mat > a
A_i for each constraint.
Definition: lrsdp.hpp:131
The AugLagrangian class implements the Augmented Lagrangian method of optimization.
const AugLagrangian< LRSDP > & AugLag() const
Return the augmented Lagrangian object.
Definition: lrsdp.hpp:121
size_t NumConstraints() const
Get the number of constraints in the LRSDP.
Definition: lrsdp.hpp:95
LRSDP(const size_t numConstraints, const arma::mat &initialPoint)
Create an LRSDP to be optimized.
const arma::uvec & AModes() const
Return the vector of modes for the A matrices.
Definition: lrsdp.hpp:111
std::vector< arma::mat > & A()
Modify the veector of A matrices (which correspond to the constraints).
Definition: lrsdp.hpp:108
const arma::mat & C() const
Return the objective function matrix (C).
Definition: lrsdp.hpp:101
arma::mat c
For objective function.
Definition: lrsdp.hpp:129
AugLagrangian< LRSDP > & augLag
The AugLagrangian object which will be used for optimization.
Definition: lrsdp.hpp:145
double Evaluate(const arma::mat &coordinates) const
Evaluate the objective function of the LRSDP (no constraints) at the given coordinates.
void GradientConstraint(const size_t index, const arma::mat &coordinates, arma::mat &gradient) const
Evaluate the gradient of a particular constraint of the LRSDP at the given coordinates.
const arma::vec & B() const
Return the vector of B values.
Definition: lrsdp.hpp:116
void Gradient(const arma::mat &coordinates, arma::mat &gradient) const
Evaluate the gradient of the LRSDP (no constraints) at the given coordinates.
double Optimize(arma::mat &coordinates)
Optimize the LRSDP and return the final objective value.
arma::mat & C()
Modify the objective function matrix (C).
Definition: lrsdp.hpp:103