Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. // Just a basic idea.  LRSDP would need to be refactored, and probably AugLagrangian too.
  2. class SDP<typename ObjectiveMatrixType>
  3. {
  4.  public:
  5.   // This would be an API modification; I think it could work...
  6.   double Evaluate(const arma::mat& coordinates);
  7.   double EvaluateConstraint(const arma::mat& coordinates, const size_t i);
  8.   void Gradient(const arma::mat& coordinates, arma::mat& gradient);
  9.   void GradientConstraint(const arma::mat& coordinates, arma::mat& gradient);
  10.  
  11.  private:
  12.   ObjectiveMatrixType c;
  13.   std::vector<arma::sp_mat> sparseA;
  14.   arma::vec sparseB;
  15.   std::vector<arma::mat> denseA;
  16.   arma::vec denseB;
  17. };
  18.  
  19. template<typename ObjectiveMatrixType>
  20. class LinearConstraintSDP : public SDP<ObjectiveMatrixType>
  21. {
  22.  public:
  23.   // We need new evaluate functions...
  24.   double Evaluate(const arma::mat& coordinates);
  25.   double EvaluateConstraint(const arma::mat& coordinates, const size_t i);
  26.   void Gradient(const arma::mat& coordinates, arma::mat& gradient);
  27.   void GradientConstraint(const arma::mat& coordinates, arma::mat& gradient);
  28.  
  29.  private:
  30.   // In addition to what the parent class holds, we need to hold linear constraints too.
  31.   std::vector<LinearConstraint> linearA;
  32.   arma::vec linearB;
  33. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement