Commit 8756de5a authored by David Bommes's avatar David Bommes

added BoundConstraint.cc

git-svn-id: http://www.openflipper.org/svnrepo/CoMISo/trunk@115 1355f012-dd97-4b2f-ae87-10fa9f823a57
parent 493315ae
//=============================================================================
//
// CLASS BoundConstraint - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include "BoundConstraint.hh"
//== FORWARDDECLARATIONS ======================================================
//== NAMESPACES ===============================================================
namespace COMISO {
//== CLASS DEFINITION =========================================================
BoundConstraint::
BoundConstraint(const unsigned int _var_idx, // index of variable for bound constraint
const double _bound, // bound: x(_var_idx) #_type, <,=,># _bound
const unsigned int _n, // number of unknowns in problem
const ConstraintType _type) // type of bound upper, lower or both (equal)
: NConstraintInterface(_type), idx_(_var_idx), bound_(_bound), n_(_n)
{
}
//-----------------------------------------------------------------------------
BoundConstraint::
~BoundConstraint()
{
}
//-----------------------------------------------------------------------------
int
BoundConstraint::
n_unknowns()
{
return n_;
}
//-----------------------------------------------------------------------------
double
BoundConstraint::
eval_constraint ( const double* _x )
{
return _x[idx_] - bound_;
}
//-----------------------------------------------------------------------------
void
BoundConstraint::
eval_gradient ( const double* _x, SVectorNC& _g )
{
_g.resize(n_); _g.coeffRef(idx_) = 1.0;
}
//-----------------------------------------------------------------------------
void
BoundConstraint::
eval_hessian ( const double* _x, SMatrixNC& _h )
{
_h.clear(); _h.resize(n_,n_);
}
//-----------------------------------------------------------------------------
bool
BoundConstraint::
is_linear()
{
return true;
}
//-----------------------------------------------------------------------------
unsigned int&
BoundConstraint::
idx()
{
return idx_;
}
//-----------------------------------------------------------------------------
double&
BoundConstraint::
bound()
{
return bound_;
}
//-----------------------------------------------------------------------------
unsigned int&
BoundConstraint::
n()
{
return n_;
}
//=============================================================================
} // namespace COMISO
//=============================================================================
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment