mlpack  master
lrsdp_function.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_OPTIMIZERS_SDP_LRSDP_FUNCTION_HPP
14 #define MLPACK_CORE_OPTIMIZERS_SDP_LRSDP_FUNCTION_HPP
15 
16 #include <mlpack/prereqs.hpp>
19 
20 namespace mlpack {
21 namespace optimization {
22 
26 template <typename SDPType>
28 {
29  public:
30 
37  LRSDPFunction(const SDPType& sdp,
38  const arma::mat& initialPoint);
39 
51  LRSDPFunction(const size_t numSparseConstraints,
52  const size_t numDenseConstraints,
53  const arma::mat& initialPoint);
54 
59  double Evaluate(const arma::mat& coordinates) const;
60 
65  void Gradient(const arma::mat& coordinates, arma::mat& gradient) const;
66 
70  double EvaluateConstraint(const size_t index,
71  const arma::mat& coordinates) const;
76  void GradientConstraint(const size_t index,
77  const arma::mat& coordinates,
78  arma::mat& gradient) const;
79 
81  size_t NumConstraints() const { return sdp.NumConstraints(); }
82 
84  const arma::mat& GetInitialPoint() const { return initialPoint; }
85 
87  const SDPType& SDP() const { return sdp; }
88 
90  SDPType& SDP() { return sdp; }
91 
92  private:
93 
95  SDPType sdp;
96 
98  arma::mat initialPoint;
99 };
100 
101 // Declare specializations in lrsdp_function.cpp.
102 template <>
104  const arma::mat& coordinates) const;
105 
106 template <>
108  const arma::mat& coordinates) const;
109 
110 template <>
112  const arma::mat& coordinates,
113  arma::mat& gradient) const;
114 
115 template <>
117  const arma::mat& coordinates,
118  arma::mat& gradient) const;
119 
120 } // namespace optimization
121 } // namespace mlpack
122 
123 // Include implementation
124 #include "lrsdp_function_impl.hpp"
125 
126 #endif // MLPACK_CORE_OPTIMIZERS_SDP_LRSDP_FUNCTION_HPP
const SDPType & SDP() const
Return the SDP object representing the problem.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
double EvaluateConstraint(const size_t index, const arma::mat &coordinates) const
Evaluate a particular constraint of the LRSDP 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.
The objective function that LRSDP is trying to optimize.
SDPType sdp
SDP object representing the problem.
SDPType & SDP()
Modify the SDP object representing the problem.
The core includes that mlpack expects; standard C++ includes and Armadillo.
const arma::mat & GetInitialPoint() const
Get the initial point of the LRSDP.
double Evaluate(const arma::mat &coordinates) const
Evaluate the objective function of the LRSDP (no constraints) at the given coordinates.
arma::mat initialPoint
Initial point.
LRSDPFunction(const SDPType &sdp, const arma::mat &initialPoint)
Construct the LRSDPFunction from the given SDP.
void Gradient(const arma::mat &coordinates, arma::mat &gradient) const
Evaluate the gradient of the LRSDP (no constraints) at the given coordinates.
This is a utility class used by AugLagrangian, meant to wrap a LagrangianFunction into a function usa...
size_t NumConstraints() const
Get the total number of constraints in the LRSDP.