LinearConstraint.hh 2.54 KB
Newer Older
David Bommes's avatar
David Bommes committed
1 2 3 4 5 6 7 8 9 10 11 12 13
//=============================================================================
//
//  CLASS NConstraintGmmInterface
//
//=============================================================================


#ifndef COMISO_LINEARCONSTRAINT_HH
#define COMISO_LINEARCONSTRAINT_HH


//== INCLUDES =================================================================

Jan Möbius's avatar
Jan Möbius committed
14
#include <CoMISo/Config/CoMISoDefines.hh>
David Bommes's avatar
David Bommes committed
15
#include "NConstraintInterface.hh"
David Bommes's avatar
David Bommes committed
16 17
#include <Eigen/StdVector>

David Bommes's avatar
David Bommes committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

//== FORWARDDECLARATIONS ======================================================

//== NAMESPACES ===============================================================

namespace COMISO {

//== CLASS DEFINITION =========================================================

	      

/** \class NProblemGmmInterface NProblemGmmInterface.hh <ACG/.../NPRoblemGmmInterface.hh>

    Brief Description.
  
    A more elaborate description follows.
*/
Jan Möbius's avatar
Jan Möbius committed
35
class COMISODLLEXPORT LinearConstraint : public NConstraintInterface
David Bommes's avatar
David Bommes committed
36 37 38
{
public:

David Bommes's avatar
David Bommes committed
39
  // sparse vector type
Jan Möbius's avatar
Jan Möbius committed
40
  typedef NConstraintInterface::SVectorNC SVectorNC;
David Bommes's avatar
David Bommes committed
41 42 43 44 45

  // different types of constraints
//  enum ConstraintType {NC_EQUAL, NC_LESS_EQUAL, NC_GREATER_EQUAL};

  /// Default constructor
Jan Möbius's avatar
Jan Möbius committed
46
  LinearConstraint(const ConstraintType _type = NC_EQUAL);
David Bommes's avatar
David Bommes committed
47

48
  // linear equation of the form -> coeffs_^T *x  + b_=_type= 0
Jan Möbius's avatar
Jan Möbius committed
49
  LinearConstraint(const SVectorNC& _coeffs, const double _b, const ConstraintType _type = NC_EQUAL);
David Bommes's avatar
David Bommes committed
50 51

  /// Destructor
Jan Möbius's avatar
Jan Möbius committed
52
  ~LinearConstraint();
David Bommes's avatar
David Bommes committed
53

Jan Möbius's avatar
Jan Möbius committed
54
  virtual int n_unknowns();
David Bommes's avatar
David Bommes committed
55

David Bommes's avatar
David Bommes committed
56 57
  void  resize(const unsigned int _n);

David Bommes's avatar
David Bommes committed
58 59 60 61 62
  const SVectorNC& coeffs() const;
        SVectorNC& coeffs();

  const double&    b() const;
        double&    b();
63

Jan Möbius's avatar
Jan Möbius committed
64 65 66
  virtual double eval_constraint ( const double* _x );
  
  virtual void eval_gradient( const double* _x, SVectorNC& _g      );
David Bommes's avatar
David Bommes committed
67

Jan Möbius's avatar
Jan Möbius committed
68
  virtual void eval_hessian    ( const double* _x, SMatrixNC& _h      );
David Bommes's avatar
David Bommes committed
69

David Bommes's avatar
David Bommes committed
70 71
  virtual bool is_linear() { return true;}

David Bommes's avatar
David Bommes committed
72 73 74 75 76 77
  // inherited from base
//  virtual ConstraintType  constraint_type (                                      ) { return type_; }

private:

  // linear equation of the form -> coeffs_^T * x + b_
David Bommes's avatar
David Bommes committed
78
  SVectorNC coeffs_;
David Bommes's avatar
David Bommes committed
79 80 81 82 83 84 85
  double    b_;
};


//=============================================================================
} // namespace COMISO
//=============================================================================
David Bommes's avatar
David Bommes committed
86 87 88
// support std vectors
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(COMISO::LinearConstraint);
//=============================================================================
David Bommes's avatar
David Bommes committed
89 90 91
#endif // ACG_LINEARCONSTRAINT_HH defined
//=============================================================================